From: Claudio Bley <claudio.bley@googlemail.com>
To: 14459@debbugs.gnu.org
Subject: bug#14459: git vc-annotate fails in detached HEAD state
Date: Mon, 27 May 2013 08:41:38 +0200 [thread overview]
Message-ID: <87ppwcgc0t.wl%claudio.bley@gmail.com> (raw)
In-Reply-To: <87hahs19iy.fsf@yandex.ru>
At Fri, 24 May 2013 23:07:49 +0400,
Dmitry Gutov wrote:
>
> 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)))
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
next prev parent reply other threads:[~2013-05-27 6:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2013-05-27 15:10 ` Stefan Monnier
2013-05-27 23:14 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppwcgc0t.wl%claudio.bley@gmail.com \
--to=claudio.bley@googlemail.com \
--cc=14459@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).