Message ID | pull.1505.git.git.1683295133304.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | doc: merge: improve conflict presentation docs | expand |
"Adam Johnson via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: Adam Johnson <me@adamj.eu> > > Improvements: > > 1. Remove the sexist example ("Barbie... wants to go shopping") "Barbie goes shopping" is a pretty common meme. A random internet search finds many of them, e.g. https://featuredanimation.com/barbie-memes/ If it is about only Barbie herself, not about any other random girls, would it still be a "sexist" example? > 2. Show real merge marker contents, rather than e.g. "yours:sample.txt". I am a bit torn about this change. While I can see why we may want to show sample output that is bit-for-bit-faithful to reality, these examples are written to teach what each part of the output means, and comments like "yours:sample.txt" are used instead of the actual conflict marker comments to be more helpful for illustrative purposes, and this change goes directly against it. > 3. Swap yours/theirs terms for source/target. I am not sure if this change is as an improvement, especially in the context of "git merge", which you merge their work into your history [*]. Surely, it *is* possible to rephase what I just said to "you merge source's work into target's history", but it makes the primary point of doing a merge less clear. But others may have different opinions, so please do not take this as the final rejection on this point. Thanks. [Footnote] * Conflicts during "git rebase" is a different matter. You tentatively put your feet in the shoes of your upstream people, whom you can call "them", and replay "your" changes on top of "their" work, and a conflict you will see during this process is what "they" will see, i.e. while you are resolving such a conflict, you are playing the role of your upstream people, and the conflict you see is shown from their point of view. In that context, "your" vs "their" may be suboptimal.
On Fri, May 5, 2023 at 6:58 AM Adam Johnson via GitGitGadget <gitgitgadget@gmail.com> wrote: > > From: Adam Johnson <me@adamj.eu> > > Improvements: > > 1. Remove the sexist example ("Barbie... wants to go shopping") > 2. Show real merge marker contents, rather than e.g. "yours:sample.txt". > 3. Swap yours/theirs terms for source/target. > 4. General wordsmithing. > > Signed-off-by: Adam Johnson <me@adamj.eu> > --- > doc: merge: improve conflict presentation docs > > Improvements: > > 1. Remove the sexist example ("Barbie... wants to go shopping") > 2. Show real merge marker contents, rather than e.g. > "yours:sample.txt". > 3. Swap yours/theirs terms for source/target. > 4. General wordsmithing. > > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1505%2Fadamchainz%2Faj%2Fmerge-conflict-docs-improvements-v1 > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1505/adamchainz/aj/merge-conflict-docs-improvements-v1 > Pull-Request: https://github.com/git/git/pull/1505 > > Documentation/git-merge.txt | 75 ++++++++++++++++++------------------- > 1 file changed, 37 insertions(+), 38 deletions(-) > > diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt > index 0aeff572a59..b4523362e48 100644 > --- a/Documentation/git-merge.txt > +++ b/Documentation/git-merge.txt > @@ -233,11 +233,11 @@ HOW CONFLICTS ARE PRESENTED > > During a merge, the working tree files are updated to reflect the result > of the merge. Among the changes made to the common ancestor's version, > -non-overlapping ones (that is, you changed an area of the file while the > -other side left that area intact, or vice versa) are incorporated in the > -final result verbatim. When both sides made changes to the same area, > +non-overlapping ones, where only one side changed an area, are incorporated > +in the final result as-is. When both sides made changes to the same area, > however, Git cannot randomly pick one side over the other, and asks you to > -resolve it by leaving what both sides did to that area. > +resolve it. Git adds changes from both sides, and optionally the > +original content from the common ancestor, surrounded by merge markers. Everywhere else in the manual we have referred to these as "conflict markers", not "merge markers". (Even if you spread out to the whole codebase, there are only two places in the code (xdiff-interface.h and t6402) that refers to "merge markers", while there are 94 places that use "conflict markers". We should fix those two to be like the other 94.) Other than that, this rewrite seems good. > By default, Git uses the same style as the one used by the "merge" program > from the RCS suite to present such a conflicted hunk, like this: If we're updating this documentation, perhaps it's time to drop the mention of RCS? 15 years ago, the reference made sense to bring up -- there were numerous folks who were new to Git that were familiar with RCS (even if only via CVS). The number of folks left who are still aware of RCS but are not aware of Git, is probably very tiny, while there are many folks new to Git who haven't heard of RCS. Maybe it still makes sense and doesn't hurt, but I'm not sure what it's buying us anymore. > @@ -245,71 +245,70 @@ from the RCS suite to present such a conflicted hunk, like this: > ------------ > Here are lines that are either unchanged from the common > ancestor, or cleanly resolved because only one side changed, > -or cleanly resolved because both sides changed the same way. > -<<<<<<< yours:sample.txt > -Conflict resolution is hard; > -let's go shopping. > +or cleanly resolved because both sides changed identically. > +<<<<<<< HEAD > +Git makes conflict resolution straightforward. > ======= > Git makes conflict resolution easy. > ->>>>>>> theirs:sample.txt > +>>>>>>> main > And here is another line that is cleanly resolved or unmodified. > ------------ Three items here about the modifications to the conflict marker annotations: (1) The use of "HEAD": For a decade and a half, merges always involved modifying the worktree as well, which somewhat forced merges to always be done with HEAD. With a new merge backend, that is not necessary anymore, and conflicts can be generated (e.g. by `git log --remerge-diff` or `git replay` or `git merge-tree`) which do not involve HEAD. The use of "HEAD" and "main" might both be considered suboptimal in the world we are moving into. For example, perhaps: <<<<<<< current_branch ("summary of commit msg that current_branch points to") ... >>>>>>> main ("summary of commit main points to") would be better, especially in cases where the user specified to merge a hash rather than a branch name. (Note that this is similar to how --remerge-diff behaves.) Of course, I've started to turn this into a question of what we should change the implementation to, whereas you were trying to document existing behavior, but sometimes documentation highlights these subtle things... (2) Conflict markers carry an extra annotation of the form :FILENAME whenever the filename differs on the two sides of history, so these could be e.g. HEAD:sample.txt and main:renamed.txt in a real example. Granted, most conflicts probably don't involve renamed files, but would it be more useful from a documentation standpoint to make users aware of what might be seen? (3) The use of "real" conflict markers instead of sample ones, meant that for the diff3 case below you used "81821ce" as the annotation. The odds of a user having that particular hash is pretty slim, and feels like much more of a distraction than using some synthetic hash or label. More on that below where it comes up. (All that said, I'm not sure what's best to use for the documentation right now, but thought these were relevant items to bring up.) > The area where a pair of conflicting changes happened is marked with markers > `<<<<<<<`, `=======`, and `>>>>>>>`. The part before the `=======` > -is typically your side, and the part afterwards is typically their side. > +is typically from the target (where you’re merging into), and the part > +afterwards is typically from the source (where you’re merging from). I dislike the whole "yours" & "theirs" thing. It would have been fine as originally designed, but in the UI at some point the terms were hardcoded and documented to stages 2 & 3 and rebase came along where those meanings were exactly backwards. But, it's unfixable now, so the best we can do is just to avoid these terms. I'm happy to see them used one less place here. > +The default format does not show what the original version contained in the > +conflicting area. You cannot tell how many lines have been deleted and > +replaced on either side. The only thing you can tell is that the target side > +says "straightforward", while the source side says "easy". > > -The default format does not show what the original said in the conflicting > -area. You cannot tell how many lines are deleted and replaced with > -Barbie's remark on your side. The only thing you can tell is that your > -side wants to say it is hard and you'd prefer to go shopping, while the > -other side wants to claim it is easy. > +You can use an alternative conflict marker style by setting the > +`merge.conflictStyle` configuration variable to either "diff3" or "zdiff3". > +Both of these styles show the original version of the conflicted area, which > +may help you find a better resolution. > > -An alternative style can be used by setting the "merge.conflictStyle" > -configuration variable to either "diff3" or "zdiff3". In "diff3" > -style, the above conflict may look like this: > +In the "diff3" style, the above conflict looks like this: > > ------------ > Here are lines that are either unchanged from the common > ancestor, or cleanly resolved because only one side changed, > -<<<<<<< yours:sample.txt > -or cleanly resolved because both sides changed the same way. > -Conflict resolution is hard; > -let's go shopping. > -||||||| base:sample.txt > +<<<<<<< HEAD > or cleanly resolved because both sides changed identically. > +Git makes conflict resolution straightforward. > +||||||| 81821ce Here's what I was referring to above. "Using real values" ends up causing us to use a value (81821ce) that a user would basically never see, and thus seems more likely to confuse them than using a descriptive term or even a fake hash (such as "aaaaaaa"). > +or cleanly resolved because both sides changed the same way. > Conflict resolution is hard. > ======= > -or cleanly resolved because both sides changed the same way. > +or cleanly resolved because both sides changed identically. > Git makes conflict resolution easy. > ->>>>>>> theirs:sample.txt > +>>>>>>> main > And here is another line that is cleanly resolved or unmodified. > ------------ > > -while in "zdiff3" style, it may look like this: > +while in the "zdiff3" style, it looks like this: The insertion of "the" surprises me. It reads better without it to me, but I don't know if I'm just used to some grammar rule being violated or something. Why is "the" necessary here? > ------------ > Here are lines that are either unchanged from the common > ancestor, or cleanly resolved because only one side changed, > -or cleanly resolved because both sides changed the same way. > -<<<<<<< yours:sample.txt > -Conflict resolution is hard; > -let's go shopping. > -||||||| base:sample.txt > or cleanly resolved because both sides changed identically. > +<<<<<<< HEAD > +Git makes conflict resolution straightforward. > +||||||| 81821ce > +or cleanly resolved because both sides changed the same way. > Conflict resolution is hard. > ======= > Git makes conflict resolution easy. > ->>>>>>> theirs:sample.txt > +>>>>>>> main > And here is another line that is cleanly resolved or unmodified. > ------------ > > -In addition to the `<<<<<<<`, `=======`, and `>>>>>>>` markers, it uses > -another `|||||||` marker that is followed by the original text. You can > -tell that the original just stated a fact, and your side simply gave in to > -that statement and gave up, while the other side tried to have a more > -positive attitude. You can sometimes come up with a better resolution by > -viewing the original. > +The original commit SHA and text are shown after another marker, `|||||||`. > +This region lets you now see that both sides made the edit from "the same > +way" to "identically", as well as editing the following line. The "diff3" > +style keeps all changed lines within the markers, whilst the "zdiff3" style > +moves the commonly edited line before the marker. The comment you added here about zdiff3 is correct in context, but feels misleading in general. commonly edited lines at the beginning of the two sides are moved before the conflict markers, commonly edited lines at the ending of the two sides are moved after the markers, and commonly edited lines anywhere else are left where they are.
Junio C Hamano wrote: > "Adam Johnson via GitGitGadget" <gitgitgadget@gmail.com> writes: > > From: Adam Johnson <me@adamj.eu> > > > > Improvements: > > > > 1. Remove the sexist example ("Barbie... wants to go shopping") > > "Barbie goes shopping" is a pretty common meme. And it's not sexist in the least. Tony Montana likes big guns, and it's not sexist to say that outloud. Tina can like big guns as well, and Peter can like to go shopping. The fact that a preference happens to match a stereotype doesn't mean that saying so constitutes bigotry. I'm Mexican and I like tacos. There's nothing wrong with somebody saying "Felipe likes tacos", especially because it's true. So what if Barbie likes to go shopping? So what if Amanda likes the color pink? Am I not allowed to like tacos because I'm Mexican?
Elijah Newren wrote: > On Fri, May 5, 2023 at 6:58 AM Adam Johnson via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > -while in "zdiff3" style, it may look like this: > > +while in the "zdiff3" style, it looks like this: > > The insertion of "the" surprises me. It reads better without it to > me, but I don't know if I'm just used to some grammar rule being > violated or something. Why is "the" necessary here? It's not necessary, but the addition of the word "the" suggests a single well-known term. If you say "minimalist style", that can refer to a broad range of styles that are generally refered to as of "minimalist" type. On the other hand if you say "the Minimalist tyle" it evokes a *single* style that cannot be confused with any other. In this case it's a single style, so "the" is warranted.
On Sat, May 6, 2023 at 4:40 PM Elijah Newren <newren@gmail.com> wrote: > > On Fri, May 5, 2023 at 6:58 AM Adam Johnson via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > [...] > Everywhere else in the manual we have referred to these as "conflict > markers", not "merge markers". [...] > If we're updating this documentation, perhaps it's time to drop the > mention of RCS? [...] > I dislike the whole "yours" & "theirs" thing. [...] I'm happy to see > them used one less place here. [...] > "Using real values" [...] seems more likely to confuse them than using a > descriptive term or even a fake hash (such as "aaaaaaa"). [...] > The comment you added here about zdiff3 is correct in context, [...] I realized I also failed to note that I like the patch in general and think it has some good cleanups, even if there are potential further improvements to make. Looking forward to your reroll.
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 0aeff572a59..b4523362e48 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -233,11 +233,11 @@ HOW CONFLICTS ARE PRESENTED During a merge, the working tree files are updated to reflect the result of the merge. Among the changes made to the common ancestor's version, -non-overlapping ones (that is, you changed an area of the file while the -other side left that area intact, or vice versa) are incorporated in the -final result verbatim. When both sides made changes to the same area, +non-overlapping ones, where only one side changed an area, are incorporated +in the final result as-is. When both sides made changes to the same area, however, Git cannot randomly pick one side over the other, and asks you to -resolve it by leaving what both sides did to that area. +resolve it. Git adds changes from both sides, and optionally the +original content from the common ancestor, surrounded by merge markers. By default, Git uses the same style as the one used by the "merge" program from the RCS suite to present such a conflicted hunk, like this: @@ -245,71 +245,70 @@ from the RCS suite to present such a conflicted hunk, like this: ------------ Here are lines that are either unchanged from the common ancestor, or cleanly resolved because only one side changed, -or cleanly resolved because both sides changed the same way. -<<<<<<< yours:sample.txt -Conflict resolution is hard; -let's go shopping. +or cleanly resolved because both sides changed identically. +<<<<<<< HEAD +Git makes conflict resolution straightforward. ======= Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt +>>>>>>> main And here is another line that is cleanly resolved or unmodified. ------------ The area where a pair of conflicting changes happened is marked with markers `<<<<<<<`, `=======`, and `>>>>>>>`. The part before the `=======` -is typically your side, and the part afterwards is typically their side. +is typically from the target (where you’re merging into), and the part +afterwards is typically from the source (where you’re merging from). + +The default format does not show what the original version contained in the +conflicting area. You cannot tell how many lines have been deleted and +replaced on either side. The only thing you can tell is that the target side +says "straightforward", while the source side says "easy". -The default format does not show what the original said in the conflicting -area. You cannot tell how many lines are deleted and replaced with -Barbie's remark on your side. The only thing you can tell is that your -side wants to say it is hard and you'd prefer to go shopping, while the -other side wants to claim it is easy. +You can use an alternative conflict marker style by setting the +`merge.conflictStyle` configuration variable to either "diff3" or "zdiff3". +Both of these styles show the original version of the conflicted area, which +may help you find a better resolution. -An alternative style can be used by setting the "merge.conflictStyle" -configuration variable to either "diff3" or "zdiff3". In "diff3" -style, the above conflict may look like this: +In the "diff3" style, the above conflict looks like this: ------------ Here are lines that are either unchanged from the common ancestor, or cleanly resolved because only one side changed, -<<<<<<< yours:sample.txt -or cleanly resolved because both sides changed the same way. -Conflict resolution is hard; -let's go shopping. -||||||| base:sample.txt +<<<<<<< HEAD or cleanly resolved because both sides changed identically. +Git makes conflict resolution straightforward. +||||||| 81821ce +or cleanly resolved because both sides changed the same way. Conflict resolution is hard. ======= -or cleanly resolved because both sides changed the same way. +or cleanly resolved because both sides changed identically. Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt +>>>>>>> main And here is another line that is cleanly resolved or unmodified. ------------ -while in "zdiff3" style, it may look like this: +while in the "zdiff3" style, it looks like this: ------------ Here are lines that are either unchanged from the common ancestor, or cleanly resolved because only one side changed, -or cleanly resolved because both sides changed the same way. -<<<<<<< yours:sample.txt -Conflict resolution is hard; -let's go shopping. -||||||| base:sample.txt or cleanly resolved because both sides changed identically. +<<<<<<< HEAD +Git makes conflict resolution straightforward. +||||||| 81821ce +or cleanly resolved because both sides changed the same way. Conflict resolution is hard. ======= Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt +>>>>>>> main And here is another line that is cleanly resolved or unmodified. ------------ -In addition to the `<<<<<<<`, `=======`, and `>>>>>>>` markers, it uses -another `|||||||` marker that is followed by the original text. You can -tell that the original just stated a fact, and your side simply gave in to -that statement and gave up, while the other side tried to have a more -positive attitude. You can sometimes come up with a better resolution by -viewing the original. +The original commit SHA and text are shown after another marker, `|||||||`. +This region lets you now see that both sides made the edit from "the same +way" to "identically", as well as editing the following line. The "diff3" +style keeps all changed lines within the markers, whilst the "zdiff3" style +moves the commonly edited line before the marker. HOW TO RESOLVE CONFLICTS