1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

vc-git-modify-change-comment: Check for other autosquashing

* lisp/vc/vc-git.el (vc-git-modify-change-comment): Check that a
rebase with --autosquash won't make any other changes and give
the user a chance to abort.
This commit is contained in:
Sean Whitton 2024-10-23 10:49:22 +08:00
parent 87766c88d5
commit c259db1d45

View File

@ -2010,6 +2010,22 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
;; See the description of --fixup in git-commit(1).
(error
"Author: and Date: not supported when modifying existing commits"))
;; Check that a rebase with --autosquash won't make changes
;; other than to REV's change comment. With the prompt here
;; it's okay to assume the user knows what --autosquash is
;; because they've made some squash!/fixup!/amend! commits.
(when
(and (split-string
(with-output-to-string
(vc-git-command standard-output 0 nil
"log" "--oneline" "-E"
"--grep" "^(squash|fixup|amend)! "
(format "%s~1.." rev))))
(not (yes-or-no-p
"Rebase may --autosquash your other squash!/fixup!/amend!; proceed?")))
(user-error "Aborted"))
(when msg-file
(let ((coding-system-for-write
(or coding-system-for-write