Skip to content

Commit f11046e

Browse files
cdowngitster
authored andcommitted
bisect: output bisect setup status in bisect log
This allows seeing the current intermediate status without adding a new good or bad commit: $ git bisect log | tail -1 # status: waiting for bad commit, 1 good commit known Signed-off-by: Chris Down <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0cf1def commit f11046e

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

builtin/bisect--helper.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,22 @@ static void bisect_status(struct bisect_state *state,
400400
free(bad_ref);
401401
}
402402

403+
__attribute__((format (printf, 1, 2)))
404+
static void bisect_log_printf(const char *fmt, ...)
405+
{
406+
struct strbuf buf = STRBUF_INIT;
407+
va_list ap;
408+
409+
va_start(ap, fmt);
410+
strbuf_vaddf(&buf, fmt, ap);
411+
va_end(ap);
412+
413+
printf("%s", buf.buf);
414+
append_to_file(git_path_bisect_log(), "# %s", buf.buf);
415+
416+
strbuf_release(&buf);
417+
}
418+
403419
static void bisect_print_status(const struct bisect_terms *terms)
404420
{
405421
struct bisect_state state = { 0 };
@@ -411,13 +427,13 @@ static void bisect_print_status(const struct bisect_terms *terms)
411427
return;
412428

413429
if (!state.nr_good && !state.nr_bad)
414-
printf(_("status: waiting for both good and bad commits\n"));
430+
bisect_log_printf(_("status: waiting for both good and bad commits\n"));
415431
else if (state.nr_good)
416-
printf(Q_("status: waiting for bad commit, %d good commit known\n",
417-
"status: waiting for bad commit, %d good commits known\n",
418-
state.nr_good), state.nr_good);
432+
bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n",
433+
"status: waiting for bad commit, %d good commits known\n",
434+
state.nr_good), state.nr_good);
419435
else
420-
printf(_("status: waiting for good commit(s), bad commit known\n"));
436+
bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n"));
421437
}
422438

423439
static int bisect_next_check(const struct bisect_terms *terms,

t/t6030-bisect-porcelain.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,17 +1029,27 @@ test_expect_success 'bisect state output with multiple good commits' '
10291029
git bisect reset &&
10301030
git bisect start >output &&
10311031
grep "waiting for both good and bad commits" output &&
1032+
git bisect log >output &&
1033+
grep "waiting for both good and bad commits" output &&
10321034
git bisect good "$HASH1" >output &&
10331035
grep "waiting for bad commit, 1 good commit known" output &&
1036+
git bisect log >output &&
1037+
grep "waiting for bad commit, 1 good commit known" output &&
10341038
git bisect good "$HASH2" >output &&
1039+
grep "waiting for bad commit, 2 good commits known" output &&
1040+
git bisect log >output &&
10351041
grep "waiting for bad commit, 2 good commits known" output
10361042
'
10371043

10381044
test_expect_success 'bisect state output with bad commit' '
10391045
git bisect reset &&
10401046
git bisect start >output &&
10411047
grep "waiting for both good and bad commits" output &&
1048+
git bisect log >output &&
1049+
grep "waiting for both good and bad commits" output &&
10421050
git bisect bad "$HASH4" >output &&
1051+
grep -F "waiting for good commit(s), bad commit known" output &&
1052+
git bisect log >output &&
10431053
grep -F "waiting for good commit(s), bad commit known" output
10441054
'
10451055

0 commit comments

Comments
 (0)