]>
Commit | Line | Data |
---|---|---|
c51c0da2 JN |
1 | #!/bin/sh |
2 | ||
3 | test_description='git apply with weird postimage filenames' | |
4 | ||
03267e86 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
c51c0da2 JN |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'setup' ' | |
9 | vector=$TEST_DIRECTORY/t4135 && | |
10 | ||
11 | test_tick && | |
12 | git commit --allow-empty -m preimage && | |
13 | git tag preimage && | |
14 | ||
15 | reset_preimage() { | |
16 | git checkout -f preimage^0 && | |
17 | git read-tree -u --reset HEAD && | |
18 | git update-index --refresh | |
6ec63305 | 19 | } |
c51c0da2 JN |
20 | ' |
21 | ||
22 | try_filename() { | |
23 | desc=$1 | |
24 | postimage=$2 | |
25 | prereq=${3:-} | |
26 | exp1=${4:-success} | |
27 | exp2=${5:-success} | |
28 | exp3=${6:-success} | |
29 | ||
30 | test_expect_$exp1 $prereq "$desc, git-style file creation patch" " | |
31 | echo postimage >expected && | |
32 | reset_preimage && | |
33 | rm -f '$postimage' && | |
34 | git apply -v \"\$vector\"/'git-$desc.diff' && | |
35 | test_cmp expected '$postimage' | |
36 | " | |
37 | ||
38 | test_expect_$exp2 $prereq "$desc, traditional patch" " | |
39 | echo postimage >expected && | |
40 | reset_preimage && | |
41 | echo preimage >'$postimage' && | |
42 | git apply -v \"\$vector\"/'diff-$desc.diff' && | |
43 | test_cmp expected '$postimage' | |
44 | " | |
45 | ||
46 | test_expect_$exp3 $prereq "$desc, traditional file creation patch" " | |
47 | echo postimage >expected && | |
48 | reset_preimage && | |
49 | rm -f '$postimage' && | |
50 | git apply -v \"\$vector\"/'add-$desc.diff' && | |
51 | test_cmp expected '$postimage' | |
52 | " | |
53 | } | |
54 | ||
55 | try_filename 'plain' 'postimage.txt' | |
5a12c886 JN |
56 | try_filename 'with spaces' 'post image.txt' |
57 | try_filename 'with tab' 'post image.txt' FUNNYNAMES | |
c51c0da2 JN |
58 | try_filename 'with backslash' 'post\image.txt' BSLASHPSPEC |
59 | try_filename 'with quote' '"postimage".txt' FUNNYNAMES success failure success | |
60 | ||
61 | test_expect_success 'whitespace-damaged traditional patch' ' | |
62 | echo postimage >expected && | |
63 | reset_preimage && | |
64 | rm -f postimage.txt && | |
65 | git apply -v "$vector/damaged.diff" && | |
66 | test_cmp expected postimage.txt | |
67 | ' | |
68 | ||
2d502e1f JN |
69 | test_expect_success 'traditional patch with colon in timezone' ' |
70 | echo postimage >expected && | |
71 | reset_preimage && | |
72 | rm -f "post image.txt" && | |
73 | git apply "$vector/funny-tz.diff" && | |
74 | test_cmp expected "post image.txt" | |
75 | ' | |
76 | ||
77 | test_expect_success 'traditional, whitespace-damaged, colon in timezone' ' | |
78 | echo postimage >expected && | |
79 | reset_preimage && | |
80 | rm -f "post image.txt" && | |
81 | git apply "$vector/damaged-tz.diff" && | |
82 | test_cmp expected "post image.txt" | |
83 | ' | |
84 | ||
f16ef7bd JS |
85 | cat >diff-from-svn <<\EOF |
86 | Index: Makefile | |
87 | =================================================================== | |
88 | diff --git a/branches/Makefile | |
89 | deleted file mode 100644 | |
90 | --- a/branches/Makefile (revision 13) | |
91 | +++ /dev/null (nonexistent) | |
92 | @@ +1 0,0 @@ | |
93 | - | |
94 | EOF | |
95 | ||
e454ad4b | 96 | test_expect_success 'apply handles a diff generated by Subversion' ' |
f16ef7bd JS |
97 | >Makefile && |
98 | git apply -p2 diff-from-svn && | |
99 | test_path_is_missing Makefile | |
100 | ' | |
101 | ||
c51c0da2 | 102 | test_done |