aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-02-08 16:22:02 -0800
committerJunio C Hamano <gitster@pobox.com>2024-02-08 16:22:03 -0800
commit5baedc68b02c1b43b307d436edac702ac3e7b89d (patch)
tree82a1ed4a982fda712c2fb9395cd24ae7bd037b17
parent19fa15fb2d8d002ce382901fa7b31de2853627bd (diff)
parentdaaa03e54c481b4906b4b6a80d89dbb5a239e509 (diff)
downloadgit-5baedc68b02c1b43b307d436edac702ac3e7b89d.tar.gz
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
-rw-r--r--builtin/bisect.c9
-rwxr-xr-xt/t6030-bisect-porcelain.sh6
2 files changed, 10 insertions, 5 deletions
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 35938b05fd..c5565686bf 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -233,11 +233,10 @@ 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;
- }
- strbuf_rtrim(&branch);
+ 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;
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 2a5b7d8379..7b24d1684e 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -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 &&