]> git.ipfire.org Git - thirdparty/git.git/commit - t/t6030-bisect-porcelain.sh
bisect: always clean on reset
authorJeff King <peff@peff.net>
Thu, 7 Dec 2023 06:53:41 +0000 (01:53 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Dec 2023 23:21:31 +0000 (08:21 +0900)
commitdaaa03e54c481b4906b4b6a80d89dbb5a239e509
treea8a20bbd123a42603b2a0ca1ec293451828f91d3
parent0d1bd1dfb37ef25e1911777c94129fc769ffec38
bisect: always clean on reset

Usually "bisect reset" cleans up any refs/bisect/ refs, along with
meta-files like .git/BISECT_LOG. But it only does so after deciding that
a bisection is active, which it does by reading BISECT_START. This is
usually fine, but it's possible to get into a confusing state if the
BISECT_START file is gone, but other cruft is left (this might be due to
a bug, or a system crash, etc).

And since "bisect reset" refuses to do anything in this state, the user
has no easy way to clean up the leftover cruft. While another "bisect
start" would clear the state, in the interim it can be annoying, as
other tools (like our bash prompt code) think we are bisecting, and
for-each-ref output may be polluted with refs/bisect/ entries.

Further adding to the confusion is that running "bisect reset $some_ref"
skips the BISECT_START check. So it never realizes that there's no
bisection active and does the cleanup anyway!

So let's just make sure we always do the cleanup, whether we looked at
BISECT_START or not. If the user doesn't give us a commit to reset to,
we'll still say "We are not bisecting" and skip the call to "git
checkout".

Reported-by: Janik Haag <janik@aq0.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bisect.c
t/t6030-bisect-porcelain.sh