3 test_description='apply same filename'
8 sed -e "$1" < "$2" > "$2".x &&
12 test_expect_success setup '
13 for i in a b c d e f g h i j k l m
17 cp same_fn other_fn &&
18 git add same_fn other_fn &&
21 test_expect_success 'apply same filename with independent changes' '
22 modify "s/^d/z/" same_fn &&
25 modify "s/^i/y/" same_fn &&
27 cp same_fn same_fn2 &&
30 test_cmp same_fn same_fn2
33 test_expect_success 'apply same filename with overlapping changes' '
36 # Store same_fn so that we can check apply -R in next test
37 cp same_fn same_fn1 &&
39 modify "s/^d/z/" same_fn &&
42 modify "s/^e/y/" same_fn &&
44 cp same_fn same_fn2 &&
47 test_cmp same_fn same_fn2
50 test_expect_success 'apply same filename with overlapping changes, in reverse' '
51 git apply -R patch0 &&
52 test_cmp same_fn same_fn1
55 test_expect_success 'apply same new filename after rename' '
57 git mv same_fn new_fn &&
58 modify "s/^d/z/" new_fn &&
60 git diff -M --cached > patch1 &&
61 modify "s/^e/y/" new_fn &&
65 git apply --index patch1 &&
66 test_cmp new_fn new_fn2
69 test_expect_success 'apply same old filename after rename -- should fail.' '
71 git mv same_fn new_fn &&
72 modify "s/^d/z/" new_fn &&
74 git diff -M --cached > patch1 &&
75 git mv new_fn same_fn &&
76 modify "s/^e/y/" same_fn &&
79 test_must_fail git apply patch1
82 test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
84 git mv same_fn new_fn &&
85 modify "s/^d/z/" new_fn &&
87 git diff -M --cached > patch1 &&
88 git commit -m "a rename" &&
89 git mv other_fn same_fn &&
90 modify "s/^e/y/" same_fn &&
92 git diff -M --cached >> patch1 &&
93 modify "s/^g/x/" same_fn &&
95 git reset --hard HEAD^ &&