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#21383: Static revisions in vc-working-revision Date: Tue, 1 Sep 2015 05:11:22 +0300 Message-ID: <55E5094A.3010108@yandex.ru> References: <55E41499.5030501@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1441073545 15325 80.91.229.3 (1 Sep 2015 02:12:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Sep 2015 02:12:25 +0000 (UTC) Cc: 21383@debbugs.gnu.org, Jonathan H To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 01 04:12:14 2015 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 1ZWb3T-000472-Oc for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Sep 2015 04:12:12 +0200 Original-Received: from localhost ([::1]:43476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWb3T-0004Qn-1F for geb-bug-gnu-emacs@m.gmane.org; Mon, 31 Aug 2015 22:12:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWb3P-0004Qd-D2 for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2015 22:12:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWb3K-0007C3-CA for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2015 22:12:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWb3K-0007BT-9D for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2015 22:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZWb3J-0001Sq-Pw for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2015 22:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Sep 2015 02:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21383-submit@debbugs.gnu.org id=B21383.14410734895588 (code B ref 21383); Tue, 01 Sep 2015 02:12:01 +0000 Original-Received: (at 21383) by debbugs.gnu.org; 1 Sep 2015 02:11:29 +0000 Original-Received: from localhost ([127.0.0.1]:44512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWb2m-0001S4-HE for submit@debbugs.gnu.org; Mon, 31 Aug 2015 22:11:28 -0400 Original-Received: from mail-lb0-f170.google.com ([209.85.217.170]:33055) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWb2k-0001Rv-3k for 21383@debbugs.gnu.org; Mon, 31 Aug 2015 22:11:26 -0400 Original-Received: by lbbsx3 with SMTP id sx3so70693143lbb.0 for <21383@debbugs.gnu.org>; Mon, 31 Aug 2015 19:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=LXSXYlr9tVaJG7vZrzrf3xBi9DBuTp46TwwAEsLVuIA=; b=kQV+tvKO4e5ycDiEzEjTEmyA8FKX+6wyzZR7xXYXVLgDXUVMcAJdOvPlBOqUEG+UP9 hmZYRVUep48BlPPuG3RggWfzX18kFidEU+nwVOaXA3ZD8v8KVZcNxRIJhxawtNGTnzwS rexR7onXllOFvmWGLJbUt0biN3ieVqUMnoLc3hPVmKNEDyMtq9/e05gXmlqe4tjrdRiD MUKKYvyTPAaai0ys39wl8jBlT0U3WI60BMogQGySCKgIg245KD7AME2y+e/zV+rT7I6M wsypdJz1k0YRuFYoLF+lSa+Ot2NFaNZunVzcfc1toa9eLuflEa1iwkvnFOEbR9SdKAJO 6DtQ== X-Received: by 10.112.171.68 with SMTP id as4mr11898292lbc.64.1441073485421; Mon, 31 Aug 2015 19:11:25 -0700 (PDT) Original-Received: from [192.168.1.190] ([178.252.127.222]) by smtp.googlemail.com with ESMTPSA id b3sm985501lak.26.2015.08.31.19.11.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 19:11:24 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Thunderbird/40.0 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.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:106028 Archived-At: On 08/31/2015 08:44 PM, Stefan Monnier wrote: > So we need to change vc-git-mode-line-string to put the branch name > in there. Doesn't seem particularly hard. That sounds like a plan. Any misgivings about this patch? diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 9522328..50c6d96 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -248,26 +248,30 @@ matching the resulting Git log output, and KEYWORDS is a list of (vc-git--state-code diff-letter))) (if (vc-git--empty-db-p) 'added 'up-to-date)))) -(defun vc-git-working-revision (file) +(defun vc-git-working-revision (_file) "Git-specific version of `vc-working-revision'." - (let* (process-file-side-effects - (str (vc-git--run-command-string nil "symbolic-ref" "HEAD"))) - (vc-file-setprop file 'vc-git-detached (null str)) - (if str - (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) - (match-string 2 str) - str) - (vc-git--rev-parse "HEAD")))) + (let (process-file-side-effects) + (vc-git--rev-parse "HEAD"))) + +(defun vc-git--symbolic-ref (file) + (or + (vc-file-getprop file 'vc-git-symbolic-ref) + (let* (process-file-side-effects + (str (vc-git--run-command-string nil "symbolic-ref" "HEAD"))) + (vc-file-setprop file 'vc-git-symbolic-ref + (if str + (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) + (match-string 2 str) + str)))))) (defun vc-git-mode-line-string (file) "Return a string for `vc-mode-line' to put in the mode line for FILE." (let* ((rev (vc-working-revision file)) - (detached (vc-file-getprop file 'vc-git-detached)) + (disp-rev (or (vc-git--symbolic-ref file) + (substring rev 0 7))) (def-ml (vc-default-mode-line-string 'Git file)) (help-echo (get-text-property 0 'help-echo def-ml))) - (propertize (if detached - (substring def-ml 0 (- 7 (length rev))) - def-ml) + (propertize (replace-regexp-in-string (concat rev "\\'") disp-rev def-ml t t) 'help-echo (concat help-echo "\nCurrent revision: " rev)))) (cl-defstruct (vc-git-extra-fileinfo