threads / patch / 45584

patchDocumentation: make 3-way merge warning more generic

Subject: [PATCH] Documentation: make 3-way merge warning more generic

## tl;dr

2 messages between Apr 1, 2017 and Apr 1, 2017. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

brian m. carlson· Apr 1, 2017, 13:31 UTC · lore

The documentation for merge strategies noted that if a change was reverted on only one branch of a merge, the resultant merge would contain the change. However, similar surprising behavior can occur where cherry-picking only one commit from a series to the other branch can cause conflicts.

Adjust the text to state in the first sentence that only the heads and the merge base are considered for three-way merge, instead of hiding this in the second sentence after introducing a scenario which might not apply to the user. This makes it easier for users to understand by first introducing the general rule (which applies to many scenarios), and only then providing a specific example.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---

I ran into this scenario with a co-worker who is a fairly advanced Git user. He created a series of five commits that modified a file on our development branch and requested the cherry-pick of one of those onto our maintenance branch. When we merged the maintenance branch into the development branch, he was surprised that there were conflicts. He expected Git to realize that the commit was already present and ignore it.

I pointed out the documentation to him, but realized that it didn't cover this case well, so I decided to reword it such that it covers this case a little better, as well as addressing the original issue.

Feedback on how I did in that regard would be welcome.
 Documentation/merge-strategies.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Show changes to Documentation/merge-strategies.txt +6 −6
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 2eb92b9327..54da2ffa33 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -123,9 +123,9 @@ subtree::
 	ancestor tree.
 
 With the strategies that use 3-way merge (including the default, 'recursive'),
-if a change is made on both branches, but later reverted on one of the
-branches, that change will be present in the merged result; some people find
-this behavior confusing.  It occurs because only the heads and the merge base
-are considered when performing a merge, not the individual commits.  The merge
-algorithm therefore considers the reverted change as no change at all, and
-substitutes the changed version instead.
+only the heads and the merge base are considered when performing a merge, not
+the individual commits.  This means that if a change is made on both branches,
+but later reverted on one of the branches, that change will be present in the
+merged result; some people find this behavior confusing.  The merge algorithm
+considers the reverted change as no change at all, and substitutes the changed
+version instead.
-- 
2.12.2.564.g063fe858b8
Junio C Hamano· Apr 1, 2017, 19:26 UTC · re: brian m. carlson · lore

Re: [PATCH] Documentation: make 3-way merge warning more generic

"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 13 quoted lines
>  With the strategies that use 3-way merge (including the default, 'recursive'),
> -if a change is made on both branches, but later reverted on one of the
> -branches, that change will be present in the merged result; some people find
> -this behavior confusing.  It occurs because only the heads and the merge base
> -are considered when performing a merge, not the individual commits.  The merge
> -algorithm therefore considers the reverted change as no change at all, and
> -substitutes the changed version instead.
> +only the heads and the merge base are considered when performing a merge, not
> +the individual commits.  This means that if a change is made on both branches,
> +but later reverted on one of the branches, that change will be present in the
> +merged result; some people find this behavior confusing.  The merge algorithm
> +considers the reverted change as no change at all, and substitutes the changed
> +version instead.

I agree that it makes sense to say 3-way merge considers only three points upfront.

I do not think "this means" is helpful to the readers, though. Drop "This means that" and instead rewrite the remainder of the paragraph after "present in the merged result", perhaps?

	If a change is made on both branches but later reverted on
	one of the branches, the net effect the branch that reverted
	the change has to the project is nothing, while the net
	effect of the other branch is to make that change.  The
	3-way merge, i.e. "if one branch did something while the
	other branch didn't do that something, merge result is to do
	that something", rule keeps the change in the merge result.

We do not need to say "some people find this confusing" buried in a long paragraph, which would not even serve the purpose of attracting readers' eyes by shouting "THIS MAY BE DIFFICULT, PAY ATTENTION". The last sentence in the original (and your version) only repeats the same thing without saying what the real 3-way merge rule is, and I think a rewrite like the above that makes it more explicit is easier to understand.

← back to recent threads