aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-07-01 16:22:10 -0700
committerJunio C Hamano <gitster@pobox.com>2008-07-01 16:22:10 -0700
commit7ebd52aa0e58df6bac5f0f87a591da17eb3324a6 (patch)
tree72cb53f7847114674455d1d8d672e56591d09420 /t
parenta08ca90938cf88c138edfd9f747d44ef1acf0c05 (diff)
parent7a07841c0ba8d791dd4c7363eaf004b4a7d11fb6 (diff)
downloadgit-7ebd52aa0e58df6bac5f0f87a591da17eb3324a6.tar.gz
git-7ebd52aa0e58df6bac5f0f87a591da17eb3324a6.tar.xz
Merge branch 'dz/apply-again'
* dz/apply-again: git-apply: handle a patch that touches the same path more than once better
Diffstat (limited to 't')
-rwxr-xr-xt/t4127-apply-same-fn.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh
new file mode 100755
index 000000000..2a6ed77c6
--- /dev/null
+++ b/t/t4127-apply-same-fn.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+test_description='apply same filename'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ for i in a b c d e f g h i j k l m
+ do
+ echo $i
+ done >same_fn &&
+ cp same_fn other_fn &&
+ git add same_fn other_fn &&
+ git commit -m initial
+'
+test_expect_success 'apply same filename with independent changes' '
+ sed -i -e "s/^d/z/" same_fn &&
+ git diff > patch0 &&
+ git add same_fn &&
+ sed -i -e "s/^i/y/" same_fn &&
+ git diff >> patch0 &&
+ cp same_fn same_fn2 &&
+ git reset --hard &&
+ git-apply patch0 &&
+ diff same_fn same_fn2
+'
+
+test_expect_success 'apply same filename with overlapping changes' '
+ git reset --hard
+ sed -i -e "s/^d/z/" same_fn &&
+ git diff > patch0 &&
+ git add same_fn &&
+ sed -i -e "s/^e/y/" same_fn &&
+ git diff >> patch0 &&
+ cp same_fn same_fn2 &&
+ git reset --hard &&
+ git-apply patch0 &&
+ diff same_fn same_fn2
+'
+
+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 &&
+ git add new_fn &&
+ git diff -M --cached > patch1 &&
+ sed -i -e "s/^e/y/" new_fn &&
+ git diff >> patch1 &&
+ cp new_fn new_fn2 &&
+ git reset --hard &&
+ git apply --index patch1 &&
+ diff new_fn new_fn2
+'
+
+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 &&
+ git add new_fn &&
+ git diff -M --cached > patch1 &&
+ git mv new_fn same_fn
+ sed -i -e "s/^e/y/" same_fn &&
+ git diff >> patch1 &&
+ git reset --hard &&
+ test_must_fail git apply patch1
+'
+
+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 &&
+ 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 &&
+ git add same_fn &&
+ git diff -M --cached >> patch1 &&
+ sed -i -e "s/^g/x/" same_fn &&
+ git diff >> patch1 &&
+ git reset --hard HEAD^ &&
+ git apply patch1
+'
+
+test_done