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' '
35 modify "s/^d/z/" same_fn &&
38 modify "s/^e/y/" same_fn &&
40 cp same_fn same_fn2 &&
43 test_cmp same_fn same_fn2
46 test_expect_success 'apply same new filename after rename' '
49 modify "s/^d/z/" new_fn &&
51 git diff -M --cached > patch1 &&
52 modify "s/^e/y/" new_fn &&
56 git apply --index patch1 &&
57 test_cmp new_fn new_fn2
60 test_expect_success 'apply same old filename after rename -- should fail.' '
63 modify "s/^d/z/" new_fn &&
65 git diff -M --cached > patch1 &&
67 modify "s/^e/y/" same_fn &&
70 test_must_fail git apply patch1
73 test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
76 modify "s/^d/z/" new_fn &&
78 git diff -M --cached > patch1 &&
79 git commit -m "a rename" &&
80 git mv other_fn same_fn
81 modify "s/^e/y/" same_fn &&
83 git diff -M --cached >> patch1 &&
84 modify "s/^g/x/" same_fn &&
86 git reset --hard HEAD^ &&