git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Improving merge of tricky conflicts

From
Sergey Organov <sorganov@gmail.com>
Date
Jul 24, 2020, 06:53 UTC
Message-ID
<874kpxwghu.fsf@osv.gnss.ru>
In-Reply-To
<xmqqimedq5c8.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
>
>>> You can also do it after "git merge" aborts with conflicts by running:
>>>
>>>   git checkout --conflict=diff3 my-file
>>>
>>> but do note that it will check out from the index, overwriting any
>>> resolution you've already done in that file.
>>
>> Though now it gets really odd "git merge" itself doesn't have this
>> option.
>
> A command line option is cumbersome that you have to type it every
> time, so configuration variable makes 100% more sense than an option
> to "git merge".

Fortunately Git already supports configuration variable, that we both agree is a nice thing to have, so I won't have to type the option every time, no.

> If your merge used the merge (as opposed to diff3) style, and seeing
> that the resulting conflict is not easy to review and you wish you
> used diff3 style instead, it is way too late for any option to "git
> merge" to help you.
  $ git merge --abort
  $ git merge --conflict=diff3 side-branch
or, say, entirely imaginary:
  $ git merge --redo --conflict=diff3 side-branch -- my-file

if merge had --redo option and path limiting support, that could be handy for other reasons as well, as I have already pointed elsewhere and you disagreed, but still.

>
> But having an option to "git checkout" lets you move forward from
> that state, so it also makes 100% more sense than an option to "git
> merge".

Actually, "git checkout" is not the place where I'd expect to find this feature in the first place, so to me it's rather already 99% illogical.

If "git merge" is what gave me the original result, it's some "git merge" variant that I'd expect to give me modified result as well.

Yeah, I can see how Git machinery is an excuse for "git checkout" to end up being used for this feature, but only after I learned it is.

Show 7 quoted lines
> So, it is not odd at all.  Just compare between merge and diff3,
> think which one would often help you, configure to use it by default,
> *and* at a rare occasion where the chosen default does not work for
> you, let "checkout" help you.  The thing is, unless you first attempt
> to "git merge", you won't know what shape of conflict you would get,
> so you cannot choose the right conflict style command line option,
> even if one were available.
What looks odd to me is that for "git merge" I need to use:
   $ git -c merge.conflictstyle=diff3 merge side-branch
as you yourself pointed, whereas for "git checkout" I can use:
   $ git checkout --conflict=diff3 my-file
even though it could have been:
   $ git -c merge.conflictstyle=diff3 checkout -m my-file
as far as I can tell. A minor inconsistency, but still.

If I got your arguments right, you think that having short-cut option for "git checkout" makes sense, while having similar one for "git merge" doesn't, whereas my argument is that either both make sense, or both don't.

Anyway, it's nice we can still do these things, one way or another.

Thanks, -- Sergey

Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 25 in “Improving merge of tricky conflicts”
  1. B. SteblerJul 21, 2020
  2. Johannes SixtJul 22, 2020
  3. Jeff KingJul 22, 2020
  4. Junio C HamanoJul 22, 2020
  5. Jeff KingJul 23, 2020
  6. Junio C HamanoJul 24, 2020
  7. Jeff KingJul 24, 2020
  8. Junio C HamanoJul 24, 2020
  9. Martin von ZweigbergkJan 16, 2021
  10. Jeff KingJan 21, 2021
  11. Martin von ZweigbergkJan 21, 2021
  12. Jeff KingJan 21, 2021
  13. Sergey OrganovJul 22, 2020
  14. Junio C HamanoJul 22, 2020
  15. Sergey OrganovJul 22, 2020
  16. Jeff KingJul 23, 2020
  17. Sergey OrganovJul 23, 2020
  18. Junio C HamanoJul 23, 2020
  19. Jacob KellerJul 24, 2020
  20. Junio C HamanoJul 24, 2020
  21. Sergey OrganovJul 24, 2020
  22. Junio C HamanoJul 24, 2020
  23. Sergey OrganovJul 24, 2020
  24. Junio C HamanoJul 24, 2020
  25. Bono SteblerJul 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.