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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 14, 2016, 23:02 UTC
Message-ID
<xmqqtwj3equx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqy48fer2s.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> 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.
Just for comparison, this is the other "riskier" approach.
-- >8 --
Subject: [PATCH] rerere: try ignoring extra cruft left by merge-recursive

Sometimes the conflict markers from the virtual ancestor synthesis done by merge-recursive can seep out to the conflicted area of the final (incomplete) merge result. Detect and reject them by noticing the "Temporary merge branch 1" (or "2") branch names.

This is an incomplete solution for "rerere sometimes cannot parse the conflicted parts" problem, because there is no such helpful clue on "|||||" (seen only when using "diff3" style) and "=====" lines.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 rerere.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/rerere.c b/rerere.c
index 1693866..02cbc24 100644
--- a/rerere.c
+++ b/rerere.c
@@ -359,6 +359,18 @@ static int rerere_file_getline(struct strbuf *sb, struct rerere_io *io_)
 	return strbuf_getwholeline(sb, io->input, '\n');
 }
 
+static int is_temporary_branch_mark(char *buf)
+{
+	const char *name;
+
+	if (!skip_prefix(buf, " Temporary merge branch ", &name))
+		return 0;
+	if (*name != '1' && *name != '2')
+		return 0;
+	name++;
+	return (!*name || (*name == '\n'));
+}
+
 /*
  * Require the exact number of conflict marker letters, no more, no
  * less, followed by SP or any whitespace
@@ -381,7 +393,7 @@ static int is_cmarker(char *buf, int marker_char, int marker_size)
 	while (marker_size--)
 		if (*buf++ != marker_char)
 			return 0;
-	if (want_sp && *buf != ' ')
+	if (want_sp && (*buf != ' ' || is_temporary_branch_mark(buf)))
 		return 0;
 	return isspace(*buf);
 }
-- 
2.8.1-367-g5b624f2
Previous: Junio C Hamano
Message 3 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.