Merge branch 'ms/rebase-insnformat-doc-fix' into maint-2.43
[git.git] / t / t4135-apply-weird-filenames.sh
blobd3502c6fddf5a6a69bde769b1f808c9431d1e38e
1 #!/bin/sh
3 test_description='git apply with weird postimage filenames'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 vector=$TEST_DIRECTORY/t4135 &&
11 test_tick &&
12 git commit --allow-empty -m preimage &&
13 git tag preimage &&
15 reset_preimage() {
16 git checkout -f preimage^0 &&
17 git read-tree -u --reset HEAD &&
18 git update-index --refresh
22 try_filename() {
23 desc=$1
24 postimage=$2
25 prereq=${3:-}
26 exp1=${4:-success}
27 exp2=${5:-success}
28 exp3=${6:-success}
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'
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'
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'
55 try_filename 'plain' 'postimage.txt'
56 try_filename 'with spaces' 'post image.txt'
57 try_filename 'with tab' 'post image.txt' FUNNYNAMES
58 try_filename 'with backslash' 'post\image.txt' BSLASHPSPEC
59 try_filename 'with quote' '"postimage".txt' FUNNYNAMES success failure success
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
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"
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"
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 @@
94 EOF
96 test_expect_success 'apply handles a diff generated by Subversion' '
97 >Makefile &&
98 git apply -p2 diff-from-svn &&
99 test_path_is_missing Makefile
102 test_done