bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14459: git vc-annotate fails in detached HEAD state


From: Dmitry Gutov
Subject: bug#14459: git vc-annotate fails in detached HEAD state
Date: Fri, 24 May 2013 23:07:49 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

claudio.bley@gmail.com (Claudio Bley) writes:

> Apparently, vc-git-working-revision calls "git symbolic-ref HEAD",
> which - in this case - gives:
>
> $ git symbolic-ref HEAD
> fatal: ref HEAD is not a symbolic ref
>
> So, vc-git-working-revision returns an empty string as the current
> "revision" vc-mode refers to.
>
> M-: (vc-git-working-revision (buffer-file-name))
>
> -> ""
>
> When calling vc-annotate, the vc-git-annotate-command gets called with
> the empty string for the rev parameter leading to the error.
>
> This patch fixes it for me: ...

I think we should fix `vc-git-working-revision' instead. After all,
`vc-working-revision' says it returns nil when the file is not
registered at all.

Please try this patch:

=== modified file 'lisp/vc/vc-git.el'
--- lisp/vc/vc-git.el   2013-04-24 07:52:00 +0000
+++ lisp/vc/vc-git.el   2013-05-24 19:07:09 +0000
@@ -237,9 +237,8 @@
 (defun vc-git-working-revision (_file)
   "Git-specific version of `vc-working-revision'."
   (let* (process-file-side-effects
-        (str (with-output-to-string
-               (with-current-buffer standard-output
-                 (vc-git--out-ok "symbolic-ref" "HEAD")))))
+         (str (or (vc-git--run-command-string nil "symbolic-ref" "HEAD")
+                  (vc-git--run-command-string nil "rev-parse" "HEAD"))))
     (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
         (match-string 2 str)
       str)))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]