Skip to content

Commit 320598c

Browse files
Jonas Rebmanngitster
authored andcommitted
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 bad 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>
1 parent ca1db8a commit 320598c

2 files changed

Lines changed: 38 additions & 23 deletions

File tree

builtin/bisect.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,16 @@ static void bisect_print_status(const struct bisect_terms *terms)
465465
return;
466466

467467
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);
469470
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);
473475
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);
475478
}
476479

477480
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)
12621265
int rc = verify_good(terms, command.buf);
12631266
is_first_run = 0;
12641267
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 revision"),
1269+
command.buf, terms->term_good);
12671270
res = BISECT_FAILED;
12681271
break;
12691272
}
12701273
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);
12731276
res = BISECT_FAILED;
12741277
break;
12751278
}
@@ -1314,7 +1317,7 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
13141317
puts(_("bisect run success"));
13151318
res = BISECT_OK;
13161319
} 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);
13181321
res = BISECT_OK;
13191322
} else if (res) {
13201323
error(_("bisect run failed: 'git bisect %s'"

t/t6030-bisect-porcelain.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,14 @@ test_expect_success 'bisect terms shows good/bad after start' '
10771077

10781078
test_expect_success 'bisect start with one term1 and term2' '
10791079
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+
test_grep "status: waiting for both '\''term2'\'' and '\''term1'\'' commits" bisect_result &&
1082+
git bisect term2 $HASH1 >bisect_result &&
1083+
test_grep "status: waiting for '\''term1'\'' commit, 1 '\''term2'\'' commit known" bisect_result &&
10821084
git bisect term1 $HASH4 &&
10831085
git bisect term1 &&
10841086
git bisect term1 >bisect_result &&
1085-
grep "$HASH2 is the first term1 commit" bisect_result &&
1087+
test_grep "$HASH2 is the first term1 commit" bisect_result &&
10861088
git bisect log >log_to_replay.txt &&
10871089
git bisect reset
10881090
'
@@ -1103,6 +1105,16 @@ test_expect_success 'bisect replay with term1 and term2' '
11031105
git bisect reset
11041106
'
11051107

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+
test_grep "bisect found first term1 commit" bisect_result &&
1114+
git bisect log >log_to_replay.txt &&
1115+
git bisect reset
1116+
'
1117+
11061118
test_expect_success 'bisect start term1 term2' '
11071119
git bisect reset &&
11081120
git bisect start --term-new term1 --term-old term2 $HASH4 $HASH1 &&
@@ -1224,29 +1236,29 @@ test_expect_success 'bisect visualize with a filename with dash and space' '
12241236
test_expect_success 'bisect state output with multiple good commits' '
12251237
git bisect reset &&
12261238
git bisect start >output &&
1227-
grep "waiting for both good and bad commits" output &&
1239+
grep "waiting for both '\''good'\'' and '\''bad'\'' commits" output &&
12281240
git bisect log >output &&
1229-
grep "waiting for both good and bad commits" output &&
1241+
grep "waiting for both '\''good'\'' and '\''bad'\'' commits" output &&
12301242
git bisect good "$HASH1" >output &&
1231-
grep "waiting for bad commit, 1 good commit known" output &&
1243+
grep "waiting for '\''bad'\'' commit, 1 '\''good'\'' commit known" output &&
12321244
git bisect log >output &&
1233-
grep "waiting for bad commit, 1 good commit known" output &&
1245+
grep "waiting for '\''bad'\'' commit, 1 '\''good'\'' commit known" output &&
12341246
git bisect good "$HASH2" >output &&
1235-
grep "waiting for bad commit, 2 good commits known" output &&
1247+
grep "waiting for '\''bad'\'' commit, 2 '\''good'\'' commits known" output &&
12361248
git bisect log >output &&
1237-
grep "waiting for bad commit, 2 good commits known" output
1249+
grep "waiting for '\''bad'\'' commit, 2 '\''good'\'' commits known" output
12381250
'
12391251

12401252
test_expect_success 'bisect state output with bad commit' '
12411253
git bisect reset &&
12421254
git bisect start >output &&
1243-
grep "waiting for both good and bad commits" output &&
1255+
grep "waiting for both '\''good'\'' and '\''bad'\'' commits" output &&
12441256
git bisect log >output &&
1245-
grep "waiting for both good and bad commits" output &&
1257+
grep "waiting for both '\''good'\'' and '\''bad'\'' commits" output &&
12461258
git bisect bad "$HASH4" >output &&
1247-
grep -F "waiting for good commit(s), bad commit known" output &&
1259+
grep -F "waiting for '\''good'\'' commit(s), '\''bad'\'' commit known" output &&
12481260
git bisect log >output &&
1249-
grep -F "waiting for good commit(s), bad commit known" output
1261+
grep -F "waiting for '\''good'\'' commit(s), '\''bad'\'' commit known" output
12501262
'
12511263

12521264
test_expect_success 'verify correct error message' '

0 commit comments

Comments
 (0)