add DUP_ARRAY
[git.git] / t / t4117-apply-reject.sh
blobc86d05a96fe8d5c7a561028c8dad452f89eb6876
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git apply with rejects
10 . ./test-lib.sh
12 test_expect_success setup '
13 test_write_lines 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 >file1 &&
14 cat file1 >saved.file1 &&
15 git update-index --add file1 &&
16 git commit -m initial &&
18 test_write_lines 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21 >file1 &&
19 git diff >patch.1 &&
20 cat file1 >clean &&
22 test_write_lines 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21 >expected &&
24 mv file1 file2 &&
25 git update-index --add --remove file1 file2 &&
26 git diff -M HEAD >patch.2 &&
28 rm -f file1 file2 &&
29 mv saved.file1 file1 &&
30 git update-index --add --remove file1 file2 &&
32 test_write_lines 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21 >file1 &&
34 cat file1 >saved.file1
37 test_expect_success 'apply --reject is incompatible with --3way' '
38 test_when_finished "cat saved.file1 >file1" &&
39 git diff >patch.0 &&
40 git checkout file1 &&
41 test_must_fail git apply --reject --3way patch.0 &&
42 git diff --exit-code
45 test_expect_success 'apply without --reject should fail' '
47 test_must_fail git apply patch.1 &&
48 test_cmp file1 saved.file1
51 test_expect_success 'apply without --reject should fail' '
53 test_must_fail git apply --verbose patch.1 &&
54 test_cmp file1 saved.file1
57 test_expect_success 'apply with --reject should fail but update the file' '
59 cat saved.file1 >file1 &&
60 rm -f file1.rej file2.rej &&
62 test_must_fail git apply --reject patch.1 &&
63 test_cmp expected file1 &&
65 test_path_is_file file1.rej &&
66 test_path_is_missing file2.rej
69 test_expect_success 'apply with --reject should fail but update the file' '
71 cat saved.file1 >file1 &&
72 rm -f file1.rej file2.rej file2 &&
74 test_must_fail git apply --reject patch.2 >rejects &&
75 test_path_is_missing file1 &&
76 test_cmp expected file2 &&
78 test_path_is_file file2.rej &&
79 test_path_is_missing file1.rej
83 test_expect_success 'the same test with --verbose' '
85 cat saved.file1 >file1 &&
86 rm -f file1.rej file2.rej file2 &&
88 test_must_fail git apply --reject --verbose patch.2 >rejects &&
89 test_path_is_missing file1 &&
90 test_cmp expected file2 &&
92 test_path_is_file file2.rej &&
93 test_path_is_missing file1.rej
97 test_expect_success 'apply cleanly with --verbose' '
99 git cat-file -p HEAD:file1 >file1 &&
100 rm -f file?.rej file2 &&
102 git apply --verbose patch.1 &&
104 test_cmp file1 clean
107 test_done