]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-modify-change-comment: Revert Log View buffer
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 25 Oct 2024 03:13:46 +0000 (11:13 +0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Oct 2024 06:31:53 +0000 (08:31 +0200)
* 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

index c4b0595022959763578d69ab062ed686325d383a..e9b8dc5c0437d099545a3da2c781402016ff291c 100644 (file)
@@ -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