bisect: output bisect setup status in bisect log
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0cf1defa5a
commit
f11046e6de
@ -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,
|
||||
|
@ -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
|
||||
'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user