3 test_description
='apply same filename'
6 TEST_PASSES_SANITIZE_LEAK
=true
10 sed -e "$1" < "$2" > "$2".x
&&
14 test_expect_success setup
'
15 test_write_lines a b c d e f g h i j k l m >same_fn &&
16 cp same_fn other_fn &&
17 git add same_fn other_fn &&
20 test_expect_success
'apply same filename with independent changes' '
21 modify "s/^d/z/" same_fn &&
24 modify "s/^i/y/" same_fn &&
26 cp same_fn same_fn2 &&
29 test_cmp same_fn same_fn2
32 test_expect_success
'apply same filename with overlapping changes' '
35 # Store same_fn so that we can check apply -R in next test
36 cp same_fn same_fn1 &&
38 modify "s/^d/z/" same_fn &&
41 modify "s/^e/y/" same_fn &&
43 cp same_fn same_fn2 &&
46 test_cmp same_fn same_fn2
49 test_expect_success
'apply same filename with overlapping changes, in reverse' '
50 git apply -R patch0 &&
51 test_cmp same_fn same_fn1
54 test_expect_success
'apply same new filename after rename' '
56 git mv same_fn new_fn &&
57 modify "s/^d/z/" new_fn &&
59 git diff -M --cached > patch1 &&
60 modify "s/^e/y/" new_fn &&
64 git apply --index patch1 &&
65 test_cmp new_fn new_fn2
68 test_expect_success
'apply same old filename after rename -- should fail.' '
70 git mv same_fn new_fn &&
71 modify "s/^d/z/" new_fn &&
73 git diff -M --cached > patch1 &&
74 git mv new_fn same_fn &&
75 modify "s/^e/y/" same_fn &&
78 test_must_fail git apply patch1
81 test_expect_success
'apply A->B (rename), C->A (rename), A->A -- should pass.' '
83 git mv same_fn new_fn &&
84 modify "s/^d/z/" new_fn &&
86 git diff -M --cached > patch1 &&
87 git commit -m "a rename" &&
88 git mv other_fn same_fn &&
89 modify "s/^e/y/" same_fn &&
91 git diff -M --cached >> patch1 &&
92 modify "s/^g/x/" same_fn &&
94 git reset --hard HEAD^ &&