Skip to content

bisect: add --auto-reset to leave when done#2335

Open
HaraldNordgren wants to merge 2 commits into
git:masterfrom
HaraldNordgren:bisect-auto-reset
Open

bisect: add --auto-reset to leave when done#2335
HaraldNordgren wants to merge 2 commits into
git:masterfrom
HaraldNordgren:bisect-auto-reset

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Add a --reset-when-found option to git bisect that resets the bisect session when culprit is found.

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.

cc: Johannes Sixt j6t@kdbg.org

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as pull.2335.git.git.1784180159.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2335/HaraldNordgren/bisect-auto-reset-v1

To fetch this version to local tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v1

Comment thread Documentation/git-bisect.adoc
@HaraldNordgren
HaraldNordgren force-pushed the bisect-auto-reset branch 10 times, most recently from 20b92e5 to 34d9c97 Compare July 17, 2026 17:14

@Anjalo133 Anjalo133 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as pull.2335.v2.git.git.1784312854.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2335/HaraldNordgren/bisect-auto-reset-v2

To fetch this version to local tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v2

Comment thread builtin/bisect.c
Comment thread Documentation/git-bisect.adoc
@gitgitgadget-git

Copy link
Copy Markdown

User Johannes Sixt <j6t@kdbg.org> has been added to the cc: list.

Comment thread builtin/bisect.c
Add a "quiet" parameter to bisect_reset() that passes "--quiet" to the
checkout restoring the original HEAD, suppressing its progress and
branch-status output.

No caller sets the flag yet, so behavior is unchanged.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
When a bisection finishes, "git bisect" reports the first bad commit
but leaves the session active until "git bisect reset" is run by hand.

Add a "--reset-when-found[=<where>]" option, accepted by both "git
bisect start" and "git bisect run", that resets as soon as the first
bad commit is found. The "original" value returns to the commit checked
out before "git bisect start", while "found" leaves the first bad commit
checked out; omitting the value defaults to "original".

Persist the selected target in a BISECT_RESET_WHEN_FOUND state file
and perform the reset quietly.

For "git bisect run", defer the reset until after the captured output
is printed and BISECT_RUN is closed. This lets cleanup remove the file
on systems that cannot unlink an open file.

Reject this option together with "--no-checkout", since that mode must
not check out either target.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
@gitgitgadget-git

Copy link
Copy Markdown

This branch is now known as hn/bisect-auto-reset.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via ce18179.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "New Topics" section about the branch hn/bisect-auto-reset on the Git mailing list:

The 'git bisect' command has been taught a '--auto-reset[=<where>]'
option that tells the command to automatically run 'git bisect reset'
to jump back to the original state or to the found culprit.

Waiting for response.
cf. <1139ae20-f08b-4cf2-b779-42328831e13e@kdbg.org>
cf. <b79a479b-d279-4ac9-a368-6eb8edfed937@kdbg.org>
source: <pull.2335.v2.git.git.1784312854.gitgitgadget@gmail.com>

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as pull.2335.v3.git.git.1784538619.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2335/HaraldNordgren/bisect-auto-reset-v3

To fetch this version to local tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v3:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2335/HaraldNordgren/bisect-auto-reset-v3

@gitgitgadget-git

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Add a --reset-when-found option to git bisect that resets the bisect session
> when culprit is found.
>
> 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.

The range-diff looks very busy, but it mostly looks like a fallout
caused by the renaming of the option and internal functions and enum
to match the updated name.

Looking good.  Is everybody happy with this version?  If so I'll
mark the topic for 'next' soonish.

Thanks.

@gitgitgadget-git

Copy link
Copy Markdown

This branch is now known as hn/bisect-reset-when-found.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into next via 1dc394a.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/bisect-reset-when-found on the Git mailing list:

The 'git bisect' command has been taught a
'--reset-when-found[=<where>]' option that tells the command to
automatically run 'git bisect reset' to jump back to the original
state or to the found culprit.

Will merge to 'master'.
cf. <xmqqldb5d1d9.fsf@gitster.g>
source: <pull.2335.v3.git.git.1784538619.gitgitgadget@gmail.com>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants