How to diff two branches with ediff preview

237 views
Skip to first unread message

Markus Lachinger

unread,
Nov 9, 2015, 12:26:10 PM11/9/15
to magit
Is there a way in emacs, spacemacs to be precise, to diff two branches and get a list of changed files (I use magit diff revision for this now) BUT ALSO allow me to diff the file at point in the list in a ediff session below?

So my ideal workflow would be:

magit-diff the branches

----------------------
| foo.rb |
| bar.txt |
| ..... |
----------------------
When I now go onto foo.rb and trigger the function I am looking for, it will spawn a ediff below:

----------------------
| foo.rb |
| bar.txt |
| ..... |
----------------------
| foo.1 | foo.2 |
| | |
| + Hello | |
| World | World |
----------------------

Doing the same again on the diff list will change the ediff file, i.a. when I go back to the list and call the function on bar.txt it will replace the ediff with the ediff for the bar.txt

Is there any way to do this with vc / magit or another plugin? I have no idea yet how to script emacs :/


(also asked on stackoverflow here: http://stackoverflow.com/questions/33601547/how-to-diff-two-branches-in-emacs-with-ediff-preview )

Kyle Meyer

unread,
Nov 9, 2015, 12:59:12 PM11/9/15
to Markus Lachinger, magit
Markus Lachinger <mmlaco...@gmail.com> writes:

[...]

> So my ideal workflow would be:
>
> magit-diff the branches
>
> ----------------------
> | foo.rb |
> | bar.txt |
> | ..... |
> ----------------------
> When I now go onto foo.rb and trigger the function I am looking for, it will spawn a ediff below:
>
> ----------------------
> | foo.rb |
> | bar.txt |
> | ..... |
> ----------------------
> | foo.1 | foo.2 |
> | | |
> | + Hello | |
> | World | World |
> ----------------------
>
> Doing the same again on the diff list will change the ediff file,
> i.a. when I go back to the list and call the function on bar.txt it
> will replace the ediff with the ediff for the bar.txt
>
> Is there any way to do this with vc / magit or another plugin?

Not that I'm know of.

So IIUC, you want

1) to be able to call magit-ediff from a file line in a diff buffer
2) keep the original diff buffer visible
3) have the ediff session update to a new file without having to
manually quit the previous ediff session

At least at first glance, my guess is that #2 and #3 would require some
pretty tricky fiddling with ediff, and I'm not sure I understand what
the motivation is there.

#1 seems like a reasonable context for magit-ediff-dwim to be aware of,
and I think it should be straightforward to add.

--
Kyle

Markus Lachinger

unread,
Nov 9, 2015, 3:40:32 PM11/9/15
to magit, mmlaco...@gmail.com
On Monday, November 9, 2015 at 9:59:12 AM UTC-8, Kyle Meyer wrote:
The motivation / use case is to be able to quickly assess the changes that were made i.e. between two branches while having more context than just the diff ± a few lines, or just be able to jump around in the file.

I could use RET to jump to the file and then switch back the buffer, but that is pretty irritating

Is there a better/'more magit' way to do that which I am not thinking of?

Kyle Meyer

unread,
Nov 9, 2015, 5:22:22 PM11/9/15
to Markus Lachinger, magit
Markus Lachinger <mmlaco...@gmail.com> writes:

[...]

> The motivation / use case is to be able to quickly assess the changes
> that were made i.e. between two branches while having more context
> than just the diff ± a few lines, or just be able to jump around in
> the file.
>
> I could use RET to jump to the file and then switch back the buffer, but that is pretty irritating

So the main irritation is that it replaces the diff window? I suppose
when I want to get back to the diff buffer, I typically call
winner-undo. Or if you give a C-u, magit-diff-visit-file will open it
in another window.

> Is there a better/'more magit' way to do that which I am not thinking of?

Depending on how much more context you want to see, you could try
magit-diff-more-context (+).

--
Kyle
Reply all
Reply to author
Forward
0 new messages