From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Claudio Bley Newsgroups: gmane.emacs.bugs Subject: bug#14459: git vc-annotate fails in detached HEAD state Date: Mon, 27 May 2013 08:41:38 +0200 Message-ID: <87ppwcgc0t.wl%claudio.bley@gmail.com> References: <87wqqopluu.wl%claudio.bley@gmail.com> <87hahs19iy.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1369636985 14417 80.91.229.3 (27 May 2013 06:43:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 May 2013 06:43:05 +0000 (UTC) To: 14459@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 27 08:43:05 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ugr96-0007DW-Vv for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 08:43:05 +0200 Original-Received: from localhost ([::1]:46539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ugr96-0004ig-Lk for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 02:43:04 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ugr90-0004iQ-9R for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 02:43:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ugr8u-0006Zx-KK for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 02:42:58 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ugr8u-0006YF-FQ for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 02:42:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UgrA2-0002pQ-Je for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 02:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Claudio Bley Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2013 06:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14459 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14459-submit@debbugs.gnu.org id=B14459.136963698410783 (code B ref 14459); Mon, 27 May 2013 06:44:02 +0000 Original-Received: (at 14459) by debbugs.gnu.org; 27 May 2013 06:43:04 +0000 Original-Received: from localhost ([127.0.0.1]:36072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ugr95-0002nr-Id for submit@debbugs.gnu.org; Mon, 27 May 2013 02:43:04 -0400 Original-Received: from mail-bk0-f47.google.com ([209.85.214.47]:46159) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ugr90-0002nI-B6 for 14459@debbugs.gnu.org; Mon, 27 May 2013 02:42:59 -0400 Original-Received: by mail-bk0-f47.google.com with SMTP id jg1so3420225bkc.6 for <14459@debbugs.gnu.org>; Sun, 26 May 2013 23:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:message-id:from:to:subject:in-reply-to:references:user-agent :mail-copies-to:mime-version:content-type; bh=n7uxTGndpvlP+SRFQST+G2RZuaaX7YtM5nGyJMV9210=; b=LgrN2iFxjVM/6oGsKMGJUH0/pzdMdG8gFW17zu7Sq53DufnQG+AqL+LrsEn4XY0ja7 oDF0/RQXb/6vzTdkBzhQ7aZaCEaTOZ/JQvax18pWOYn/gYuzMFUVP1/Cg4PU4xd1L98F Pumu5akIrSBMmPfdPKsdg+zeALRZyEJ0lj7G6Hq+jDttbLv4THWUDDqH1MtMDJxSN6t4 Xfr9fNtxHzYWiw367JvSq81uyF0iyhZBi1Wuk2K25i84SYzzx7y+C7j6IqpU8fnHa/dR qqoSIKkJhSoBm7zUdwf4lXoErwlK6JJpbR9D5HIcYC65jOVSdLGlA+UqCr82Qj3K2+yH PwFg== X-Received: by 10.204.76.205 with SMTP id d13mr2434197bkk.147.1369636901523; Sun, 26 May 2013 23:41:41 -0700 (PDT) Original-Received: from CLAUDIO-PC.localdomain.de (178-24-168-244-dynip.superkabel.de. [178.24.168.244]) by mx.google.com with ESMTPSA id da16sm7749637bkb.2.2013.05.26.23.41.39 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 26 May 2013 23:41:40 -0700 (PDT) In-Reply-To: <87hahs19iy.fsf@yandex.ru> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL/10.8 Emacs/24.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) Mail-Copies-To: never X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74592 Archived-At: 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