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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> 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@xxxxxxxxx>
> ---
>  * 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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]