From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#14459: git vc-annotate fails in detached HEAD state Date: Fri, 24 May 2013 23:07:49 +0400 Message-ID: <87hahs19iy.fsf@yandex.ru> References: <87wqqopluu.wl%claudio.bley@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369422507 25309 80.91.229.3 (24 May 2013 19:08:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 May 2013 19:08:27 +0000 (UTC) Cc: 14459@debbugs.gnu.org To: claudio.bley@gmail.com (Claudio Bley) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 24 21:08:26 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 1UfxLl-0003z0-Lv for geb-bug-gnu-emacs@m.gmane.org; Fri, 24 May 2013 21:08:25 +0200 Original-Received: from localhost ([::1]:56519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfxLl-0002fF-2h for geb-bug-gnu-emacs@m.gmane.org; Fri, 24 May 2013 15:08:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfxLe-0002f2-0u for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:08:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfxLa-0003xc-VG for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:08:17 -0400 Original-Received: from [140.186.70.43] (port=44181 helo=debbugs.gnu.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfxLa-0003rf-QI for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:08:14 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UfxMM-0002SV-IN for bug-gnu-emacs@gnu.org; Fri, 24 May 2013 15:09:02 -0400 X-Loop: help-debbugs@gnu.org 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: Original-Received: via spool by 14459-submit@debbugs.gnu.org id=B14459.13694225379438 (code B ref 14459); Fri, 24 May 2013 19:09:02 +0000 Original-Received: (at 14459) by debbugs.gnu.org; 24 May 2013 19:08:57 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <87wqqopluu.wl%claudio.bley@gmail.com> (Claudio Bley's message of "Fri, 24 May 2013 15:07:37 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Antivirus: avast! (VPS 130524-0, 24.05.2013), Outbound message X-Antivirus-Status: Clean 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:74531 Archived-At: 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)))