3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='git apply with rejects
12 test_expect_success setup
'
13 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
17 cat file1 >saved.file1 &&
18 git update-index --add file1 &&
19 git commit -m initial &&
21 for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21
28 for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21
34 git update-index --add --remove file1 file2 &&
35 git diff -M HEAD >patch.2 &&
38 mv saved.file1 file1 &&
39 git update-index --add --remove file1 file2 &&
41 for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21
46 cat file1 >saved.file1
49 test_expect_success
'apply --reject is incompatible with --3way' '
50 test_when_finished "cat saved.file1 >file1" &&
53 test_must_fail git apply --reject --3way patch.0 &&
57 test_expect_success
'apply without --reject should fail' '
65 test_cmp file1 saved.file1
68 test_expect_success
'apply without --reject should fail' '
70 if git apply --verbose patch.1
76 test_cmp file1 saved.file1
79 test_expect_success
'apply with --reject should fail but update the file' '
81 cat saved.file1 >file1 &&
82 rm -f file1.rej file2.rej &&
84 if git apply --reject patch.1
86 echo "succeeds with --reject?"
90 test_cmp file1 expected &&
96 echo "file2 should not have been touched"
101 test_expect_success
'apply with --reject should fail but update the file' '
103 cat saved.file1 >file1 &&
104 rm -f file1.rej file2.rej file2 &&
106 if git apply --reject patch.2 >rejects
108 echo "succeeds with --reject?"
113 echo "file1 still exists?"
116 test_cmp file2 expected &&
122 echo "file2 should not have been touched"
128 test_expect_success
'the same test with --verbose' '
130 cat saved.file1 >file1 &&
131 rm -f file1.rej file2.rej file2 &&
133 if git apply --reject --verbose patch.2 >rejects
135 echo "succeeds with --reject?"
140 echo "file1 still exists?"
143 test_cmp file2 expected &&
149 echo "file2 should not have been touched"
155 test_expect_success
'apply cleanly with --verbose' '
157 git cat-file -p HEAD:file1 >file1 &&
158 rm -f file?.rej file2 &&
160 git apply --verbose patch.1 &&