]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-git-modify-change-comment: Check for other autosquashing
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 23 Oct 2024 02:49:22 +0000 (10:49 +0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Oct 2024 05:06:30 +0000 (07:06 +0200)
* 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

index 6d8cca07e377b1ed5bb7e68aca5eb420692a0a66..e039133ede584cbc3ec9b9d38aac57d15ee44ef7 100644 (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