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 <chris@xxxxxxxxxxxxxx> --- builtin/bisect--helper.c | 26 +++++++++++++++++++++----- t/t6030-bisect-porcelain.sh | 10 ++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index fa8024a864..e358e3dd5b 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -400,6 +400,22 @@ static void bisect_status(struct bisect_state *state, free(bad_ref); } +__attribute__((format (printf, 1, 2))) +static void bisect_log_printf(const char *fmt, ...) +{ + struct strbuf buf = STRBUF_INIT; + va_list ap; + + va_start(ap, fmt); + strbuf_vaddf(&buf, fmt, ap); + va_end(ap); + + printf("%s", buf.buf); + append_to_file(git_path_bisect_log(), "# %s", buf.buf); + + strbuf_release(&buf); +} + static void bisect_print_status(const struct bisect_terms *terms) { struct bisect_state state = { 0 }; @@ -411,13 +427,13 @@ static void bisect_print_status(const struct bisect_terms *terms) return; if (!state.nr_good && !state.nr_bad) - printf(_("status: waiting for both good and bad commits\n")); + bisect_log_printf(_("status: waiting for both good and bad commits\n")); else if (state.nr_good) - printf(Q_("status: waiting for bad commit, %d good commit known\n", - "status: waiting for bad commit, %d good commits known\n", - state.nr_good), state.nr_good); + bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n", + "status: waiting for bad commit, %d good commits known\n", + state.nr_good), state.nr_good); else - printf(_("status: waiting for good commit(s), bad commit known\n")); + bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n")); } static int bisect_next_check(const struct bisect_terms *terms, diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 686f6d5c7f..83931d482f 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -1029,9 +1029,15 @@ test_expect_success 'bisect state output with multiple good commits' ' git bisect reset && git bisect start >output && grep "waiting for both good and bad commits" output && + git bisect log >output && + grep "waiting for both good and bad commits" output && git bisect good "$HASH1" >output && grep "waiting for bad commit, 1 good commit known" output && + git bisect log >output && + grep "waiting for bad commit, 1 good commit known" output && git bisect good "$HASH2" >output && + grep "waiting for bad commit, 2 good commits known" output && + git bisect log >output && grep "waiting for bad commit, 2 good commits known" output ' @@ -1039,7 +1045,11 @@ test_expect_success 'bisect state output with bad commit' ' git bisect reset && git bisect start >output && grep "waiting for both good and bad commits" output && + git bisect log >output && + grep "waiting for both good and bad commits" output && git bisect bad "$HASH4" >output && + grep -F "waiting for good commit(s), bad commit known" output && + git bisect log >output && grep -F "waiting for good commit(s), bad commit known" output ' -- 2.36.0