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 for i in a b c d e f g h i j k l m
19 cp same_fn other_fn &&
20 git add same_fn other_fn &&
23 test_expect_success
'apply same filename with independent changes' '
24 modify "s/^d/z/" same_fn &&
27 modify "s/^i/y/" same_fn &&
29 cp same_fn same_fn2 &&
32 test_cmp same_fn same_fn2
35 test_expect_success
'apply same filename with overlapping changes' '
38 # Store same_fn so that we can check apply -R in next test
39 cp same_fn same_fn1 &&
41 modify "s/^d/z/" same_fn &&
44 modify "s/^e/y/" same_fn &&
46 cp same_fn same_fn2 &&
49 test_cmp same_fn same_fn2
52 test_expect_success
'apply same filename with overlapping changes, in reverse' '
53 git apply -R patch0 &&
54 test_cmp same_fn same_fn1
57 test_expect_success
'apply same new filename after rename' '
59 git mv same_fn new_fn &&
60 modify "s/^d/z/" new_fn &&
62 git diff -M --cached > patch1 &&
63 modify "s/^e/y/" new_fn &&
67 git apply --index patch1 &&
68 test_cmp new_fn new_fn2
71 test_expect_success
'apply same old filename after rename -- should fail.' '
73 git mv same_fn new_fn &&
74 modify "s/^d/z/" new_fn &&
76 git diff -M --cached > patch1 &&
77 git mv new_fn same_fn &&
78 modify "s/^e/y/" same_fn &&
81 test_must_fail git apply patch1
84 test_expect_success
'apply A->B (rename), C->A (rename), A->A -- should pass.' '
86 git mv same_fn new_fn &&
87 modify "s/^d/z/" new_fn &&
89 git diff -M --cached > patch1 &&
90 git commit -m "a rename" &&
91 git mv other_fn same_fn &&
92 modify "s/^e/y/" same_fn &&
94 git diff -M --cached >> patch1 &&
95 modify "s/^g/x/" same_fn &&
97 git reset --hard HEAD^ &&