branch: elpa/magit
commit fe56c0d10a91d00aed65f831b8435a7224bc7730
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-bisect-start-read-args: Use selected commits if appropriate
Closes #5049.
---
docs/CHANGELOG.4 | 4 ++++
docs/magit.org | 13 +++++++++----
docs/magit.texi | 13 +++++++++----
lisp/magit-bisect.el | 29 ++++++++++++++++++-----------
4 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/docs/CHANGELOG.4 b/docs/CHANGELOG.4
index ed25cf1d02..be38cd6481 100644
--- a/docs/CHANGELOG.4
+++ b/docs/CHANGELOG.4
@@ -47,6 +47,10 @@
- Added new option ~magit-submodule-list-predicate~ and taught
~magit-submodule-list~ to support unpopulated modules. #5077
+- When ~magit-bisect-start~ and ~magit-bisect-run~ are invoked with the
+ region marking a reange of consecutive commit, the commits at the
+ ends are used as the good and bad commits. #5049
+
Bugfixes:
- ~magit-ignore-submodules-p~ didn't return ~nil~ for ~none~.
diff --git a/docs/magit.org b/docs/magit.org
index 661bc7b9a1..f23cb6fc77 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -4132,11 +4132,16 @@ following suffix commands.
Start a bisect session.
Bisecting a bug means to find the commit that introduced it.
+
This command starts such a bisect session by asking for a known
- good commit and a known bad commit. If you're bisecting a change
- that isn't a regression, you can select alternate terms that are
- conceptually more fitting than "bad" and "good", but the infix
- arguments to do so are disabled by default.
+ good commit and a known bad commit. If the region marks a range of
+ commit, where one is an ancestor of the other, then these commits
+ are used as the good and bad commits. Otherwise these starting
+ points are read in the minibuffer.
+
+ If you're bisecting a change that isn't a regression, you can select
+ alternate terms that are conceptually more fitting than "bad" and
+ "good", but the infix arguments to do so are disabled by default.
- Key: B s (magit-bisect-run) ::
diff --git a/docs/magit.texi b/docs/magit.texi
index 307f60905b..2dc5f54e45 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -4871,11 +4871,16 @@ following suffix commands.
Start a bisect session.
Bisecting a bug means to find the commit that introduced it.
+
This command starts such a bisect session by asking for a known
-good commit and a known bad commit. If you're bisecting a change
-that isn't a regression, you can select alternate terms that are
-conceptually more fitting than "bad" and "good", but the infix
-arguments to do so are disabled by default.
+good commit and a known bad commit. If the region marks a range of
+commit, where one is an ancestor of the other, then these commits
+are used as the good and bad commits. Otherwise these starting
+points are read in the minibuffer.
+
+If you're bisecting a change that isn't a regression, you can select
+alternate terms that are conceptually more fitting than "bad" and
+"good", but the infix arguments to do so are disabled by default.
@item @kbd{B s} (@code{magit-bisect-run})
@kindex B s
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 6cc646741a..032d50a83c 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -107,17 +107,24 @@ other actions from the bisect transient command (\
(magit-git-bisect "start" (list args bad good) t))
(defun magit-bisect-start-read-args ()
- (let* ((args (transient-args 'magit-bisect))
- (bad (magit-read-branch-or-commit
- (format "Start bisect with %s revision"
- (or (transient-arg-value "--term-new=" args)
- "bad")))))
- (list bad
- (magit-read-other-branch-or-commit
- (format "%s revision" (or (transient-arg-value "--term-old=" args)
- "Good"))
- bad)
- args)))
+ (let ((args (transient-args 'magit-bisect))
+ (revs (magit-region-values '(commit branch) t)))
+ (or (and revs
+ (let ((a (car revs))
+ (b (last revs)))
+ (cond ((magit-rev-ancestor-p a b) (list b a args))
+ ((magit-rev-ancestor-p b a) (list a b args)))))
+ (let ((bad (magit-read-branch-or-commit
+ (format "Start bisect with %s revision"
+ (or (transient-arg-value "--term-new=" args)
+ "bad")))))
+ (list bad
+ (magit-read-other-branch-or-commit
+ (format "%s revision"
+ (or (transient-arg-value "--term-old=" args)
+ "Good"))
+ bad)
+ args)))))
(defun magit-bisect-start--assert (bad good args)
(unless (magit-git-string "merge-base" bad good)