summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-git.el
diff options
context:
space:
mode:
authorK. Handa <handa@gnu.org>2015-09-02 18:28:54 +0900
committerK. Handa <handa@gnu.org>2015-09-02 18:28:54 +0900
commite7b62736aade24620c8ba6fa6bd467d017f16ee0 (patch)
treed00a2203437a168b2414c6b73afc00a88d90b4b1 /lisp/vc/vc-git.el
parentae08d073d7e2738580341534adc3c5924dc76860 (diff)
parent30866274e21c5f0a1c5f60cfe290743e7d482349 (diff)
downloademacs-e7b62736aade24620c8ba6fa6bd467d017f16ee0.tar.gz
emacs-e7b62736aade24620c8ba6fa6bd467d017f16ee0.tar.bz2
emacs-e7b62736aade24620c8ba6fa6bd467d017f16ee0.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'lisp/vc/vc-git.el')
-rw-r--r--lisp/vc/vc-git.el30
1 files changed, 17 insertions, 13 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 9522328cae8..50c6d96e911 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