Question

I would like git to show me all lines that changed between two specific commits, including the filename and the line number on each line. I imagine the output to be similar to

file.cpp:20:- void deletedFunction()
file.cpp:20:+ int addedFunction()
Makefile:3:-# removed comment

I want to use this to navigate easily through all changed of a commit with emacs via the next-error command of the compile-mode. So, the exact output after the second : can look different, but filename:line:... should be there. Also, not all changes have to be listed -- additions-only or deleteions-only would be ok for a start, too.

Was it helpful?

Solution

Nice to see my comment solved your question :) I said: «I'd like to know (mandatory question): are you not satisfied with magit, and why ? you can see diffs, navigate and hit to go to the file and line nb. Looks good to me.»

Magit manual lives here: http://magit.github.io/master/magit.html and code on github: https://github.com/magit/magit

a complete intro: http://www.masteringemacs.org/articles/2013/12/06/introduction-magit-emacs-mode-git/

(as usual, it is available with ELPA: M-x list-packages)

Enjoy !

ps: two configs I use:

; use ido to switch branches
; https://github.com/bradleywright/emacs-d/blob/master/packages/init-magit.el
(setq magit-completing-read-function 'magit-ido-completing-read)
;; open magit status in same window as current buffer
;; (setq magit-status-buffer-switch-function 'switch-to-buffer)
;; highlight word/letter changes in hunk diffs
(setq magit-diff-refine-hunk t)

OTHER TIPS

I've never used magit (though I've heard good things), and I very rarely use git (I'm an hg guy), but all of this should apply to a supported VCS of vc mode.

It doesn't work like compilation-mode, but you can easily navigate through diffs with diff-mode.

To get the diff buffer:

  • C-x v = does a diff on the current file.
  • C-x v D does a recursive diff on a directory.
  • C-x v d brings you to a buffer will all the modified/added/untracked/etc. files in the repo. You can select them with m and diff the selected files with =.

In the diff buffer:

  • n goes to the next hunk.
  • p goes to the previous hunk.
  • N goes to the next file.
  • P goes to the previous file.
  • o goes to the source file for the current hunk.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top