Skip to content

Commit 67dfb89

Browse files
committed
Merge branch 'jk/bisect-reset-fix'
"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
2 parents 9eec6a1 + daaa03e commit 67dfb89

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

builtin/bisect.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@ static int bisect_reset(const char *commit)
233233
struct strbuf branch = STRBUF_INIT;
234234

235235
if (!commit) {
236-
if (strbuf_read_file(&branch, git_path_bisect_start(), 0) < 1) {
236+
if (!strbuf_read_file(&branch, git_path_bisect_start(), 0))
237237
printf(_("We are not bisecting.\n"));
238-
return 0;
239-
}
240-
strbuf_rtrim(&branch);
238+
else
239+
strbuf_rtrim(&branch);
241240
} else {
242241
struct object_id oid;
243242

@@ -246,7 +245,7 @@ static int bisect_reset(const char *commit)
246245
strbuf_addstr(&branch, commit);
247246
}
248247

249-
if (!ref_exists("BISECT_HEAD")) {
248+
if (branch.len && !ref_exists("BISECT_HEAD")) {
250249
struct child_process cmd = CHILD_PROCESS_INIT;
251250

252251
cmd.git_cmd = 1;

t/t6030-bisect-porcelain.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ test_expect_success 'bisect reset when not bisecting' '
170170
cmp branch.expect branch.output
171171
'
172172

173+
test_expect_success 'bisect reset cleans up even when not bisecting' '
174+
echo garbage >.git/BISECT_LOG &&
175+
git bisect reset &&
176+
test_path_is_missing .git/BISECT_LOG
177+
'
178+
173179
test_expect_success 'bisect reset removes packed refs' '
174180
git bisect reset &&
175181
git bisect start &&

0 commit comments

Comments
 (0)