@@ -4,6 +4,11 @@ test_description='apply same filename'
44
55. ./test-lib.sh
66
7+ modify () {
8+ sed -e " $1 " < " $2 " > " $2 " .x &&
9+ mv " $2 " .x " $2 "
10+ }
11+
712test_expect_success setup '
813 for i in a b c d e f g h i j k l m
914 do
@@ -14,10 +19,10 @@ test_expect_success setup '
1419 git commit -m initial
1520'
1621test_expect_success ' apply same filename with independent changes' '
17- sed -i -e "s/^d/z/" same_fn &&
22+ modify "s/^d/z/" same_fn &&
1823 git diff > patch0 &&
1924 git add same_fn &&
20- sed -i -e "s/^i/y/" same_fn &&
25+ modify "s/^i/y/" same_fn &&
2126 git diff >> patch0 &&
2227 cp same_fn same_fn2 &&
2328 git reset --hard &&
@@ -27,10 +32,10 @@ test_expect_success 'apply same filename with independent changes' '
2732
2833test_expect_success ' apply same filename with overlapping changes' '
2934 git reset --hard
30- sed -i -e "s/^d/z/" same_fn &&
35+ modify "s/^d/z/" same_fn &&
3136 git diff > patch0 &&
3237 git add same_fn &&
33- sed -i -e "s/^e/y/" same_fn &&
38+ modify "s/^e/y/" same_fn &&
3439 git diff >> patch0 &&
3540 cp same_fn same_fn2 &&
3641 git reset --hard &&
@@ -41,10 +46,10 @@ test_expect_success 'apply same filename with overlapping changes' '
4146test_expect_success ' apply same new filename after rename' '
4247 git reset --hard
4348 git mv same_fn new_fn
44- sed -i -e "s/^d/z/" new_fn &&
49+ modify "s/^d/z/" new_fn &&
4550 git add new_fn &&
4651 git diff -M --cached > patch1 &&
47- sed -i -e "s/^e/y/" new_fn &&
52+ modify "s/^e/y/" new_fn &&
4853 git diff >> patch1 &&
4954 cp new_fn new_fn2 &&
5055 git reset --hard &&
@@ -55,11 +60,11 @@ test_expect_success 'apply same new filename after rename' '
5560test_expect_success ' apply same old filename after rename -- should fail.' '
5661 git reset --hard
5762 git mv same_fn new_fn
58- sed -i -e "s/^d/z/" new_fn &&
63+ modify "s/^d/z/" new_fn &&
5964 git add new_fn &&
6065 git diff -M --cached > patch1 &&
6166 git mv new_fn same_fn
62- sed -i -e "s/^e/y/" same_fn &&
67+ modify "s/^e/y/" same_fn &&
6368 git diff >> patch1 &&
6469 git reset --hard &&
6570 test_must_fail git apply patch1
@@ -68,15 +73,15 @@ test_expect_success 'apply same old filename after rename -- should fail.' '
6873test_expect_success ' apply A->B (rename), C->A (rename), A->A -- should pass.' '
6974 git reset --hard
7075 git mv same_fn new_fn
71- sed -i -e "s/^d/z/" new_fn &&
76+ modify "s/^d/z/" new_fn &&
7277 git add new_fn &&
7378 git diff -M --cached > patch1 &&
7479 git commit -m "a rename" &&
7580 git mv other_fn same_fn
76- sed -i -e "s/^e/y/" same_fn &&
81+ modify "s/^e/y/" same_fn &&
7782 git add same_fn &&
7883 git diff -M --cached >> patch1 &&
79- sed -i -e "s/^g/x/" same_fn &&
84+ modify "s/^g/x/" same_fn &&
8085 git diff >> patch1 &&
8186 git reset --hard HEAD^ &&
8287 git apply patch1
0 commit comments