summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-10-13 22:29:23 +0200
committerPhilip Kaludercic <philipk@posteo.net>2022-10-15 17:22:49 +0200
commit1f4b234a5c166552e14f387515642de632a2b1a3 (patch)
tree940afdfd5ff3da89fafb1caf917b7d75eef99830
parent307ad210040251ea0de2e7f453350c4497bda874 (diff)
downloademacs-1f4b234a5c166552e14f387515642de632a2b1a3.tar.gz
* lisp/vc/vc-git.el (vc-git-symbolic-commit): Add argument FORCE
(Bug#57400)
-rw-r--r--lisp/vc/vc-git.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 5d564f3c94d..0eae7dd6b85 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -2030,14 +2030,19 @@ FILE can be nil."
(setq ok nil))))))
(and ok str)))
-(defun vc-git-symbolic-commit (commit)
- "Translate COMMIT string into symbolic form.
-Returns nil if not possible."
+(defun vc-git-symbolic-commit (commit &optional force)
+ "Translate revision string of COMMIT to a symbolic form.
+If the optional argument FORCE is non-nil, the returned value is
+allowed to include revision specifications like \"master~8\"
+\(the 8th parent of the commit currently pointed to by the master
+branch), otherwise such revision specifications are rejected, and
+the function returns nil."
(and commit
(let ((name (with-temp-buffer
(and
(vc-git--out-ok "name-rev" "--name-only" commit)
(goto-char (point-min))
+ (or force (not (looking-at "^.*[~^].*$" t)))
(= (forward-line 2) 1)
(bolp)
(buffer-substring-no-properties (point-min)