revision: fix leaking parents when simplifying commits
[git/gitster.git] / t / t4117-apply-reject.sh
blob4d15ccd28ecb27b47041cbaab412f1f1b93a91bf
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git apply with rejects
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
13 test_expect_success setup '
14 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 &&
15 cat file1 >saved.file1 &&
16 git update-index --add file1 &&
17 git commit -m initial &&
19 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 &&
20 git diff >patch.1 &&
21 cat file1 >clean &&
23 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 &&
25 mv file1 file2 &&
26 git update-index --add --remove file1 file2 &&
27 git diff -M HEAD >patch.2 &&
29 rm -f file1 file2 &&
30 mv saved.file1 file1 &&
31 git update-index --add --remove file1 file2 &&
33 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 &&
35 cat file1 >saved.file1
38 test_expect_success 'apply --reject is incompatible with --3way' '
39 test_when_finished "cat saved.file1 >file1" &&
40 git diff >patch.0 &&
41 git checkout file1 &&
42 test_must_fail git apply --reject --3way patch.0 &&
43 git diff --exit-code
46 test_expect_success 'apply without --reject should fail' '
48 test_must_fail git apply patch.1 &&
49 test_cmp file1 saved.file1
52 test_expect_success 'apply without --reject should fail' '
54 test_must_fail git apply --verbose patch.1 &&
55 test_cmp file1 saved.file1
58 test_expect_success 'apply with --reject should fail but update the file' '
60 cat saved.file1 >file1 &&
61 rm -f file1.rej file2.rej &&
63 test_must_fail git apply --reject patch.1 &&
64 test_cmp expected file1 &&
66 test_path_is_file file1.rej &&
67 test_path_is_missing file2.rej
70 test_expect_success 'apply with --reject should fail but update the file' '
72 cat saved.file1 >file1 &&
73 rm -f file1.rej file2.rej file2 &&
75 test_must_fail git apply --reject patch.2 >rejects &&
76 test_path_is_missing file1 &&
77 test_cmp expected file2 &&
79 test_path_is_file file2.rej &&
80 test_path_is_missing file1.rej
84 test_expect_success 'the same test with --verbose' '
86 cat saved.file1 >file1 &&
87 rm -f file1.rej file2.rej file2 &&
89 test_must_fail git apply --reject --verbose patch.2 >rejects &&
90 test_path_is_missing file1 &&
91 test_cmp expected file2 &&
93 test_path_is_file file2.rej &&
94 test_path_is_missing file1.rej
98 test_expect_success 'apply cleanly with --verbose' '
100 git cat-file -p HEAD:file1 >file1 &&
101 rm -f file?.rej file2 &&
103 git apply --verbose patch.1 &&
105 test_cmp file1 clean
108 test_done