[PATCH] fix for incorrect index update

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] fix for incorrect index update

From: Dave O <hidden>
Date: 2016-06-15 22:46:44

call_depth > 0 requires trees to be constructed from the files with
conflicts, therefore the stages thusly must not be updated

Signed-off-by: Dave Olszewski <redacted>
---
  merge-recursive.c          |   11 +++--
  t/t3031-merge-criscross.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 101 insertions(+), 5 deletions(-)
  create mode 100644 t/t3031-merge-criscross.sh
diff --git a/merge-recursive.c b/merge-recursive.c
index a3721ef..f5df9b9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -933,11 +933,12 @@ static int process_renames(struct merge_options *o,
  				       ren1_src, ren1_dst, branch1,
  				       branch2);
  				update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
-				update_stages(ren1_dst, NULL,
-						branch1 == o->branch1 ?
-						ren1->pair->two : NULL,
-						branch1 == o->branch1 ?
-						NULL : ren1->pair->two, 1);
+				if (!o->call_depth)
+					update_stages(ren1_dst, NULL,
+							branch1 == o->branch1 ?
+							ren1->pair->two : NULL,
+							branch1 == o->branch1 ?
+							NULL : ren1->pair->two, 1);
  			} else if (!sha_eq(dst_other.sha1, null_sha1)) {
  				const char *new_path;
  				clean_merge = 0;
diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh
new file mode 100644
index 0000000..cbfd95b
--- /dev/null
+++ b/t/t3031-merge-criscross.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='merge-recursive backend test'
+
+. ./test-lib.sh
+
+#         A      <- create some files
+#        / \
+#       B   C    <- cause rename/delete conflicts between B and C
+#      /     \
+#     |\     /|
+#     | D   E |
+#     |  \ /  |
+#     |   X   |
+#     |  / \  |
+#     | /   \ |
+#     |/     \|
+#     F       G  <- merge E into B, D into C
+#      \     /
+#       \   /
+#        \ /
+#         H      <- recursive merge crashes
+#
+
+# initialize
+test_expect_success 'setup repo with criss-cross history' '
+	mkdir data &&
+
+	test_debug create a bunch of files &&
+	n=1 &&
+	while test $n -le 10
+	do
+		echo $n > data/$n &&
+		n=$(($n+1)) ||
+		break
+	done &&
+
+	test_debug check them in &&
+	git add data &&
+	git commit -m A &&
+	git branch A &&
+
+	test_debug a file in one branch &&
+	git checkout -b B A &&
+	git rm data/9 &&
+	git add data &&
+	git commit -m B &&
+
+	test_debug with a branch off of it &&
+	git branch D &&
+
+	test_debug put some commits on D &&
+	git checkout D &&
+	echo testD > data/testD &&
+	git add data &&
+	git commit -m D &&
+
+	test_debug back up to the top, create another branch and cause a rename  &&
+	test_debug conflict with the file we deleted earlier &&
+	git checkout -b C A &&
+	git mv data/9 data/new-9 &&
+	git add data &&
+	git commit -m C &&
+
+	test_debug with a branch off of it &&
+	git branch E &&
+
+	test_debug put a commit on E &&
+	git checkout E &&
+	echo testE > data/testE &&
+	git add data &&
+	git commit -m E &&
+
+	test_debug now, merge E into B &&
+	git checkout B &&
+	test_must_fail git merge E &&
+	test_debug force-resolve &&
+	git add data &&
+	git commit -m F &&
+	git branch F &&
+
+	test_debug and merge D into C &&
+	git checkout C &&
+	test_must_fail git merge D &&
+	test_debug force-resolve &&
+	git add data &&
+	git commit -m G &&
+	git branch G
+'
+
+test_expect_failure 'recursive merge between F and G, causes segfault' '
+	git merge F
+'
+
+test_done
-- 
1.6.2.4

Re: [PATCH] fix for incorrect index update

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:44

Dave O [off-list ref] writes:
call_depth > 0 requires trees to be constructed from the files with
conflicts, therefore the stages thusly must not be updated

Signed-off-by: Dave Olszewski <redacted>
---
Thanks.  I'd add:

	From: Dave Olszewski [off-list ref]

at the beginning, so you would not be shown as "Dave O" in "git shortlog"
and friends.
 merge-recursive.c          |   11 +++--
 t/t3031-merge-criscross.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+), 5 deletions(-)
 create mode 100644 t/t3031-merge-criscross.sh
quoted hunk
diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh
new file mode 100644
That should have been 100755 (I'll fix-up myself; no need to resend).
quoted hunk
index 0000000..cbfd95b
--- /dev/null
+++ b/t/t3031-merge-criscross.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='merge-recursive backend test'
+
+. ./test-lib.sh
+
+#         A      <- create some files
+#        / \
+#       B   C    <- cause rename/delete conflicts between B and C
+#      /     \
+#     |\     /|
+#     | D   E |
+#     |  \ /  |
+#     |   X   |
+#     |  / \  |
+#     | /   \ |
+#     |/     \|
+#     F       G  <- merge E into B, D into C
+#      \     /
+#       \   /
+#        \ /
+#         H      <- recursive merge crashes
+#
Much nicer than Dscho's ;-)
+# initialize
+test_expect_success 'setup repo with criss-cross history' '
+	mkdir data &&
+
+	test_debug create a bunch of files &&
You inherited a bug from Dscho's patch, it seems.  Have you tried running
the test with debug option?

This could have been

	test_debug "echo create a bunch of files" &&

but I'd say we just make them into comments.

Re: [PATCH] fix for incorrect index update

From: Dave Olszewski <hidden>
Date: 2016-06-15 22:46:44

On Sat, 9 May 2009, Junio C Hamano wrote:
Thanks.  I'd add:

	From: Dave Olszewski [off-list ref]

at the beginning, so you would not be shown as "Dave O" in "git shortlog"
and friends.
Ok, sounds good.  Thanks for the explanation of the issue.  Much of the
git internals are still mysterious but that's slowly changing :-)
Much nicer than Dscho's ;-)
Well, it was mine first, can't fault him for that!
You inherited a bug from Dscho's patch, it seems.  Have you tried running
the test with debug option?

This could have been

	test_debug "echo create a bunch of files" &&

but I'd say we just make them into comments.
I didn't, sorry for that.  Making them comments seems ok to me.

Thanks once again.

     Dave Olszewski
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help