From 06706396b27eb1f60acd3cdd45153d1e7679a697 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 23 Oct 2024 10:49:22 +0800 Subject: [PATCH] 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. (cherry picked from commit c259db1d454a27cc79217f4740b1ecdb4bb28114) --- lisp/vc/vc-git.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 6d8cca07e37..e039133ede5 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -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 -- 2.39.5