git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/3] read-tree: loosen too strict index requirements
@ 2005-06-11  9:53 Junio C Hamano
  2005-06-12  3:55 ` [PATCH] Fix rename/copy when dealing with temporarily broken pairs Junio C Hamano
  2005-06-12  3:57 ` [PATCH] Add --diff-filter= output restriction to diff-* family Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2005-06-11  9:53 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

This patch teaches read-tree 3-way merge that, when only "the
other tree" changed a path, and if the index file already has
the same change, we are not in a situation that would clobber
the index and the work tree, and lets the merge succeed; this is
case #14ALT in t1000 test.  It does not change the result of the
merge, but prevents it from failing when it does not have to.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

*** This is another leftover bits from the earlier 3-piece series.
*** This is not necessary for the --emu23 two-way improvements,
*** but rather help a case that would not be so uncommon in the
*** 3-way merge case.

 read-tree.c                 |    6 ++++++
 t/t1000-read-tree-m-3way.sh |    9 +++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/read-tree.c b/read-tree.c
--- a/read-tree.c
+++ b/read-tree.c
@@ -280,6 +280,12 @@ static int threeway_merge(struct cache_e
 		}
 		/* otherwise we will apply the original rule */
 	}
+	/* #14ALT */
+	if (a && b && c && same(a, b) && !same(a, c)) {
+		if (old && same(old, c))
+			return merged_entry_allow_dirty(c, old, dst);
+		/* otherwise the regular rule applies */
+	}
 	/*
 	 * If we have an entry in the index cache ("old"), then we want
 	 * to make sure that it matches any entries in stage 2 ("first
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -464,6 +464,15 @@ test_expect_success \
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
+test_expect_success \
+    '14 - may match B in O && A && B && O==A && O!=B case' \
+    "rm -f .git/index NM &&
+     cp .orig-B/NM NM &&
+     git-update-cache --add NM &&
+     echo extra >>NM &&
+     git-read-tree -m $tree_O $tree_A $tree_B &&
+     check_result"
+
 test_expect_failure \
     '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
------------


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

end of thread, other threads:[~2005-06-13 23:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-11  9:53 [PATCH 5/3] read-tree: loosen too strict index requirements Junio C Hamano
2005-06-12  3:55 ` [PATCH] Fix rename/copy when dealing with temporarily broken pairs Junio C Hamano
2005-06-13 16:24   ` Jon Seymour
2005-06-13 17:58     ` Petr Baudis
2005-06-13 21:01     ` Junio C Hamano
2005-06-13 22:17       ` Jon Seymour
2005-06-12  3:57 ` [PATCH] Add --diff-filter= output restriction to diff-* family Junio C Hamano

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).