3

I want to directly compare the diffs of two commits in emacs (rather than seeing the diff of two trees at given commit points).

A bonus would be being able to use ediff mode to compare the two buffers.

However there seems to be no way to have two *magit-revision* buffers open at once. Even if I rename the first, (magit-visit-ref) still updates that buffer.

I've looked through the manuals but couldn't find a reference to what controls the new buffer creation. Any ideas?

  • Not clear to me if you're asking to get a diff between two commits, or look at two diffs from two commits at once. – npostavs Oct 20 '16 at 13:38
  • 1
    @npostavs: the second, I want to compare the two commits side by side to see what changed in a particular changeset rather than over the whole tree. – stsquad Oct 20 '16 at 13:41
  • 2
    Have you tried running magit-toggle-buffer-lock on the first revision buffer rather than renaming it? – Kyle Meyer Oct 20 '16 at 13:45
  • @KyleMeyer: ahh that makes sense - and works ;-) – stsquad Oct 20 '16 at 13:47
  • @KyleMeyer: are you going to write up your answer or do you want me to do it? – stsquad Oct 21 '16 at 10:54
4

You can do it from the magit-log buffer

  • M-x magit-log
  • E r ref1..ref2
  • You can do it from the status buffer too (although seeing the log will help to find the refs, of course) – npostavs Oct 20 '16 at 13:39
  • This does get what I want, almost, is it possible to show the revisions side by side for all files or do I need to compare a file at a time? – stsquad Oct 20 '16 at 13:46
  • you need to compare a file at a time. – djangoliv Oct 21 '16 at 6:55
2

Based on Kyle Meyer's comment to the OP -- thanks, Kyle.

It seems that what you want is to see the diffs associated with the two commits in two separate magit-revision buffers. You can accomplish this by loading up the first diff in the usual way (e.g. by hitting RET on it in a log view), running M-x magit-toggle-buffer-lock so that the buffer becomes pinned to that particular view, and then loading up the second diff in the usual way.

Without M-x magit-toggle-buffer-lock, Magit would reuse the buffer containing the first diff, erasing it and putting the second diff there instead. With M-x magit-toggle-buffer-lock, Magit is "forced" to create a new buffer for the second diff, which is what you want.

Note that djangoliv's answer does something different; it starts up an ediff session comparing the versions of a file from two different different commits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.