2

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.

  • You can have a look here: quora.com/… – 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
0

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.

  • 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 9:57
8

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

(setq vc-git-annotate-switches '("-w"))
  • 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 9:26

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.