branch: elpa/git-commit
commit faa19075be7b640c1625cd74e6686344835ecb1d
Author: Kyle Meyer <[email protected]>
Commit: Kyle Meyer <[email protected]>

    magit-bisect-run: Restore checks for flipped revs and dirty tree
    
    As of Magit v2.90.0, magit-bisect-start aborts if the revisions are
    flipped or there are uncommitted changes.  magit-bisect-run shared
    those guards at the time because it used magit-bisect-start
    underneath, but f592e367 (magit-bisect-run: Don't start bisect
    asynchronously, 2021-06-20) moved away from magit-bisect-start,
    unintentionally losing the checks.
    
    Restore the checks by extracting them to a shared helper.
    
    Closes #5070.
---
 docs/RelNotes/4.0.0.org |  5 +++++
 lisp/magit-bisect.el    | 22 +++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/docs/RelNotes/4.0.0.org b/docs/RelNotes/4.0.0.org
index 2af6261f64..eb2c13a5b9 100644
--- a/docs/RelNotes/4.0.0.org
+++ b/docs/RelNotes/4.0.0.org
@@ -227,6 +227,11 @@ f9ae2a6306 #4620 magit-blame--make-highlight-overlay: Add 
only to intended line
   incorrectly repeated already applied patches in the list of
   remaining patches.  #5024
 
+- ~magit-bisect-run~ is supposed to abort if there are uncommitted
+  changes or if the revisions are flipped (like ~magit-bisect-start~
+  does), but these checks were unintentionally dropped in Magit
+  v3.1.0.  #5070
+
 10b5407131 magit-diff-highlight-list: Ensure delayed highlighting takes place
 b32521d543 magit-ediff-read-files: Handle renames in one-file logs
 94aca04dc8 magit-module-section: Use correct keymap
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index b52b03bbf4..9421da166f 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -104,15 +104,7 @@ other actions from the bisect transient command (\
   (interactive (if (magit-bisect-in-progress-p)
                    (user-error "Already bisecting")
                  (magit-bisect-start-read-args)))
-  (unless (magit-rev-ancestor-p good bad)
-    (user-error
-     "The %s revision (%s) has to be an ancestor of the %s one (%s)"
-     (or (transient-arg-value "--term-old=" args) "good")
-     good
-     (or (transient-arg-value "--term-new=" args) "bad")
-     bad))
-  (when (magit-anything-modified-p)
-    (user-error "Cannot bisect with uncommitted changes"))
+  (magit-bisect-start--assert bad good args)
   (magit-repository-local-set 'bisect--first-parent
                               (transient-arg-value "--first-parent" args))
   (magit-git-bisect "start" (list args bad good) t))
@@ -130,6 +122,17 @@ other actions from the bisect transient command (\
            bad)
           args)))
 
+(defun magit-bisect-start--assert (bad good args)
+  (unless (magit-rev-ancestor-p good bad)
+    (user-error
+     "The %s revision (%s) has to be an ancestor of the %s one (%s)"
+     (or (transient-arg-value "--term-old=" args) "good")
+     good
+     (or (transient-arg-value "--term-new=" args) "bad")
+     bad))
+  (when (magit-anything-modified-p)
+    (user-error "Cannot bisect with uncommitted changes")))
+
 ;;;###autoload
 (defun magit-bisect-reset ()
   "After bisecting, cleanup bisection state and return to original `HEAD'."
@@ -197,6 +200,7 @@ bisect run'."
                                 (magit-bisect-start-read-args))))
                  (cons (read-shell-command "Bisect shell command: ") args)))
   (when (and bad good)
+    (magit-bisect-start--assert bad good args)
     ;; Avoid `magit-git-bisect' because it's asynchronous, but the
     ;; next `git bisect run' call requires the bisect to be started.
     (magit-with-toplevel

Reply via email to