bisect: use selected alternate terms in status output

Alternate bisect terms are helpful when the terms "good" and "bad" are confusing such as when bisecting for the resolution of an issue (the first good commit) rather than the introduction of a regression. These terms must be used when marking a commit (e.g. `git bisect new`), they will be used in reference names (e.g. refs/bisect/new) and they are used in parts of git's log output such as "<sha> was both old and new" in git bisect skip's output. However, hardcoded "good"/"bad" terms are still used in a few status messages and can cause confusion about the status of the bisect such as: $ git bisect old [sha] is the first new commit or about the required action such as: status: waiting for bad commit, 1 good commit known $ git bisect bad error: Invalid command: you're currently in a new/old bisect fatal: unknown command: 'bad' This commit updates all remaining output messages which use hardcoded "good" and "bad" terms to use the selected terms consistently across the bisect output and adds tests. Signed-off-by: Jonas Rebmann <kernel@schlaraffenlan.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonas Rebmann committed May 14, 2026 at 11:07 UTC 99ac2324a52a2e37dcde6b8dd6c9fb44706a65a0
2 files changed +27 -12
builtin/bisect.c
+13 -10
@@ -465,13 +465,16 @@ static void bisect_print_status(const struct bisect_terms *terms)
465 return;
466
467 if (!state.nr_good && !state.nr_bad)
468 - bisect_log_printf(_("status: waiting for both good and bad commits\n"));
468 + bisect_log_printf(_("status: waiting for both %s and %s commits\n"),
469 + terms->term_good, terms->term_bad);
470 else if (state.nr_good)
470 - bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n",
471 - "status: waiting for bad commit, %d good commits known\n",
472 - state.nr_good), state.nr_good);
471 + bisect_log_printf(Q_("status: waiting for %s commit, %d %s commit known\n",
472 + "status: waiting for %s commit, %d %s commits known\n",
473 + state.nr_good),
474 + terms->term_bad, state.nr_good, terms->term_good);
475 else
474 - bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n"));
476 + bisect_log_printf(_("status: waiting for %s commit(s), %s commit known\n"),
477 + terms->term_good, terms->term_bad);
478 }
479
480 static int bisect_next_check(const struct bisect_terms *terms,
@@ -1262,14 +1265,14 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1265 int rc = verify_good(terms, command.buf);
1266 is_first_run = 0;
1267 if (rc < 0 || 128 <= rc) {
1265 - error(_("unable to verify %s on good"
1266 - " revision"), command.buf);
1268 + error(_("unable to verify %s on %s"
1269 + " revision"), command.buf, terms->term_good);
1270 res = BISECT_FAILED;
1271 break;
1272 }
1273 if (rc == res) {
1271 - error(_("bogus exit code %d for good revision"),
1272 - rc);
1274 + error(_("bogus exit code %d for %s revision"),
1275 + rc, terms->term_good);
1276 res = BISECT_FAILED;
1277 break;
1278 }
@@ -1314,7 +1317,7 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1317 puts(_("bisect run success"));
1318 res = BISECT_OK;
1319 } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
1317 - puts(_("bisect found first bad commit"));
1320 + printf(_("bisect found first %s commit\n"), terms->term_bad);
1321 res = BISECT_OK;
1322 } else if (res) {
1323 error(_("bisect run failed: 'git bisect %s'"
t/t6030-bisect-porcelain.sh
+14 -2
@@ -1077,8 +1077,10 @@ test_expect_success 'bisect terms shows good/bad after start' '
1077
1078 test_expect_success 'bisect start with one term1 and term2' '
1079 git bisect reset &&
1080 - git bisect start --term-old term2 --term-new term1 &&
1081 - git bisect term2 $HASH1 &&
1080 + git bisect start --term-old term2 --term-new term1 >bisect_result &&
1081 + grep "status: waiting for both term2 and term1 commits" bisect_result &&
1082 + git bisect term2 $HASH1 >bisect_result &&
1083 + grep "status: waiting for term1 commit, 1 term2 commit known" bisect_result &&
1084 git bisect term1 $HASH4 &&
1085 git bisect term1 &&
1086 git bisect term1 >bisect_result &&
@@ -1103,6 +1105,16 @@ test_expect_success 'bisect replay with term1 and term2' '
1105 git bisect reset
1106 '
1107
1108 +test_expect_success 'bisect run term1 term2' '
1109 + git bisect reset &&
1110 + git bisect start --term-new term1 --term-old term2 $HASH4 $HASH1 &&
1111 + git bisect term1 &&
1112 + git bisect run false >bisect_result &&
1113 + grep "bisect found first term1 commit" bisect_result &&
1114 + git bisect log >log_to_replay.txt &&
1115 + git bisect reset
1116 +'
1117 +
1118 test_expect_success 'bisect start term1 term2' '
1119 git bisect reset &&
1120 git bisect start --term-new term1 --term-old term2 $HASH4 $HASH1 &&