Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Re: [PATCH/RFC] ll-merge: use a longer conflict marker for internal merge
Date: Thu, 14 Apr 2016 16:02:30 -0700	[thread overview]
Message-ID: <xmqqtwj3equx.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqy48fer2s.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Thu, 14 Apr 2016 15:57:47 -0700")

Junio C Hamano <gitster@pobox.com> 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@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

      reply	other threads:[~2016-04-14 23:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 22:12 [PATCH] ll-merge: fix typo in comment Junio C Hamano
2016-04-14 22:57 ` [PATCH/RFC] ll-merge: use a longer conflict marker for internal merge Junio C Hamano
2016-04-14 23:02   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqtwj3equx.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox