threads / patch / 42032

patchll-merge: fix typo in comment

Subject: [PATCH] ll-merge: fix typo in comment

## tl;dr

3 messages between Apr 14, 2016 and Apr 14, 2016. Diffs are folded; open one to read it.

replies: 2people: 1as markdown or json

Junio C Hamano· Apr 14, 2016, 22:12 UTC · lore

When a944af1d (merge: teach -Xours/-Xtheirs to binary ll-merge driver, 2012-09-08) introduced FAVOR_OURS/FAVOR_THEIRS to the binary ll-merge driver, it changed what happens to the merge result for the outer merge, and updated the comment from:

    The tentative merge result is "ours" for the final round, or
    common ancestor for an internal merge.  Still return "conflicted
    merge" status.
to
    The tentative merge result is the or common ancestor for an
    internal merge.

What happened is obvious. I noticed the lack of definitive article in front of "common" but failed to remove "or". Also I forgot to describe what I did for the final merge, probably because I was satisified by the description in the log message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 ll-merge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Show changes to ll-merge.c +3 −1
diff --git a/ll-merge.c b/ll-merge.c
index ff4a43a..fe22412 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -47,7 +47,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
 	assert(opts);
 
 	/*
-	 * The tentative merge result is the or common ancestor for an internal merge.
+	 * The tentative merge result is the common ancestor for an
+	 * internal merge.  For the final merge, it is "ours" by
+	 * default but -Xours/-Xtheirs can tweak the choice.
 	 */
 	if (opts->virtual_ancestor) {
 		stolen = orig;
Junio C Hamano· Apr 14, 2016, 22:57 UTC · re: Junio C Hamano · lore

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

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(-)
Show changes to 3 files +9 −4

ll-merge.c, t/t6024-recursive-merge.sh, t/t6036-recursive-corner-cases.sh

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
Junio C Hamano· Apr 14, 2016, 23:02 UTC · re: Junio C Hamano · lore

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

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(-)
Show changes to rerere.c +13 −1
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

← back to recent threads