Search code examples
gitemacsgit-diffgit-log

How to list all lines with changes to easily navigate between changes with emacs?


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.


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)