Re: Improving merge of tricky conflicts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> On Wed, Jul 22, 2020 at 07:50:08AM +0200, Johannes Sixt wrote:
>
>> Am 22.07.20 um 01:29 schrieb B. Stebler:
>> > I have been looking for a tool to display merge conflicts, that instead
>> > of showing the two versions of the conflicting section, would show the
>> > diff for that section in both conflicting commits.
>> 
>> Perhaps you want to configure `merge.conflictStyle=diff3`? It does not
>> exactly show a diff, but it writes the base version of the conflicted
>> part in addition to "ours" and "theirs".
>
> Yeah, I find diff3 is usually sufficient. But the contents of the base,
> "ours", and "theirs" sides are also available in the index:
>
>   # diff between base (stage 1) and ours (stage 2)
>   git diff :1:file :2:file
>
>   # diff between base (stage 1) and theirs (stage 3)
>   git diff :1:file :3:file
>
> I thought we had added nice aliases for "ours" and "theirs" instead of
> the hard-to-remember stage numbers, but I think we only did so for
> things like "git checkout --ours", etc.
>
> The big downside here, of course, is that it's showing the diff for the
> whole file, not just one hunk (on the other hand, I often find the
> trickiest conflicts are ones where the changes unexpectedly span
> multiple hunks).

Yup, I often find myself comparing the base part (lines between |||
and ===) with our part (lines between <<< and |||) and their part
(lines between === and >>>) while looking at the diff3 output to see
what unique change each side did, in order to come up with a
conflict resolution.

I do this often enough to wonder if I should write a small "filter"
that I can pipe a whole "diff3" <<< ... ||| ... === ... >>> region
to and convert it into to diffs, but not often enough to motivate
me to actually write one ;-).



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux