]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4117-apply-reject.sh
The third batch
[thirdparty/git.git] / t / t4117-apply-reject.sh
CommitLineData
57dc397c
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
5be60078 6test_description='git apply with rejects
57dc397c
JH
7
8'
9
71c79160 10TEST_PASSES_SANITIZE_LEAK=true
57dc397c
JH
11. ./test-lib.sh
12
13test_expect_success setup '
08495412 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 &&
57dc397c
JH
15 cat file1 >saved.file1 &&
16 git update-index --add file1 &&
17 git commit -m initial &&
18
08495412 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 &&
57dc397c 20 git diff >patch.1 &&
82e2765f
JH
21 cat file1 >clean &&
22
08495412 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 &&
57dc397c
JH
24
25 mv file1 file2 &&
26 git update-index --add --remove file1 file2 &&
27 git diff -M HEAD >patch.2 &&
28
29 rm -f file1 file2 &&
30 mv saved.file1 file1 &&
31 git update-index --add --remove file1 file2 &&
32
08495412 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 &&
57dc397c
JH
34
35 cat file1 >saved.file1
36'
37
cfb6f9ac
JH
38test_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
44'
45
57dc397c
JH
46test_expect_success 'apply without --reject should fail' '
47
e7d053dd 48 test_must_fail git apply patch.1 &&
3af82863 49 test_cmp file1 saved.file1
57dc397c
JH
50'
51
a2bf404e
JH
52test_expect_success 'apply without --reject should fail' '
53
e7d053dd 54 test_must_fail git apply --verbose patch.1 &&
3af82863 55 test_cmp file1 saved.file1
a2bf404e
JH
56'
57
57dc397c
JH
58test_expect_success 'apply with --reject should fail but update the file' '
59
82e2765f
JH
60 cat saved.file1 >file1 &&
61 rm -f file1.rej file2.rej &&
57dc397c 62
e7d053dd 63 test_must_fail git apply --reject patch.1 &&
dcbaa0b3 64 test_cmp expected file1 &&
82e2765f 65
91de82ad 66 test_path_is_file file1.rej &&
e7d053dd 67 test_path_is_missing file2.rej
57dc397c
JH
68'
69
70test_expect_success 'apply with --reject should fail but update the file' '
71
82e2765f
JH
72 cat saved.file1 >file1 &&
73 rm -f file1.rej file2.rej file2 &&
57dc397c 74
e7d053dd
JK
75 test_must_fail git apply --reject patch.2 >rejects &&
76 test_path_is_missing file1 &&
dcbaa0b3 77 test_cmp expected file2 &&
82e2765f 78
91de82ad 79 test_path_is_file file2.rej &&
e7d053dd 80 test_path_is_missing file1.rej
82e2765f 81
57dc397c
JH
82'
83
a2bf404e
JH
84test_expect_success 'the same test with --verbose' '
85
86 cat saved.file1 >file1 &&
87 rm -f file1.rej file2.rej file2 &&
88
e7d053dd
JK
89 test_must_fail git apply --reject --verbose patch.2 >rejects &&
90 test_path_is_missing file1 &&
dcbaa0b3 91 test_cmp expected file2 &&
a2bf404e 92
91de82ad 93 test_path_is_file file2.rej &&
e7d053dd 94 test_path_is_missing file1.rej
a2bf404e
JH
95
96'
97
98test_expect_success 'apply cleanly with --verbose' '
99
100 git cat-file -p HEAD:file1 >file1 &&
101 rm -f file?.rej file2 &&
102
103 git apply --verbose patch.1 &&
104
3af82863 105 test_cmp file1 clean
a2bf404e
JH
106'
107
57dc397c 108test_done