Merge branch 'master' of git://git.kernel.org/pub/scm/git/git
[git/jnareb-git.git] / t / t4135-apply-weird-filenames.sh
blobbf5dc57286493b0b94caf927304e92db11e54f2c
1 #!/bin/sh
3 test_description='git apply with weird postimage filenames'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 vector=$TEST_DIRECTORY/t4135 &&
10 test_tick &&
11 git commit --allow-empty -m preimage &&
12 git tag preimage &&
14 reset_preimage() {
15 git checkout -f preimage^0 &&
16 git read-tree -u --reset HEAD &&
17 git update-index --refresh
18 } &&
20 test_when_finished "rm -f \"tab embedded.txt\"" &&
21 test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" &&
22 if touch -- "tab embedded.txt" '\''"quoteembedded".txt'\''
23 then
24 test_set_prereq FUNNYNAMES
28 try_filename() {
29 desc=$1
30 postimage=$2
31 prereq=${3:-}
32 exp1=${4:-success}
33 exp2=${5:-success}
34 exp3=${6:-success}
36 test_expect_$exp1 $prereq "$desc, git-style file creation patch" "
37 echo postimage >expected &&
38 reset_preimage &&
39 rm -f '$postimage' &&
40 git apply -v \"\$vector\"/'git-$desc.diff' &&
41 test_cmp expected '$postimage'
44 test_expect_$exp2 $prereq "$desc, traditional patch" "
45 echo postimage >expected &&
46 reset_preimage &&
47 echo preimage >'$postimage' &&
48 git apply -v \"\$vector\"/'diff-$desc.diff' &&
49 test_cmp expected '$postimage'
52 test_expect_$exp3 $prereq "$desc, traditional file creation patch" "
53 echo postimage >expected &&
54 reset_preimage &&
55 rm -f '$postimage' &&
56 git apply -v \"\$vector\"/'add-$desc.diff' &&
57 test_cmp expected '$postimage'
61 try_filename 'plain' 'postimage.txt'
62 try_filename 'with spaces' 'post image.txt'
63 try_filename 'with tab' 'post image.txt' FUNNYNAMES
64 try_filename 'with backslash' 'post\image.txt' BSLASHPSPEC
65 try_filename 'with quote' '"postimage".txt' FUNNYNAMES success failure success
67 test_expect_success 'whitespace-damaged traditional patch' '
68 echo postimage >expected &&
69 reset_preimage &&
70 rm -f postimage.txt &&
71 git apply -v "$vector/damaged.diff" &&
72 test_cmp expected postimage.txt
75 test_expect_success 'traditional patch with colon in timezone' '
76 echo postimage >expected &&
77 reset_preimage &&
78 rm -f "post image.txt" &&
79 git apply "$vector/funny-tz.diff" &&
80 test_cmp expected "post image.txt"
83 test_expect_success 'traditional, whitespace-damaged, colon in timezone' '
84 echo postimage >expected &&
85 reset_preimage &&
86 rm -f "post image.txt" &&
87 git apply "$vector/damaged-tz.diff" &&
88 test_cmp expected "post image.txt"
91 test_done