git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 3-way merge with file move fails when diff.renames = copies
@ 2008-11-10 22:26 David D. Kilzer
  2008-11-10 23:41 ` Johannes Schindelin
  2008-11-10 23:49 ` [PATCH] 3-way merge with file move fails " Junio C Hamano
  0 siblings, 2 replies; 22+ messages in thread
From: David D. Kilzer @ 2008-11-10 22:26 UTC (permalink / raw)
  To: git; +Cc: David D. Kilzer, Johannes Schindelin, gitster

With diff.renames = copies, a 3-way merge (e.g. "git rebase") would
fail with the following error:

    fatal: mode change for <file>, which is not in current HEAD
    Repository lacks necessary blobs to fall back on 3-way merge.
    Cannot fall back to three-way merge.
    Patch failed at 0001.

The bug is a logic error added in ece7b749, which attempts to find
an sha1 for a patch with no index line in build_fake_ancestor().
Instead of failing unless an sha1 is found for both the old file and
the new file, a failure should only be reported if neither the old
file nor the new file is found.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
---
 builtin-apply.c   |    2 +-
 t/t3400-rebase.sh |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index 4c4d1e1..cfeb6cc 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2573,7 +2573,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
 		else if (get_sha1(patch->old_sha1_prefix, sha1))
 			/* git diff has no index line for mode/type changes */
 			if (!patch->lines_added && !patch->lines_deleted) {
-				if (get_current_sha1(patch->new_name, sha1) ||
+				if (get_current_sha1(patch->new_name, sha1) &&
 				    get_current_sha1(patch->old_name, sha1))
 					die("mode change for %s, which is not "
 						"in current HEAD", name);
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index b7a670e..a156850 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -84,4 +84,21 @@ test_expect_success 'rebase a single mode change' '
      GIT_TRACE=1 git rebase master
 '
 
+test_expect_success 'rebase a single file move with diff.renames = copies' '
+     git config diff.renames copies &&
+     git checkout master &&
+     echo 1 > Y &&
+     git add Y &&
+     test_tick &&
+     git commit -m "prepare file move" &&
+     git checkout -b filemove HEAD^ &&
+     echo 1 > Y &&
+     git add Y &&
+     mkdir D &&
+     git mv A D/A &&
+     test_tick &&
+     git commit -m filemove &&
+     GIT_TRACE=1 git rebase master
+'
+
 test_done
-- 
1.6.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-07-24 22:00 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-10 22:26 [PATCH] 3-way merge with file move fails when diff.renames = copies David D. Kilzer
2008-11-10 23:41 ` Johannes Schindelin
2008-11-10 23:53   ` [PATCH] Fix 3-way merge with file move " David D. Kilzer
2008-11-10 23:49 ` [PATCH] 3-way merge with file move fails " Junio C Hamano
2008-11-11  0:06   ` David D. Kilzer
2008-11-11  0:15   ` Junio C Hamano
2010-07-21 19:58     ` [PATCH] Fix rebase with file move " David D. Kilzer
2010-07-21 21:54       ` Junio C Hamano
2010-07-22  0:22         ` David D. Kilzer
2010-07-22  7:51       ` Jonathan Nieder
2010-07-22 21:59         ` David D. Kilzer
2010-07-23 17:01           ` [PATCH 0/5] " Jonathan Nieder
2010-07-23 17:03             ` [PATCH 1/5] t4150 (am): style tweaks Jonathan Nieder
2010-07-23 17:04             ` [PATCH 2/5] t4150 (am): futureproof against failing tests Jonathan Nieder
2010-07-23 17:04             ` [PATCH 3/5] Teach "apply --index-info" to handle rename patches Jonathan Nieder
2010-07-23 17:05             ` [PATCH 4/5] t3400 (rebase): whitespace cleanup Jonathan Nieder
2010-07-23 17:06             ` [PATCH 5/5] rebase: protect against diff.renames configuration Jonathan Nieder
2010-07-23 19:51               ` Sverre Rabbelier
2010-07-23 21:03                 ` Junio C Hamano
2010-07-23 19:53               ` Sverre Rabbelier
2010-07-23 18:47             ` [PATCH 0/5] Fix rebase with file move when diff.renames = copies David D. Kilzer
2010-07-24 21:59               ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).