From: Chris Down <chris@chrisdown.name> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, Johannes Schindelin <johannes.schindelin@gmx.de>, Christian Couder <chriscool@tuxfamily.org>, Taylor Blau <me@ttaylorr.com>, kernel-team@fb.com Subject: [PATCH v3 2/2] bisect: output bisect setup status in bisect log Date: Wed, 11 May 2022 19:00:14 +0100 [thread overview] Message-ID: <83c76401ad2e066bc25cab542214bc3a021afd02.1652291688.git.chris@chrisdown.name> (raw) In-Reply-To: <cover.1652291688.git.chris@chrisdown.name> 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@chrisdown.name> --- 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
next prev parent reply other threads:[~2022-05-11 18:01 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-11 18:00 [PATCH v3 0/2] bisect: status improvements when bisect is not fully fleshed out Chris Down 2022-05-11 18:00 ` [PATCH v3 1/2] bisect: output state before we are ready to compute bisection Chris Down 2022-05-11 18:00 ` Chris Down [this message] 2022-05-11 19:41 ` [PATCH v3 0/2] bisect: status improvements when bisect is not fully fleshed out Junio C Hamano
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=83c76401ad2e066bc25cab542214bc3a021afd02.1652291688.git.chris@chrisdown.name \ --to=chris@chrisdown.name \ --cc=chriscool@tuxfamily.org \ --cc=git@vger.kernel.org \ --cc=gitster@pobox.com \ --cc=johannes.schindelin@gmx.de \ --cc=kernel-team@fb.com \ --cc=me@ttaylorr.com \ --subject='Re: [PATCH v3 2/2] bisect: output bisect setup status in bisect log' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).