diff options
| -rw-r--r-- | builtin/bisect.c | 9 | ||||
| -rwxr-xr-x | t/t6030-bisect-porcelain.sh | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/builtin/bisect.c b/builtin/bisect.c index 7301740267..0bcaadc658 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -227,11 +227,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; @@ -240,7 +239,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 3ba4fdf615..c07776810a 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -147,6 +147,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 && |
