20

I'm a die-hard emacs user, but so far have always used kdiff3 for 3-way merges with ancestor, e.g. when performing git merge or rebase. I really like the way that kdiff3 can not only simultaneously display all four versions of the text being merged:

  • the common ancestor (buffer A in kdiff3)
  • "ours" a.k.a. "local" (buffer B in kdiff3)
  • "theirs" a.k.a. "remote" (buffer C in kdiff3)
  • the merge result or target

but also makes the differences between A, B, and C clear via colour highlighting. However, kdiff3 unsurprisingly sucks in comparison to emacs when it comes to text editing of the merge buffer, since kdiff3 is not a full-blown text editor. It also doesn't integrate out of the box with the excellent magit package. So I'm trying to switch to using ediff when resolving conflicts in this particular scenario (I have been successfully using ediff for other use cases for many years).

However, despite reading the ediff manual and EmacsWiki page, and asking on #emacs IRC, I can't find a way to simultaneously display all 4 buffers. By default it shows:

  • "ours" a.k.a. "local" (labelled buffer A)
  • "theirs" a.k.a. "remote" (labelled buffer B)
  • the merge result or target (labelled buffer C)

Pressing / switches the window displaying the merge result buffer (C) so that it displays the ancestor buffer, but you can't see the ancestor and the merge result simultaneously. (Also, the diff in the ancestor buffer is highlighted in a single colour which doesn't clearly show which bits differ from the other two visible buffers (A and B), although according to this thread, it seems that unfortunately ancestor diff refinement hasn't been implemented yet.)

Is there an easy way to configure ediff to simultaneously display all 4 buffers?

Adam Spiers
  • 15,491
  • 5
  • 40
  • 61

2 Answers2

6

This has being added to the trunk version. Now by default, 3-way merges show four buffers, i.e., "local" (buffer A), "remote" (buffer B), the merge result (buffer C) and the ancestor. You can change this default customizing the new option 'ediff-show-ancestor'.

The key '/' is now bound to a new command 'ediff-toggle-show-ancestor': it toggles whether to show 3 (local, remote and result) or 4 (local, remote, result, ancestor) buffers.

These changes will be visible in Emacs 26.1 release.

Tino
  • 334
  • 4
  • 7
  • 1
    I've finally found that `git config --global merge.conflictStyle diff3` ensures the ancestor version is also inserted within the conflict range, which seems to be necessary to take advantage of this feature. – Adam Spiers Jan 02 '21 at 21:16
1

Nope, there's no easy way to just configure it to do that. There is the option ediff-window-setup-function, which you can customize to be any function you want. You can look at the defaults, ediff-setup-windows-plain and ediff-setup-windows-multi to get an idea of what you'll need to do. In fact, the easiest way to proceed will be to copy one of them into your emacs config and modify it (changing the name, of course); they're not trivial.

db48x
  • 2,886
  • 20
  • 16