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

Re: [PATCH] bisect: add --force flag to force checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 16, 2024, 22:30 UTC
Message-ID
<xmqqmst4ykqh.fsf@gitster.g>
In-Reply-To
<pull.1641.git.git.1705302307639.gitgitgadget@gmail.com>
"Kevin Wang via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> From: Kevin Wang <kevmo314@gmail.com>
>
> Adds a `--force`/`-f` flag to `git bisect good/bad` and `git bisect run` to
> force a checkout. Currently, if the repository state adds any local changes
> the user must manually reset the repository state before moving to the next
> bisection step. This can happen with package lock files or log output data,
> for example. With this change, a developer can run `git bisect run --force`
> to automatically reset the repository state after each evaluation. The flag
> is also supported as `git bisect (good|bad) --force` as well.
The usual way to compose a log message is to
 - Give an observation on how the current system work in the present
   tense (so no need to say "Currently X is Y", just "X is Y"), and
   discuss what you perceive as a problem in it.
 - Propose a solution (optional---often, problem description
   trivially leads to an obvious solution in reader's minds).
 - Give commands to the make codebase "like so".
in this order.

To those who have been intimately following the discussion, it often is understandable without both, but we are not writing for those who review the patches. We are writing for future readers who are not aware of the review discussion we have on list, so we should give something to prepare them by setting the stage and stating the objective first, before going into how the patch solved it.

Having said all that.

I highly doubt that this patch is a good idea. If your "bisect run" script needs to update something in the working tree before it runs some test, the script is in a much better place than Git, which is unaware of what your run script is doing, to prepare the working tree into pristine state. The best Git would be able to do would be to "reset --hard", but that will lose local modifications that are deliberately there and has nothing to do with what your run script did.

Adding some description to the documentation of "bisect run" and teaching readers a common trick of structuring their run script better might be a more productive approach, I would have to say. For example, when I bisect some old code, I may have to apply a temporary patch to some of the sources to get them compile with more recent compilers (I usually do this with a cherry-picking of a local fixup). So my "bisect run" script might go like so:

    #!/bin/sh
    # bisect run
    git apply local-fixup || exit 125
    make test
    status=$?
    make distclean
    git apply -R local-fixup || exit 125
    exit $status
That is, I'd apply some local fix-up to the working tree files
before running tests, and once done, I revert the local fix-up
and exit from the run script with the exit status of the test
I wanted to perform.
    
This way, I can keep other local changes (things like changes to
documentation files that I am working on, which has nothing to do
with the problem I am bisecting but I know they do not interfere)
without wiping them away with a sledgehammer "reset --hard".  Your
"bisect good/bad -f" sounds like the sledgehammer approach to me.
Thanks.
Previous: Kevin Wang via GitGitGadget
Message 2 of 2 in “bisect: add --force flag to force checkout”
  1. bisect: add --force flag to force checkoutKevin Wang via GitGitGadget, Jan 15, 2024
  2. Junio C HamanoJan 16, 2024

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.