]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4135-apply-weird-filenames.sh
Start the 2.46 cycle
[thirdparty/git.git] / t / t4135-apply-weird-filenames.sh
CommitLineData
c51c0da2
JN
1#!/bin/sh
2
3test_description='git apply with weird postimage filenames'
4
03267e86 5TEST_PASSES_SANITIZE_LEAK=true
c51c0da2
JN
6. ./test-lib.sh
7
8test_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
22try_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
55try_filename 'plain' 'postimage.txt'
5a12c886
JN
56try_filename 'with spaces' 'post image.txt'
57try_filename 'with tab' 'post image.txt' FUNNYNAMES
c51c0da2
JN
58try_filename 'with backslash' 'post\image.txt' BSLASHPSPEC
59try_filename 'with quote' '"postimage".txt' FUNNYNAMES success failure success
60
61test_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
69test_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
77test_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
85cat >diff-from-svn <<\EOF
86Index: Makefile
87===================================================================
88diff --git a/branches/Makefile
89deleted file mode 100644
90--- a/branches/Makefile (revision 13)
91+++ /dev/null (nonexistent)
92@@ +1 0,0 @@
93-
94EOF
95
e454ad4b 96test_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 102test_done