summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-11-10 23:49:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-23 21:44:38 (GMT)
commit18cdf802ca6e2772b5901f786f59de3843299b1c (patch)
treefbfb9bbf456c2c9a5280c4522dac85fd4c56e9d6 /t
parent5d274859444260142a77b844ab616f07bf80aaa5 (diff)
downloadgit-18cdf802ca6e2772b5901f786f59de3843299b1c.zip
git-18cdf802ca6e2772b5901f786f59de3843299b1c.tar.gz
git-18cdf802ca6e2772b5901f786f59de3843299b1c.tar.bz2
Teach "apply --index-info" to handle rename patches
With v1.5.3.2~14 (apply --index-info: fall back to current index for mode changes, 2007-09-17), git apply learned to stop worrying about the lack of diff index line when a file already present in the current index had no content change. But it still worries too much: for rename patches, it is checking that both the old and new filename are present in the current index. This makes no sense, since a file rename generally involves creating a file there was none before. So just check the old filename. Noticed while trying to use “git rebase” with diff.renames = copies. [jn: add tests] Reported-by: David D. Kilzer <ddkilzer@kilzer.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4150-am.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 70b57de..1c3d8ed 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -116,6 +116,18 @@ test_expect_success setup '
git commit -m "added another file" &&
git format-patch --stdout master >lorem-move.patch &&
+
+ git checkout -b rename &&
+ git mv file renamed &&
+ git commit -m "renamed a file" &&
+
+ git format-patch -M --stdout lorem >rename.patch &&
+
+ git reset --soft lorem^ &&
+ git commit -m "renamed a file and added another" &&
+
+ git format-patch -M --stdout lorem^ >rename-add.patch &&
+
# reset time
unset test_tick &&
test_tick
@@ -246,8 +258,42 @@ test_expect_success 'am -3 falls back to 3-way merge' '
git diff --exit-code lorem
'
+test_expect_success 'am can rename a file' '
+ grep "^rename from" rename.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am rename.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
+'
+
+test_expect_success 'am -3 can rename a file' '
+ grep "^rename from" rename.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am -3 rename.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
+'
+
+test_expect_success 'am -3 can rename a file after falling back to 3-way merge' '
+ grep "^rename from" rename-add.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am -3 rename-add.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
+'
+
test_expect_success 'am -3 -q is quiet' '
rm -fr .git/rebase-apply &&
+ git checkout -f lorem2 &&
git reset master2 --hard &&
sed -n -e "3,\$p" msg >file &&
head -n 9 msg >>file &&