all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#14459: git vc-annotate fails in detached HEAD state
@ 2013-05-24 13:07 Claudio Bley
  2013-05-24 19:07 ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Claudio Bley @ 2013-05-24 13:07 UTC (permalink / raw)
  To: 14459

Hi.

1. I open a git versioned file with vc-git enabled in a directory
   currently in detached HEAD state (e.g. after checking out a tag)
2. notice the mode line says "Git:!"

Now, when I do

C-x v g (vc-annotate)

The annotation buffer will be displayed, only saying

,----
| fatal: bad revision ''
`----

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:

----------------- 8< --------------------- 8< -------------
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 06474cb..63a7115 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -885,7 +885,7 @@ or BRANCH^ (where \"^\" can be repeated)."
 
 (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)))
+    (vc-git-command buf 'async nil "blame" "--date=iso" "-C" "-C" (if (> (length rev) 0) rev) "--" name)))
 
 (declare-function vc-annotate-convert-time "vc-annotate" (time))
 
-- 
Claudio







^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-27 23:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-24 13:07 bug#14459: git vc-annotate fails in detached HEAD state Claudio Bley
2013-05-24 19:07 ` Dmitry Gutov
2013-05-27  6:41   ` Claudio Bley
2013-05-27 15:10     ` Stefan Monnier
2013-05-27 23:14       ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.