GNU bug report logs -
#14459
git vc-annotate fails in detached HEAD state
Previous Next
Reported by: claudio.bley <at> gmail.com (Claudio Bley)
Date: Fri, 24 May 2013 13:38:01 UTC
Severity: normal
Fixed in version 24.4
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14459 in the body.
You can then email your comments to 14459 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14459
; Package
emacs
.
(Fri, 24 May 2013 13:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
claudio.bley <at> gmail.com (Claudio Bley)
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 24 May 2013 13:38:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14459
; Package
emacs
.
(Fri, 24 May 2013 19:09:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 14459 <at> debbugs.gnu.org (full text, mbox):
claudio.bley <at> 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)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14459
; Package
emacs
.
(Mon, 27 May 2013 06:44:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 14459 <at> debbugs.gnu.org (full text, mbox):
At Fri, 24 May 2013 23:07:49 +0400,
Dmitry Gutov wrote:
>
> claudio.bley <at> 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)))
Yes, this is way better than what I've come up with. But shouldn't we
also use the "--short[=n]" option to restrict the length of the
revision string as it is displayed in the modeline? I think 40 chars
is a bit long a text taking up precious space in my modeline.
- Claudio
--
Claudio
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14459
; Package
emacs
.
(Mon, 27 May 2013 15:12:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 14459 <at> debbugs.gnu.org (full text, mbox):
> Yes, this is way better than what I've come up with. But shouldn't we
> also use the "--short[=n]" option to restrict the length of the
> revision string as it is displayed in the modeline? I think 40 chars
> is a bit long a text taking up precious space in my modeline.
The shortening could also be limited to the modeline.
Stefan
Reply sent
to
Dmitry Gutov <dgutov <at> yandex.ru>
:
You have taken responsibility.
(Mon, 27 May 2013 23:16:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
claudio.bley <at> gmail.com (Claudio Bley)
:
bug acknowledged by developer.
(Mon, 27 May 2013 23:16:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 14459-done <at> debbugs.gnu.org (full text, mbox):
Version: 24.4
Claudio Bley <claudio.bley <at> googlemail.com> writes:
> Yes, this is way better than what I've come up with. But shouldn't we
> also use the "--short[=n]" option to restrict the length of the
> revision string as it is displayed in the modeline? I think 40 chars
> is a bit long a text taking up precious space in my modeline.
Thanks, I missed that. And also the fact that
`vc-git-mode-line-string' relied on the non-standard return value (empty
string) to determine whether it should add the appropriate help-echo,
("No current branch (detached HEAD)").
I've checked in a more comprehensive patch, using the same help-echo
format in both cases.
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> The shortening could also be limited to the modeline.
Done. Shortening the mode-line format in `vc-git-mode-line-string'
wasn't an obvious solution for me, but it seems to work well enough.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 25 Jun 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 314 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.