git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] merge-tree: fix (merge-base a b) b a
@ 2010-07-10  0:53 Will Palmer
  2010-07-10  0:53 ` [PATCH 1/2] add basic tests for merge-tree Will Palmer
  2010-07-10  0:53 ` [PATCH 2/2] fix merge-tree where two branches share no changes Will Palmer
  0 siblings, 2 replies; 3+ messages in thread
From: Will Palmer @ 2010-07-10  0:53 UTC (permalink / raw
  To: git; +Cc: wmpalmer, gitster

This series notes, then fixes, a regression introduced by
15b4f7a68d8c3c8ee28424415b203f61202d65d1 /
	merge-tree: use ll_merge() not xdl_merge()

I don't know the proper terminology to describe what's being fixed here.
This seems to most-easily be triggered by (for example):
	git merge-tree $(git merge-base HEAD @{u}) HEAD @{u}

In the git repository at the moment, this could be triggered with:
	git merge-tree $(git merge-base origin/next origin/master) \
		origin/next origin/master

Though as I write this, next has only just been merged with master, so
that is not the case. For an example which is less likely to go away,
try:
	git merge-tree c9eaaab4165d8f402930d12899ec097495b599e6 \
		be16ac8cc8ce693c6adf37b80db65d10a41b4eb9 \
		9918285fb10d81af9021dae99c5f4de88ded497c

It's actually very trivial to reproduce this, to the point where I
can't help but wonder how much merge-tree is actually being used. As
I narrowed the test-case more and more, I was surprised by how little
it took to trigger it. The first patch in this series includes some
very basic tests for merge-tree, the last of which demonstrates the
regression.

The second patch implements the trivial fix for it.

Will Palmer (2):
  add basic tests for merge-tree
  fix merge-tree where two branches share no changes

 builtin/merge-tree.c  |    3 ++-
 t/t4300-merge-tree.sh |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletions(-)
 create mode 100755 t/t4300-merge-tree.sh

-- 
1.7.1.703.g42c01

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

* [PATCH 1/2] add basic tests for merge-tree
  2010-07-10  0:53 [PATCH 0/2] merge-tree: fix (merge-base a b) b a Will Palmer
@ 2010-07-10  0:53 ` Will Palmer
  2010-07-10  0:53 ` [PATCH 2/2] fix merge-tree where two branches share no changes Will Palmer
  1 sibling, 0 replies; 3+ messages in thread
From: Will Palmer @ 2010-07-10  0:53 UTC (permalink / raw
  To: git; +Cc: wmpalmer, gitster

merge-tree had no test cases, so here we add some very basic tests for
it, including one known-breakage.

Signed-off-by: Will Palmer <wmpalmer@gmail.com>
---
 t/t4300-merge-tree.sh |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100755 t/t4300-merge-tree.sh

diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
new file mode 100755
index 0000000..afcb89d
--- /dev/null
+++ b/t/t4300-merge-tree.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Will Palmer
+#
+
+test_description='git merge-tree'
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit "initial"
+'
+
+test_expect_success 'both added same' '
+	git reset --hard initial
+	test_commit "same-A" "ONE" "AAA" 
+
+	git reset --hard initial
+	test_commit "same-B" "ONE" "AAA"
+
+	git merge-tree initial same-A same-B
+'
+
+test_expect_success 'both added conflict' '
+	git reset --hard initial
+	test_commit "diff-A" "ONE" "AAA" 
+
+	git reset --hard initial
+	test_commit "diff-B" "ONE" "BBB"
+
+	git merge-tree initial diff-A diff-B
+'
+
+test_expect_failure 'nothing similar' '
+	git reset --hard initial
+	test_commit "no-common-A" "ONE" "AAA" 
+
+	git reset --hard initial
+	test_commit "no-common-B" "TWO" "BBB"
+
+	git merge-tree initial no-common-A no-common-B
+'
+
+test_done
-- 
1.7.1.703.g42c01

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

* [PATCH 2/2] fix merge-tree where two branches share no changes
  2010-07-10  0:53 [PATCH 0/2] merge-tree: fix (merge-base a b) b a Will Palmer
  2010-07-10  0:53 ` [PATCH 1/2] add basic tests for merge-tree Will Palmer
@ 2010-07-10  0:53 ` Will Palmer
  1 sibling, 0 replies; 3+ messages in thread
From: Will Palmer @ 2010-07-10  0:53 UTC (permalink / raw
  To: git; +Cc: wmpalmer, gitster

Here we fix a regression which was introduced by
15b4f7a68d8c3c8ee28424415b203f61202d65d1 /
	merge-tree: use ll_merge() not xdl_merge()

Which caused merge-tree to segfault in particular combinations of
merging files which existed in one branch, but not in the other or in
the merge-base. This was caused by referencing entry->path at a time
when entry was known to be possibly-NULL.

To correct the problem, we save the path of the entry we came in with,
as the path should be the same among all the stages no matter which
sides are involved in the merge.

Signed-off-by: Will Palmer <wmpalmer@gmail.com>
---
 builtin/merge-tree.c  |    3 ++-
 t/t4300-merge-tree.sh |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index fc00d79..9b25ddc 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
 {
 	enum object_type type;
 	struct blob *base, *our, *their;
+	const char *path = entry->path;
 
 	if (!entry->stage)
 		return read_sha1_file(entry->blob->object.sha1, &type, size);
@@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
 	their = NULL;
 	if (entry)
 		their = entry->blob;
-	return merge_file(entry->path, base, our, their, size);
+	return merge_file(path, base, our, their, size);
 }
 
 static void *origin(struct merge_list *entry, unsigned long *size)
diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
index afcb89d..97a3deb 100755
--- a/t/t4300-merge-tree.sh
+++ b/t/t4300-merge-tree.sh
@@ -30,7 +30,7 @@ test_expect_success 'both added conflict' '
 	git merge-tree initial diff-A diff-B
 '
 
-test_expect_failure 'nothing similar' '
+test_expect_success 'nothing similar' '
 	git reset --hard initial
 	test_commit "no-common-A" "ONE" "AAA" 
 
-- 
1.7.1.703.g42c01

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

end of thread, other threads:[~2010-07-10  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-10  0:53 [PATCH 0/2] merge-tree: fix (merge-base a b) b a Will Palmer
2010-07-10  0:53 ` [PATCH 1/2] add basic tests for merge-tree Will Palmer
2010-07-10  0:53 ` [PATCH 2/2] fix merge-tree where two branches share no changes Will Palmer

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).