From: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Sixt <j6t@kdbg.org>, Harald Nordgren <haraldnordgren@gmail.com>
Subject: [PATCH v4 0/2] bisect: add --reset-when-found to leave when done
Date: Sat, 01 Aug 2026 09:44:03 +0000 [thread overview]
Message-ID: <pull.2335.v4.git.git.1785577445.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2335.v3.git.git.1784538619.gitgitgadget@gmail.com>
Add a --reset-when-found option to git bisect that resets the bisect session
when culprit is found.
Changes in v4:
* Simplify translation calls.
* Avoid git subshell calls in tests, that can bury errors.
Changes in v3:
* Rename --auto-reset to --reset-when-found, including internal names.
* Defer git bisect run cleanup until captured output is printed and
BISECT_RUN is closed. Drop the open-descriptor preparatory change,
retaining the existing filename-based output handling.
Changes in v2:
* Add option --auto-reset[=<where>] with option to go to final commit as
well as original.
* Refactored tests.
Harald Nordgren (2):
bisect: let bisect_reset() optionally check out quietly
bisect: add --reset-when-found to leave when done
Documentation/git-bisect.adoc | 14 +++-
bisect.c | 2 +
builtin/bisect.c | 148 +++++++++++++++++++++++++++++-----
t/t6030-bisect-porcelain.sh | 121 +++++++++++++++++++++++++++
4 files changed, 264 insertions(+), 21 deletions(-)
base-commit: a97fcc37c2bc6340a8d7ce78dedf227aac4e9aa7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2335%2FHaraldNordgren%2Fbisect-auto-reset-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2335/HaraldNordgren/bisect-auto-reset-v4
Pull-Request: https://github.com/git/git/pull/2335
Range-diff vs v3:
1: 59920c51ae = 1: e39670edf4 bisect: let bisect_reset() optionally check out quietly
2: 542f4b2c80 ! 2: f5f370df1b bisect: add --reset-when-found to leave when done
@@ builtin/bisect.c: static enum bisect_error bisect_start(struct bisect_terms *ter
}
}
+ if (reset_when_found != RESET_WHEN_FOUND_NONE && no_checkout) {
-+ res = error(_("'--reset-when-found' cannot be used with '--no-checkout'"));
++ res = error(_("options '%s' and '%s' cannot be used together"),
++ "--reset-when-found", "--no-checkout");
+ goto finish;
+ }
pathspec_pos = i;
@@ builtin/bisect.c: static int bisect_run(struct bisect_terms *terms, int argc, co
+
+ if (reset_when_found != RESET_WHEN_FOUND_NONE) {
+ if (refs_ref_exists(get_main_ref_store(the_repository), "BISECT_HEAD"))
-+ return error(_("'--reset-when-found' cannot be used with '--no-checkout'"));
++ return error(_("options '%s' and '%s' cannot be used together"),
++ "--reset-when-found", "--no-checkout");
+ write_file(git_path_bisect_reset_when_found(), "%s\n",
+ reset_when_found_mode_name(reset_when_found));
+ argc--;
@@ t/t6030-bisect-porcelain.sh: test_bisect_usage () {
}
+test_bisect_state_file () {
-+ test_path_is_file "$(git rev-parse --git-path "$1")"
++ local file &&
++ file=$(git rev-parse --git-path "$1") &&
++ test_path_is_file "$file"
+}
+
+test_bisect_state_missing () {
-+ test_path_is_missing "$(git rev-parse --git-path "$1")"
++ local file &&
++ file=$(git rev-parse --git-path "$1") &&
++ test_path_is_missing "$file"
+}
+
+bisect_start_and_finish () {
@@ t/t6030-bisect-porcelain.sh: test_expect_success '"git bisect run" simple case'
'
+test_expect_success '"git bisect start --reset-when-found" defaults to original' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ git checkout main &&
+ bisect_start_and_finish --reset-when-found &&
-+ test "$HASH4" = "$(git rev-parse HEAD)" &&
-+ test main = "$(git branch --show-current)" &&
++ actual=$(git rev-parse HEAD) &&
++ test "$HASH4" = "$actual" &&
++ actual=$(git branch --show-current) &&
++ test main = "$actual" &&
+ test_bisect_state_missing BISECT_START &&
+
+ bisect_start_and_finish --reset-when-found=original &&
-+ test "$HASH4" = "$(git rev-parse HEAD)" &&
-+ test main = "$(git branch --show-current)" &&
++ actual=$(git rev-parse HEAD) &&
++ test "$HASH4" = "$actual" &&
++ actual=$(git branch --show-current) &&
++ test main = "$actual" &&
+ test_bisect_state_missing BISECT_START
+'
+
+test_expect_success '"git bisect start --reset-when-found=found" leaves first bad checked out' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ bisect_start_and_finish --reset-when-found=found &&
-+ test "$HASH3" = "$(git rev-parse HEAD)" &&
++ actual=$(git rev-parse HEAD) &&
++ test "$HASH3" = "$actual" &&
+ test_bisect_state_missing BISECT_START
+'
+
+test_expect_success '"git bisect run --reset-when-found" defaults to original' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ bisect_run_reset_when_found --reset-when-found &&
-+ test "$HASH4" = "$(git rev-parse HEAD)" &&
-+ test main = "$(git branch --show-current)" &&
++ actual=$(git rev-parse HEAD) &&
++ test "$HASH4" = "$actual" &&
++ actual=$(git branch --show-current) &&
++ test main = "$actual" &&
+ test_bisect_state_missing BISECT_START
+'
+
+test_expect_success '"git bisect run --reset-when-found=found" leaves first bad checked out' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ bisect_run_reset_when_found --reset-when-found=found &&
-+ test "$HASH3" = "$(git rev-parse HEAD)" &&
++ actual=$(git rev-parse HEAD) &&
++ test "$HASH3" = "$actual" &&
+ test_bisect_state_missing BISECT_START
+'
+
+test_expect_success '--reset-when-found rejects an unknown reset target' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ test_reset_when_found_fails \
+ "invalid value for.*--reset-when-found.*unknown" BISECT_START \
+ git bisect start --reset-when-found=unknown $HASH4 $HASH2 &&
@@ t/t6030-bisect-porcelain.sh: test_expect_success '"git bisect run" simple case'
+test_expect_success '--reset-when-found cannot be used with --no-checkout' '
+ test_when_finished "git bisect reset" &&
+ test_reset_when_found_fails \
-+ "cannot be used with.*--no-checkout" BISECT_START \
++ "options .*--reset-when-found.* and .*--no-checkout.* cannot be used together" BISECT_START \
+ git bisect start --reset-when-found=original --no-checkout $HASH4 $HASH2 &&
+
+ git bisect start --no-checkout $HASH4 $HASH2 &&
+ test_reset_when_found_fails \
-+ "cannot be used with.*--no-checkout" BISECT_RESET_WHEN_FOUND \
++ "options .*--reset-when-found.* and .*--no-checkout.* cannot be used together" BISECT_RESET_WHEN_FOUND \
+ git bisect run --reset-when-found=found true
+'
+
@@ t/t6030-bisect-porcelain.sh: test_expect_success '"git bisect run" simple case'
+'
+
+test_expect_success '--reset-when-found does not leak into a later bisection' '
-+ test_when_finished "git bisect reset; git checkout main" &&
++ test_when_finished "git bisect reset && git checkout main" &&
+ bisect_start_and_finish --reset-when-found &&
+
+ git bisect start $HASH4 $HASH2 &&
--
gitgitgadget
next prev parent reply other threads:[~2026-08-01 9:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 5:35 [PATCH 0/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 1/3] bisect: read run output from the open descriptor Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 2/3] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 3/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
2026-07-16 17:22 ` Junio C Hamano
2026-07-16 21:22 ` Harald Nordgren
2026-07-17 5:00 ` Junio C Hamano
2026-07-17 9:16 ` Harald Nordgren
2026-07-17 16:43 ` Junio C Hamano
2026-07-17 18:27 ` [PATCH v2 0/3] " Harald Nordgren via GitGitGadget
2026-07-17 18:27 ` [PATCH v2 1/3] bisect: read run output from the open descriptor Harald Nordgren via GitGitGadget
2026-07-17 22:42 ` Junio C Hamano
2026-07-18 16:24 ` Johannes Sixt
2026-07-17 18:27 ` [PATCH v2 2/3] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-07-17 18:27 ` [PATCH v2 3/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
2026-07-18 16:18 ` Johannes Sixt
2026-07-20 1:14 ` Junio C Hamano
2026-07-20 9:10 ` [PATCH v3 0/2] " Harald Nordgren via GitGitGadget
2026-07-20 9:10 ` [PATCH v3 1/2] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-07-20 9:10 ` [PATCH v3 2/2] bisect: add --reset-when-found to leave when done Harald Nordgren via GitGitGadget
2026-07-23 9:17 ` Johannes Sixt
2026-07-23 14:27 ` Junio C Hamano
2026-08-01 6:51 ` Harald Nordgren
2026-07-20 17:20 ` [PATCH v3 0/2] bisect: add --auto-reset " Junio C Hamano
2026-08-01 9:44 ` Harald Nordgren via GitGitGadget [this message]
2026-08-01 9:44 ` [PATCH v4 1/2] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-08-01 9:44 ` [PATCH v4 2/2] bisect: add --reset-when-found to leave when done Harald Nordgren via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2335.v4.git.git.1785577445.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=haraldnordgren@gmail.com \
--cc=j6t@kdbg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox