From: Philip Kaludercic Date: Thu, 13 Oct 2022 20:29:23 +0000 (+0200) Subject: * lisp/vc/vc-git.el (vc-git-symbolic-commit): Add argument FORCE X-Git-Tag: emacs-29.0.90~1616^2~602 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1f4b234a5c166552e14f387515642de632a2b1a3;p=emacs.git * lisp/vc/vc-git.el (vc-git-symbolic-commit): Add argument FORCE (Bug#57400) --- 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)