From e368492108b3dc09c0982f951a7dc00b15e70074 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 25 Oct 2024 11:13:46 +0800 Subject: [PATCH] vc-modify-change-comment: Revert Log View buffer * lisp/vc/vc.el (vc-modify-change-comment): Revert the Log View buffer after modifying the change comment. (cherry picked from commit 9729353ba019d9e7f603515dbf88cbc8807bb120) --- lisp/vc/vc.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index c4b05950229..e9b8dc5c043 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2517,7 +2517,17 @@ the variable `vc-BACKEND-header'." (lambda () (vc-call-backend backend 'log-edit-mode)) (lambda (files comment) (vc-call-backend backend - 'modify-change-comment files rev comment)) + 'modify-change-comment files rev comment) + ;; We are now back in `vc-parent-buffer'. + ;; If this is Log View, then revision IDs might now be + ;; out-of-date, which could be hazardous if the user immediately + ;; tries to use `log-view-modify-change-comment' a second time. + ;; E.g. with Git, `vc-git-modify-change-comment' could create an + ;; "amend!" commit referring to a commit which no longer exists + ;; on the branch, such that it wouldn't be autosquashed. + ;; So refresh the view. + (when (derived-mode-p 'log-view-mode) + (revert-buffer))) nil backend))) ;;;###autoload -- 2.39.2