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 without --reject should fail' '
57 diff -u file1 saved.file1
60 test_expect_success 'apply with --reject should fail but update the file' '
62 cat saved.file1 >file1 &&
63 rm -f file1.rej file2.rej &&
65 if git apply --reject patch.1
67 echo "succeeds with --reject?"
71 diff -u file1 expected &&
77 echo "file2 should not have been touched"
82 test_expect_success 'apply with --reject should fail but update the file' '
84 cat saved.file1 >file1 &&
85 rm -f file1.rej file2.rej file2 &&
87 if git apply --reject patch.2 >rejects
89 echo "succeeds with --reject?"
94 echo "file1 still exists?"
97 diff -u file2 expected &&
103 echo "file2 should not have been touched"