Thread (1 message) 1 message, 1 author, 2024-01-16

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

From: Junio C Hamano <hidden>
Date: 2024-01-16 22:30:36

"Kevin Wang via GitGitGadget" [off-list ref] writes:
From: Kevin Wang <redacted>

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help