Merge branch 'jk/bisect-reset-fix' into maint-2.43

"git bisect reset" has been taught to clean up state files and refs
even when BISECT_START file is gone.

* jk/bisect-reset-fix:
  bisect: always clean on reset
This commit is contained in:
Junio C Hamano
2024-02-08 16:22:02 -08:00
2 changed files with 10 additions and 5 deletions

View File

@ -233,10 +233,9 @@ static int bisect_reset(const char *commit)
struct strbuf branch = STRBUF_INIT;
if (!commit) {
if (strbuf_read_file(&branch, git_path_bisect_start(), 0) < 1) {
if (!strbuf_read_file(&branch, git_path_bisect_start(), 0))
printf(_("We are not bisecting.\n"));
return 0;
}
else
strbuf_rtrim(&branch);
} else {
struct object_id oid;
@ -246,7 +245,7 @@ static int bisect_reset(const char *commit)
strbuf_addstr(&branch, commit);
}
if (!ref_exists("BISECT_HEAD")) {
if (branch.len && !ref_exists("BISECT_HEAD")) {
struct child_process cmd = CHILD_PROCESS_INIT;
cmd.git_cmd = 1;

View File

@ -170,6 +170,12 @@ test_expect_success 'bisect reset when not bisecting' '
cmp branch.expect branch.output
'
test_expect_success 'bisect reset cleans up even when not bisecting' '
echo garbage >.git/BISECT_LOG &&
git bisect reset &&
test_path_is_missing .git/BISECT_LOG
'
test_expect_success 'bisect reset removes packed refs' '
git bisect reset &&
git bisect start &&