git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 2/2] bisect: add --reset-when-found to leave when done

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 1, 2026, 21:40 UTC
Message-ID
<xmqqo6fl7c4w.fsf@gitster.g>
In-Reply-To
<xmqqwlu97h1k.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> The defer_reset arrangement looks somewhat ugly even though what it
> achieves may be a worthy thing to do.  Is the only code path that
> passes defer_reset==true down the call chain the bisect_run()
> codepath, to give that single caller a chance to close files that
> bisect_reset() would remove by calling bisect_clean_state()?
>
> I am wondering if the result of solving it slightly differently may
> give us cleaner and easier to follow code, namely, we stop calling
> bisect_clean_state() from bisect_reset().  Of course you would need
> to find different place to call bisect_clean_state() to compensate,
> if we go that route, but how many code paths do we have that depends
> on bisect_reset() calling biesct_clean_state()?
Conceptually, what you want out of this new feature is:
    Please run "git bisect <anything>" normally.  Make sure you
    notice when the command completed and found the culprit, And
    when you notice it, run "git bisect reset" (or "git bisect reset
    <oid-of-bad-commit>").

Stepping back even further, shouldn't this be doable *a* *lot* simpler, given that existing code does not locally exit(0)? Wouldn't it be the matter of

 - Add --reset-when-finished option parsing to the main command and
   the subcommands that want to parse it.
 - Make sure all indivudual cmd_bisect__<subcommand> returns the
   result code, instead of calling exit(), and the result code
   includes those INTERNAL ones.
 - Tweak bisect_next_all() to report the found commit when it
   returns BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND.  Perhaps
   bisect_next() can leave it in a file-scope static variable.
 - Instead of doing
	return is_bisect_success(res) ? 0 : -res;
   at the end of cmd_bisect(), if "--reset-when-finished" is in
   effect, also react to BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND and
   use the commit bisect_next() received from bisect_next_all() as
   needed and do what bisect_reset() does.  Presumably at that
   point, files that are problematic on Windows would all already
   been closed, right?

That way, almost all the changes needed to cmd_bisect__<subcommand> and below will be pure clean-up changes.

Hmm?
Previous: Junio C HamanoNext: Harald Nordgren via GitGitGadget
Message 30 of 42 in “bisect: add --auto-reset to leave when done”
  1. 0/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 16, 2026
  2. 1/3 bisect: read run output from the open descriptorHarald Nordgren via GitGitGadget, Jul 16, 2026
  3. 2/3 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 16, 2026
  4. 3/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 16, 2026
  5. Junio C HamanoJul 16, 2026
  6. Harald NordgrenJul 16, 2026
  7. Junio C HamanoJul 17, 2026
  8. Harald NordgrenJul 17, 2026
  9. Junio C HamanoJul 17, 2026
  10. 0/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 17, 2026
  11. 1/3 bisect: read run output from the open descriptorHarald Nordgren via GitGitGadget, Jul 17, 2026
  12. Junio C HamanoJul 17, 2026
  13. Johannes SixtJul 18, 2026
  14. 2/3 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 17, 2026
  15. 3/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 17, 2026
  16. Johannes SixtJul 18, 2026
  17. Junio C HamanoJul 20, 2026
  18. 0/2 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 20, 2026
  19. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 20, 2026
  20. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Jul 20, 2026
  21. Johannes SixtJul 23, 2026
  22. Junio C HamanoJul 23, 2026
  23. Harald NordgrenAug 1, 2026
  24. Junio C HamanoJul 20, 2026
  25. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 1, 2026
  26. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 1, 2026
  27. Junio C HamanoAug 1, 2026
  28. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 1, 2026
  29. Junio C HamanoAug 1, 2026
  30. Junio C HamanoAug 1, 2026
  31. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  32. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 2, 2026
  33. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  34. Junio C HamanoAug 2, 2026
  35. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  36. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 2, 2026
  37. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  38. Junio C HamanoAug 3, 2026
  39. Harald NordgrenAug 6, 2026
  40. Junio C HamanoAug 6, 2026
  41. Harald NordgrenAug 6, 2026
  42. Junio C HamanoAug 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.