From unknown Thu Aug 14 22:21:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14459: git vc-annotate fails in detached HEAD state Resent-From: claudio.bley@gmail.com (Claudio Bley) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 May 2013 13:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14459 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14459@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.136940266919980 (code B ref -1); Fri, 24 May 2013 13:38:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 May 2013 13:37:49 +0000 Received: from localhost ([127.0.0.1]:59987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfsBm-0005CA-Ib for submit@debbugs.gnu.org; Fri, 24 May 2013 09:37:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51191) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfsBh-0005Bh-NQ for submit@debbugs.gnu.org; Fri, 24 May 2013 09:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfsAd-0001Y1-54 for submit@debbugs.gnu.org; Fri, 24 May 2013 09:36:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.6 required=5.0 tests=BAYES_05,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:42261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrpY-000125-4c for submit@debbugs.gnu.org; Fri, 24 May 2013 09:14:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrpW-0002o4-LV for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufrij-00070v-CW for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:07:53 -0400 Received: from plane.gmane.org ([80.91.229.3]:37145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufrij-00070Y-3Y for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:07:45 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ufrih-00051r-Le for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:07:43 +0200 Received: from 178-24-168-244-dynip.superkabel.de ([178.24.168.244]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 15:07:43 +0200 Received: from claudio.bley by 178-24-168-244-dynip.superkabel.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 15:07:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ From: claudio.bley@gmail.com (Claudio Bley) Date: Fri, 24 May 2013 15:07:37 +0200 Lines: 51 Message-ID: <87wqqopluu.wl%claudio.bley@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 178-24-168-244-dynip.superkabel.de 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) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) 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 From unknown Thu Aug 14 22:21:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14459: git vc-annotate fails in detached HEAD state Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 May 2013 19:09: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: To: claudio.bley@gmail.com (Claudio Bley) Cc: 14459@debbugs.gnu.org Received: via spool by 14459-submit@debbugs.gnu.org id=B14459.13694225379438 (code B ref 14459); Fri, 24 May 2013 19:09:02 +0000 Received: (at 14459) by debbugs.gnu.org; 24 May 2013 19:08:57 +0000 Received: from localhost ([127.0.0.1]:60772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfxMG-0002SB-Qo for submit@debbugs.gnu.org; Fri, 24 May 2013 15:08:57 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:44199) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfxMF-0002Ry-2R for 14459@debbugs.gnu.org; Fri, 24 May 2013 15:08:55 -0400 Received: by mail-la0-f53.google.com with SMTP id ea20so4855016lab.12 for <14459@debbugs.gnu.org>; Fri, 24 May 2013 12:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:x-antivirus:x-antivirus-status; bh=xLd/CP6xnzImGilw414ZEW4H0exK5f/zjI6kZJTzC3k=; b=B8jgct30Jj/9nwPnDc00ObV4tH/vwC/uiHDRAFh5Xr/uSibb8TA6L0Dj5ZtTM9M+zo VivNlZ9z0XA4SLXwdXilBJnPFu4/V3APt/kd6WC3nuRTOc+cwV8h0bTfQrq5xhZaVtGa O/Cdfw8pBbEI0yGMkhliY1nevLk/DKKmJyYyLfBXkW6CHnI113/3JxAPlPKRU1xkukPu c/nF3wf33gUuYqOzksMOe2EvTr3mCDQzE/RJSuomTeqDaf9B5s7Ni0lqhA6is5bpSu8T 3u0SMKAAUr6XbCSlPW4g1v6uIQqSA7XTGf2ysAKo9RFPpdXfPwuI62YP9o/7Zmyyx7qY 5nxQ== X-Received: by 10.112.190.73 with SMTP id go9mr9583912lbc.43.1369422471932; Fri, 24 May 2013 12:07:51 -0700 (PDT) Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id w20sm12221lbi.14.2013.05.24.12.07.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 May 2013 12:07:50 -0700 (PDT) From: Dmitry Gutov References: <87wqqopluu.wl%claudio.bley@gmail.com> Date: Fri, 24 May 2013 23:07:49 +0400 In-Reply-To: <87wqqopluu.wl%claudio.bley@gmail.com> (Claudio Bley's message of "Fri, 24 May 2013 15:07:37 +0200") Message-ID: <87hahs19iy.fsf@yandex.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Antivirus: avast! (VPS 130524-0, 24.05.2013), Outbound message X-Antivirus-Status: Clean X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) 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))) From unknown Thu Aug 14 22:21:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14459: git vc-annotate fails in detached HEAD state 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: To: 14459@debbugs.gnu.org Received: via spool by 14459-submit@debbugs.gnu.org id=B14459.136963698410783 (code B ref 14459); Mon, 27 May 2013 06:44:02 +0000 Received: (at 14459) by debbugs.gnu.org; 27 May 2013 06:43:04 +0000 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 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 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) 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) Date: Mon, 27 May 2013 08:41:38 +0200 Message-ID: <87ppwcgc0t.wl%claudio.bley@gmail.com> From: Claudio Bley In-Reply-To: <87hahs19iy.fsf@yandex.ru> References: <87wqqopluu.wl%claudio.bley@gmail.com> <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 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) 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 From unknown Thu Aug 14 22:21:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14459: git vc-annotate fails in detached HEAD state Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2013 15:12:01 +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: To: 14459@debbugs.gnu.org Received: via spool by 14459-submit@debbugs.gnu.org id=B14459.136966750019778 (code B ref 14459); Mon, 27 May 2013 15:12:01 +0000 Received: (at 14459) by debbugs.gnu.org; 27 May 2013 15:11:40 +0000 Received: from localhost ([127.0.0.1]:36615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ugz5H-00058r-Hg for submit@debbugs.gnu.org; Mon, 27 May 2013 11:11:39 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:19018) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ugz5F-00058G-SM for 14459@debbugs.gnu.org; Mon, 27 May 2013 11:11:38 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCpOt/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjRlIgykDpHqBXoMTgUo X-IPAS-Result: Av4EABK/CFFMCpOt/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjRlIgykDpHqBXoMTgUo X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="14609550" Received: from 76-10-147-173.dsl.teksavvy.com (HELO pastel.home) ([76.10.147.173]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 27 May 2013 11:10:11 -0400 Received: by pastel.home (Postfix, from userid 20848) id A9B3367ACB; Mon, 27 May 2013 11:10:15 -0400 (EDT) From: Stefan Monnier Message-ID: References: <87wqqopluu.wl%claudio.bley@gmail.com> <87hahs19iy.fsf@yandex.ru> <87ppwcgc0t.wl%claudio.bley@gmail.com> Date: Mon, 27 May 2013 11:10:15 -0400 In-Reply-To: <87ppwcgc0t.wl%claudio.bley@gmail.com> (Claudio Bley's message of "Mon, 27 May 2013 08:41:38 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > 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 From unknown Thu Aug 14 22:21:36 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: claudio.bley@gmail.com (Claudio Bley) Subject: bug#14459: closed (Re: bug#14459: git vc-annotate fails in detached HEAD state) Message-ID: References: <87bo7w583n.fsf@yandex.ru> <87wqqopluu.wl%claudio.bley@gmail.com> X-Gnu-PR-Message: they-closed 14459 X-Gnu-PR-Package: emacs Reply-To: 14459@debbugs.gnu.org Date: Mon, 27 May 2013 23:16:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1369696562-16824-1" This is a multi-part message in MIME format... ------------=_1369696562-16824-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14459: git vc-annotate fails in detached HEAD state which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14459@debbugs.gnu.org. --=20 14459: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14459 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1369696562-16824-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14459-done) by debbugs.gnu.org; 27 May 2013 23:15:31 +0000 Received: from localhost ([127.0.0.1]:36906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uh6dX-0004Lz-3F for submit@debbugs.gnu.org; Mon, 27 May 2013 19:15:31 -0400 Received: from mail-la0-f41.google.com ([209.85.215.41]:54921) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uh6dU-0004Lg-Lw for 14459-done@debbugs.gnu.org; Mon, 27 May 2013 19:15:30 -0400 Received: by mail-la0-f41.google.com with SMTP id ee20so6889087lab.14 for <14459-done@debbugs.gnu.org>; Mon, 27 May 2013 16:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:x-antivirus:x-antivirus-status; bh=km1a2aSeSDxns+nG7r3Nx+jpk69fxwNLBByzm7RsMNc=; b=j3Z9bGL6jGBcUZQ1mblwWSy3PzP8kkzqQgLDsaNU2p4UW08Zw/76OJhxt5Cv0KNkLc oQQqnRv46c/vmZfWy7yYLeEHYl2Nxhf4TszEZWDoAnRdIS2xWZC1YGava6/ZMeZYPGoy Zj7Gvi9z5cGHFR/l4Xh+5RSNQ0WV4zMIb47NbVEaFsIIWAD0juMBp9to99gyuiNPm8Cg nJuBxuLbWbD1nJkzYeEjkMi3h/Ja6+6u9nBRxgUQoadyruCiHuOAK8AZ+H/gJLNuAd8r qr3CX5t9KSu8i0tKdlDmvW4MekDKP2IqCFeWLsDZeNN/ebBwXygH4XJW1GrmJ4VWFIcr h/5g== X-Received: by 10.112.181.163 with SMTP id dx3mr15074002lbc.126.1369696447751; Mon, 27 May 2013 16:14:07 -0700 (PDT) Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id t4sm12319201lbe.7.2013.05.27.16.14.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 16:14:06 -0700 (PDT) From: Dmitry Gutov To: Stefan Monnier Subject: Re: bug#14459: git vc-annotate fails in detached HEAD state References: <87wqqopluu.wl%claudio.bley@gmail.com> <87hahs19iy.fsf@yandex.ru> <87ppwcgc0t.wl%claudio.bley@gmail.com> Date: Tue, 28 May 2013 03:14:04 +0400 In-Reply-To: (Stefan Monnier's message of "Mon, 27 May 2013 11:10:15 -0400") Message-ID: <87bo7w583n.fsf@yandex.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Antivirus: avast! (VPS 130527-1, 28.05.2013), Outbound message X-Antivirus-Status: Clean X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 14459-done Cc: 14459-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Version: 24.4 Claudio Bley 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 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. ------------=_1369696562-16824-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 24 May 2013 13:37:49 +0000 Received: from localhost ([127.0.0.1]:59987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfsBm-0005CA-Ib for submit@debbugs.gnu.org; Fri, 24 May 2013 09:37:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51191) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfsBh-0005Bh-NQ for submit@debbugs.gnu.org; Fri, 24 May 2013 09:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfsAd-0001Y1-54 for submit@debbugs.gnu.org; Fri, 24 May 2013 09:36:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.6 required=5.0 tests=BAYES_05,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:42261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrpY-000125-4c for submit@debbugs.gnu.org; Fri, 24 May 2013 09:14:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrpW-0002o4-LV for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufrij-00070v-CW for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:07:53 -0400 Received: from plane.gmane.org ([80.91.229.3]:37145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufrij-00070Y-3Y for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 09:07:45 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ufrih-00051r-Le for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:07:43 +0200 Received: from 178-24-168-244-dynip.superkabel.de ([178.24.168.244]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 15:07:43 +0200 Received: from claudio.bley by 178-24-168-244-dynip.superkabel.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 15:07:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: claudio.bley@gmail.com (Claudio Bley) Subject: git vc-annotate fails in detached HEAD state Date: Fri, 24 May 2013 15:07:37 +0200 Lines: 51 Message-ID: <87wqqopluu.wl%claudio.bley@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 178-24-168-244-dynip.superkabel.de User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) 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 ------------=_1369696562-16824-1--