Showing the two sides of a `diff3` git conflict

I use the diff3 conflict marker style, so when I get a conflict I get the two sides, but also the original code (under the ||||||| heading):

<<<<<<< HEAD
GreenMessage.send(include_signature: true)
||||||| merged common ancestor
BlueMessage.send(include_signature: true)
=======
BlueMessage.send(include_signature: false)
>>>>>>> merged-branch

(example from Take the pain out of git conflict resolution: use diff3 – nilbus.com)

When I get these conflict, what I (almost?) always want to see is the diff between the HEAD and the original code and the diff between the merge and the original code. i.e. I want to see that one of the changes was

- BlueMessage.send(include_signature: true)
+ GreenMessage.send(include_signature: true)

…and the other change was

- BlueMessage.send(include_signature: true)
+ BlueMessage.send(include_signature: false)
>>>>>>> merged-branch

Is there anything built into Emacs (or Magit, perhaps?) for showing me these two diffs based on the diff3 conflict markers?

The smerge and ediff, Emacs’ built-in patching UIs, both can handle this format. The vc (built-in) and magit packages wrap them to add VCS support.

With magit you are probably most intrested in the magit-ediff-dwim command. The merge.conflictStyle git option needs to be set to diff3, as described in the article you’ve referenced.

Oh, wow. smerge-diff-base-upper and merge-diff-base-lower do exactly what I want. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.