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

[PATCH/RFC] ll-merge: use a longer conflict marker for internal merge

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 14, 2016, 22:57 UTC
Message-ID
<xmqqy48fer2s.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqbn5bg7r4.fsf@gitster.mtv.corp.google.com>

The primary use of conflict markers is to help the user who resolves the final (outer) merge by hand to show which part came from which branch by separating the blocks of lines apart. When the conflicted parts from a "virtual ancestor" merge created by merge-recursive remains in the common ancestor part in the final result, however, the conflict markers that are the same size as the final merge become harder to see.

Increase the conflict marker size slightly for these inner merges so that the markers from the final merge and cruft from internal merge can be distinguished more easily.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This would help reduce the common issue that prevents "rerere"
   from being used on a really complex conflict.  I have another
   (arguably riskier) patch that teaches rerere's parser to ignore
   "<<<" and ">>>" markers that says "Temporary merge branch " at
   the end of the line that achives a similar effect, but I think
   this may be a cleaner solution, partly because it also deals with
   "===" and "|||" lines that do not have such a clue to help
   rerere's parser.
 ll-merge.c                        | 8 ++++++--
 t/t6024-recursive-merge.sh        | 2 +-
 t/t6036-recursive-corner-cases.sh | 3 ++-
 3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ll-merge.c b/ll-merge.c
index 5c73274..e5ff7f6 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -376,8 +376,12 @@ int ll_merge(mmbuffer_t *result_buf,
 		}
 	}
 	driver = find_ll_merge_driver(ll_driver_name);
-	if (opts->virtual_ancestor && driver->recursive)
-		driver = find_ll_merge_driver(driver->recursive);
+
+	if (opts->virtual_ancestor) {
+		if (driver->recursive)
+			driver = find_ll_merge_driver(driver->recursive);
+		marker_size += 2;
+	}
 	return driver->fn(driver, result_buf, path, ancestor, ancestor_label,
 			  ours, our_label, theirs, their_label,
 			  opts, marker_size);
diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index 755d30c..3f59e58 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -76,7 +76,7 @@ test_expect_success "result contains a conflict" "test_cmp expect a1"
 
 git ls-files --stage > out
 cat > expect << EOF
-100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1	a1
+100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1	a1
 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2	a1
 100644 fd7923529855d0b274795ae3349c5e0438333979 3	a1
 EOF
diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh
index a86087b..cc1ee6a 100755
--- a/t/t6036-recursive-corner-cases.sh
+++ b/t/t6036-recursive-corner-cases.sh
@@ -217,7 +217,8 @@ test_expect_success 'git detects differently handled merges conflict' '
 		-L "" \
 		-L "Temporary merge branch 1" \
 		merged empty merge-me &&
-	test $(git rev-parse :1:new_a) = $(git hash-object merged)
+	sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
+	test $(git rev-parse :1:new_a) = $(git hash-object merged-internal)
 '
 
 #
-- 
2.8.1-367-g5b624f2
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “ll-merge: fix typo in comment”
  1. ll-merge: fix typo in commentJunio C Hamano, Apr 14, 2016
  2. ll-merge: use a longer conflict marker for internal mergeJunio C Hamano, Apr 14, 2016
  3. Junio C HamanoApr 14, 2016

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.