From 1f4b234a5c166552e14f387515642de632a2b1a3 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 13 Oct 2022 22:29:23 +0200 Subject: [PATCH] * lisp/vc/vc-git.el (vc-git-symbolic-commit): Add argument FORCE (Bug#57400) --- lisp/vc/vc-git.el | 11 ++++++++--- 1 file 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) -- 2.39.5