git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] bisect: output bisect setup status in bisect log

From
Chris Down <chris@chrisdown.name>
Date
May 6, 2022, 00:52 UTC
Message-ID
<acab8859d02c95750fdbc691ac672c17d5be0291.1651796862.git.chris@chrisdown.name>
In-Reply-To
<cover.1651796862.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    | 25 ++++++++++++++++++++-----
 t/t6030-bisect-porcelain.sh |  9 +++++++--
 2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 9d583f651c..ef75f0a0ce 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -404,6 +404,21 @@ static struct bisect_state bisect_status(const struct bisect_terms *terms)
 	return bs;
 }
 
+__attribute__((format (printf, 1, 2)))
+static void bisect_log_printf(const char *fmt, ...)
+{
+	va_list ap;
+	char buf[1024];
+
+	va_start(ap, fmt);
+	if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0)
+		*buf = '\0';
+	va_end(ap);
+
+	printf("%s", buf);
+	append_to_file(git_path_bisect_log(), "# %s", buf);
+}
+
 static void bisect_print_status(const struct bisect_terms *terms)
 {
 	const struct bisect_state bs = bisect_status(terms);
@@ -413,13 +428,13 @@ static void bisect_print_status(const struct bisect_terms *terms)
 		return;
 
 	if (!bs.nr_good && !bs.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 (bs.nr_good)
-		printf(Q_("status: waiting for bad commit, %d good commit known\n",
-			  "status: waiting for bad commit, %d good commits known\n",
-			  bs.nr_good), bs.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",
+				     bs.nr_good), bs.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 a02587d1a7..d16730a2e2 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -1029,18 +1029,23 @@ 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 | grep "waiting for both good and bad commits" &&
        git bisect good "$HASH1" >output &&
        grep "waiting for bad commit, 1 good commit known" output &&
+       git bisect log | grep "waiting for bad commit, 1 good commit known" &&
        git bisect good "$HASH2" >output &&
-       grep "waiting for bad commit, 2 good commits known" output
+       grep "waiting for bad commit, 2 good commits known" output &&
+       git bisect log | grep "waiting for bad commit, 2 good commits known"
 '
 
 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 | grep "waiting for both good and bad commits" &&
        git bisect bad "$HASH4" >output &&
-       grep -F "waiting for good commit(s), bad commit known" output
+       grep -F "waiting for good commit(s), bad commit known" output &&
+       git bisect log | grep -F "waiting for good commit(s), bad commit known"
 '
 
 test_done
-- 
2.36.0
Previous: Junio C HamanoNext: Taylor Blau
Message 7 of 19 in “bisect: status improvements when bisect is not fully fleshed out”
  1. 0/2 bisect: status improvements when bisect is not fully fleshed outChris Down, May 6, 2022
  2. 1/2 bisect: output state before we are ready to compute bisectionChris Down, May 6, 2022
  3. Taylor BlauMay 6, 2022
  4. Chris DownMay 6, 2022
  5. Junio C HamanoMay 6, 2022
  6. Junio C HamanoMay 6, 2022
  7. 2/2 bisect: output bisect setup status in bisect logChris Down, May 6, 2022
  8. Taylor BlauMay 6, 2022
  9. Chris DownMay 6, 2022
  10. Taylor BlauMay 9, 2022
  11. Junio C HamanoMay 6, 2022
  12. Junio C HamanoMay 6, 2022
  13. Junio C HamanoMay 6, 2022
  14. Taylor BlauMay 9, 2022
  15. Junio C HamanoMay 9, 2022
  16. Taylor BlauMay 9, 2022
  17. Chris DownMay 7, 2022
  18. Junio C HamanoMay 7, 2022
  19. Chris DownMay 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.