4

I have a hard time using vc-annotate (my version control system is git), because the output is not very userfriendly, as it displays long filenames in a separate column in the buffer, which take up half of my screen. Apart from that it takes ages until vc-annotate command returns any output.

I suspect this is because of some arguments passed to git blame command. Can I somehow override the default vc-annotate command and pass my custom options to git blame (like not showing file paths, different date format etc.)

I tried magit-blame but didn't like the output style of mixing code and annotations.

tarsius
  • 25,298
  • 4
  • 69
  • 109
Max
  • 311
  • 2
  • 11
  • You can have a look here: https://www.quora.com/How-do-I-get-emacss-vc-annotate-to-show-only-the-author-of-a-line-Im-using-git – djangoliv Oct 28 '15 at 14:40
  • I tend to just use `v` to hide the metadata when it takes up too much space, and then toggle it back on when I want to see it. – phils Jan 12 '17 at 21:01

2 Answers2

12

With Emacs 25.1 you can pass options to git blame using the vc-git-annotate-switches variable:

(setq vc-git-annotate-switches '("-w"))
Scott Weldon
  • 2,695
  • 1
  • 17
  • 31
skybert
  • 373
  • 4
  • 10
  • 2
    But `-c` (that suppress embedding long file names into blame) option breaks highlighting and VC commands. I wander if there is a bug reported on this issue. – gavenkoa Apr 30 '17 at 09:26
1

These are hard-coded into the vc-git-annotate-command function. The following is from 24.5:

(defun vc-git-annotate-command (file buf &optional rev)
  (let ((name (file-relative-name file)))
    (vc-git-command buf 'async nil "blame" "--date=iso" "-C" "-C" rev "--" name)))

The simplest thing at present is probably to redefine the function:

(eval-after-load "vc-git"
  '(defun vc-git-annotate-command (file buf &optional rev)
     ...))

You could also M-x report-emacs-bug to ask for the command arguments to be abstracted out to a variable, if you conclude there's a good case for this to be configurable.

phils
  • 48,657
  • 3
  • 76
  • 115
  • 1
    Nice thank you. That should help, but I cant seem to find a way to exclude the file path from the git output. Do you know if I can somehow make the file path column narrower in emacs? – Max Oct 30 '15 at 11:52
  • Oh... You're seeing file paths in your `vc-annotate` output with git? That's not normal (or certainly not with git 2.1.4). Which version are you using? – phils Oct 30 '15 at 12:13
  • 1
    See the discussion of the `--show-name` option in the `git-blame` man page. It shouldn't be active by default, but git enables it automatically in certain circumstances because it's important. You can pass `--no-show-name` to force it off, but it looks to me as if that's a *bad* idea. Instead try just toggling the metadata off and on (`v`) in the vc-annotate buffer, as required. – phils Oct 30 '15 at 12:23
  • I see, git indeed only shows the filename when the file was renamed. But my project has quite deep dir structure, so the filename column takes 3/4 of my screen. Hm ok, if thats the only viable solution, then I might have to goggle the metadata with v, but better would be to narrow the file column or be able to toggle that column only … anyway, thanks for your help! :) – Max Oct 31 '15 at 09:57