git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fix for incorrect index update

From
Dave O <cxreg@pobox.com>
Date
May 9, 2009, 21:49 UTC
Message-ID
<alpine.DEB.2.00.0905091356070.21000@narbuckle.genericorp.net>

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 <cxreg@pobox.com>
---
  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
Next: Junio C Hamano
Message 1 of 3 in “fix for incorrect index update”
  1. fix for incorrect index updateDave O, May 9, 2009
  2. Junio C HamanoMay 10, 2009
  3. Dave OlszewskiMay 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.