[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 307ad21004 3/5: * lisp/vc/vc-git.el (vc-git--rev-parse): Allow ab
From: |
Philip Kaludercic |
Subject: |
master 307ad21004 3/5: * lisp/vc/vc-git.el (vc-git--rev-parse): Allow abbreviating commits |
Date: |
Sat, 15 Oct 2022 11:23:27 -0400 (EDT) |
branch: master
commit 307ad210040251ea0de2e7f453350c4497bda874
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
* 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)
---
lisp/vc/vc-git.el | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index ea06ccaf87..5d564f3c94 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'."