Subject: bug#6481: 23.2.50; vc-annotate-show-log-revision-at-line yields empty buffer

From: Eric Hanchrow <[email-masked]>
Date: Sun, 20 Jun 2010 15:54:51 -0700

I visited a file in a git working copy, and typed C-x v g to see the
"blame".  In the resulting buffer, I typed "l".  I saw (after a few
seconds) a *vc-change-log* buffer that was empty.  Naturally, I expected
that buffer to contain a single log message from git, corresponding to
the commit ID on the line on which I typed "l".

I think the problem is that the annotated buffer looks like this:

    ad470f08 lisp/vc-git.el   (Dan Nicolaescu      2007-07-22 19:46:04
+0000   1) ;;; vc-git.el --- VC backend for the git version control
system
    ad470f08 lisp/vc-git.el   (Dan Nicolaescu      2007-07-22 19:46:04
+0000   2)

... and that the regexp in vc-git-annotate-extract-revision-at-line
matches from the end of the commit ID, all the way up to (but not
including) the first left-paren.  So the file name being returned from
that function is "lisp/vc-git.el   ", including the trailing spaces.

The following patch fixes it for me:

    diff --git a/lisp/vc-git.el b/lisp/vc-git.el
    index dec5479..a295106 100644
    --- a/lisp/vc-git.el
    +++ b/lisp/vc-git.el
    @@ -706,8 +706,14 @@ or BRANCH^ (where \"^\" can be repeated)."
         (when (looking-at "\\([0-9a-f^][0-9a-f]+\\) \\(\\([^(]+\\) \\)?")
           (let ((revision (match-string-no-properties 1)))
            (if (match-beginning 2)
    -	    (cons revision (expand-file-name (match-string-no-properties 3)
    -					     (vc-git-root default-directory)))
    +	    (let* ((extracted (match-string-no-properties 3))
    +                   (trimmed
    +                    (replace-regexp-in-string
    +                     (rx (one-or-more (any space)) eos)
    +                     ""
    +                     extracted)))
    +              (cons revision (expand-file-name trimmed
    +                                               (vc-git-root
default-directory))))
              revision)))))

     ;;; TAG SYSTEM

In GNU Emacs 23.2.50.2 (i686-pc-linux-gnu)
 of 2010-06-04 on debian
configured using `configure  '--without-x''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-autojoin-mode: t
  erc-log-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  eldoc-mode: t
  global-auto-revert-mode: t
  ido-everywhere: t
  display-time-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
h e s SPC f o r SPC ( a b b r e v i a t e - f i l e
- n a m e SPC d e f a u l t - d i r e c t o r y ) C-k
C-c C-u C-x u ESC C-p C-k h t t p : / / t h e p i o
n e e r w o m a n . c o m / c o o k i n g / 2 0 1 0
/ 0 1 / p e r f e c t - p o t a t o e s - a u - g r
a t i n / RET C-c C-@ C-c C-@ a s SPC i t SPC h a p
p e n s , SPC y e s RET C-c C-@ C-c C-@ C-c C-@ l e
t ' s SPC h a v e SPC t h e SPC b o t s SPC t DEL d
o SPC i t SPC f o r SPC u s RET ESC x w o m a n RET
c u r l RET C-s - F C-s C-a ESC 0 C-l q C-c C-@ C-c
C-@ o p s ! RET C-c C-@ C-x b v c - RET C-h i t C-s
t r i m C-s C-s C-a C-x b s h e RET ESC x r e p o r
t - e m TAB RET C-g C-x 2 C-x b C-s RET C-x b a n n
RET C-h c l C-x b RET ESC < C-s - s h o w - l C-w -
r DEL C-s C-a ESC x ESC p RET

Recent messages:
Mark saved where search started
Source file `/usr/local/src/emacs/lisp/mail/emacsbug.el' newer than
byte-compiled file
Quit
l runs the command vc-annotate-show-log-revision-at-line
Mark set
Mark saved where search started
Scanning for dabbrevs...99%
dabbrev-expand: No dynamic expansion for `vc-show-log' found
Scanning for dabbrevs...99%
dabbrev-expand: No dynamic expansion for `vc-show-log-re' found

Load-path shadows:
~/.emacs.d/custom hides /usr/local/src/emacs/lisp/custom
/usr/local/src/emacs/lisp/s-region hides
/usr/local/src/emacs/lisp/obsolete/s-region

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045
qp ietf-drums mailabbrev nnheader mm-util mail-prsvr gmm-utils
mailheader canlock hashcash emacsbug vc-annotate rect tabify org-table
org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo
org-infojs org-html org-exp org-exp-blocks org-agenda org-info org-gnus
org-bibtex org-bbdb org byte-opt bytecomp byte-compile org-footnote
org-src org-list org-faces org-compat org-macs noutline outline erc-dcc
novice em-unix em-term term ehelp em-script em-prompt em-ls em-hist
em-pred em-glob em-dirs em-cmpl em-basic esh-opt em-banner em-alias
esh-var esh-io esh-cmd esh-ext esh-proc esh-arg esh-groups eshell
esh-module esh-mode esh-util etags tmm electric two-column wdired
make-mode ffap iso-transl disp-table jka-compr cus-start cus-load
icomplete apropos vc-bzr sha1 hex-util vc-sccs vc-cvs vc-rcs vc-dir ewoc
cc-mode cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs debug mule-util info log-edit smerge-mode add-log log-view
pcvs-util diff-mode easy-mmode vc conf-mode newcomment vc-git cmuscheme
scheme help-mode view epa-file tramp-imap tramp-gw tramp-fish tramp-smb
tramp-cache tramp-ftp tramp-cmds tramp auth-source gnus-util netrc shell
password-cache tramp-compat trampver multi-isearch rmail mail-utils
dabbrev warnings erc-menu erc-ring erc-pcomplete time-date pcomplete
erc-track erc-match erc-netsplit erc-goodies erc-button erc-fill
erc-stamp wid-edit erc-truncate erc-spelling flyspell ispell erc-join
erc-log erc-services erc-networks erc erc-backend erc-compat format-spec
thingatpt pp package reporter woman easymenu man assoc vc-dispatcher
vc-svn eldoc midnight uniquify advice help-fns advice-preload epa epg
epg-config derived autorevert ansi-color server grep compile comint ring
tool-bar cl cl-19 find-func ibuf-ext ibuf-macs ibuffer ido dired-x
dired-aux dired regexp-opt edmacro kmacro rx autoinsert time image
ediff-hook vc-hooks lisp-float-type lisp-mode register page menu-bar
rfn-eshadow timer jit-lock font-lock syntax facemenu font-core frame
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
multi-tty emacs)

-- 
If there were a little guy running around inside the computer
executing our programs, he would probably have as long and
plaintive a tale to tell about his job as a federal government
employee.
        -- Paul Graham