summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-git.el
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-10-11 21:11:20 +0200
committerPhilip Kaludercic <philipk@posteo.net>2022-10-15 17:22:49 +0200
commit307ad210040251ea0de2e7f453350c4497bda874 (patch)
tree301400079d398f7552bf1c26667bf5f002d3c093 /lisp/vc/vc-git.el
parent5fc064f14c0e76bf15b7528ef6ef3771ad169aba (diff)
downloademacs-307ad210040251ea0de2e7f453350c4497bda874.tar.gz
* lisp/vc/vc-git.el (vc-git--rev-parse): Allow abbreviating commits
* lisp/vc/vc-git.el (vc-git-working-revision): Use abbreviated comment references. (Bug#57400)
Diffstat (limited to 'lisp/vc/vc-git.el')
-rw-r--r--lisp/vc/vc-git.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index ea06ccaf870..5d564f3c94d 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -373,8 +373,9 @@ in the order given by `git status'."
(defun vc-git-working-revision (_file)
"Git-specific version of `vc-working-revision'."
- (let (process-file-side-effects)
- (vc-git--rev-parse "HEAD")))
+ (let* ((process-file-side-effects nil)
+ (commit (vc-git--rev-parse "HEAD" t)))
+ (or (vc-git-symbolic-commit commit) commit)))
(defun vc-git--symbolic-ref (file)
(or
@@ -1674,11 +1675,15 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
;; does not (and cannot) quote.
(vc-git--rev-parse (concat rev "~1"))))
-(defun vc-git--rev-parse (rev)
+(defun vc-git--rev-parse (rev &optional short)
(with-temp-buffer
(and
- (vc-git--out-ok "rev-parse" rev)
- (buffer-substring-no-properties (point-min) (+ (point-min) 40)))))
+ (if short
+ (vc-git--out-ok "rev-parse" "--short" rev)
+ (vc-git--out-ok "rev-parse" rev))
+ (string-trim-right
+ (buffer-substring-no-properties (point-min) (min (+ (point-min) 40)
+ (point-max)))))))
(defun vc-git-next-revision (file rev)
"Git-specific version of `vc-next-revision'."