summaryrefslogtreecommitdiff
path: root/t/t4127-apply-same-fn.sh
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2008-07-04 08:43:19 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-04 01:36:25 -0700
commit41872fd573601b123da00294f77d7d4c25db6010 (patch)
tree6443cbb3465b92b1ce3e591d6bed50e75f406a4a /t/t4127-apply-same-fn.sh
parent6991357513bf8bfbb71a4675e271b386cc273476 (diff)
downloadgit-41872fd573601b123da00294f77d7d4c25db6010.tar.gz
t4127-apply-same-fn: Avoid sed -i
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4127-apply-same-fn.sh')
-rwxr-xr-xt/t4127-apply-same-fn.sh27
1 files changed, 16 insertions, 11 deletions
diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh
index 2a6ed77c65..1f859dd908 100755
--- a/t/t4127-apply-same-fn.sh
+++ b/t/t4127-apply-same-fn.sh
@@ -4,6 +4,11 @@ test_description='apply same filename'
. ./test-lib.sh
+modify () {
+ sed -e "$1" < "$2" > "$2".x &&
+ mv "$2".x "$2"
+}
+
test_expect_success setup '
for i in a b c d e f g h i j k l m
do
@@ -14,10 +19,10 @@ test_expect_success setup '
git commit -m initial
'
test_expect_success 'apply same filename with independent changes' '
- sed -i -e "s/^d/z/" same_fn &&
+ modify "s/^d/z/" same_fn &&
git diff > patch0 &&
git add same_fn &&
- sed -i -e "s/^i/y/" same_fn &&
+ modify "s/^i/y/" same_fn &&
git diff >> patch0 &&
cp same_fn same_fn2 &&
git reset --hard &&
@@ -27,10 +32,10 @@ test_expect_success 'apply same filename with independent changes' '
test_expect_success 'apply same filename with overlapping changes' '
git reset --hard
- sed -i -e "s/^d/z/" same_fn &&
+ modify "s/^d/z/" same_fn &&
git diff > patch0 &&
git add same_fn &&
- sed -i -e "s/^e/y/" same_fn &&
+ modify "s/^e/y/" same_fn &&
git diff >> patch0 &&
cp same_fn same_fn2 &&
git reset --hard &&
@@ -41,10 +46,10 @@ test_expect_success 'apply same filename with overlapping changes' '
test_expect_success 'apply same new filename after rename' '
git reset --hard
git mv same_fn new_fn
- sed -i -e "s/^d/z/" new_fn &&
+ modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
- sed -i -e "s/^e/y/" new_fn &&
+ modify "s/^e/y/" new_fn &&
git diff >> patch1 &&
cp new_fn new_fn2 &&
git reset --hard &&
@@ -55,11 +60,11 @@ test_expect_success 'apply same new filename after rename' '
test_expect_success 'apply same old filename after rename -- should fail.' '
git reset --hard
git mv same_fn new_fn
- sed -i -e "s/^d/z/" new_fn &&
+ modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
git mv new_fn same_fn
- sed -i -e "s/^e/y/" same_fn &&
+ modify "s/^e/y/" same_fn &&
git diff >> patch1 &&
git reset --hard &&
test_must_fail git apply patch1
@@ -68,15 +73,15 @@ test_expect_success 'apply same old filename after rename -- should fail.' '
test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
git reset --hard
git mv same_fn new_fn
- sed -i -e "s/^d/z/" new_fn &&
+ modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
git commit -m "a rename" &&
git mv other_fn same_fn
- sed -i -e "s/^e/y/" same_fn &&
+ modify "s/^e/y/" same_fn &&
git add same_fn &&
git diff -M --cached >> patch1 &&
- sed -i -e "s/^g/x/" same_fn &&
+ modify "s/^g/x/" same_fn &&
git diff >> patch1 &&
git reset --hard HEAD^ &&
git apply patch1