Skip to content

Commit ffcb4e9

Browse files
committed
bisect: do not run show-branch just to show the current commit
In scripted versions of "git bisect", we used "git show-branch" to describe a single commit in the bisect log and also to the interactive user after checking out the next version to be tested. The former use of "git show-branch" was lost when the helper function that wrote bisect log entries was rewritten at 0f30233 (bisect--helper: `bisect_write` shell function in C, 2019-01-02) in C But we've kept the latter ever since 0871984 (bisect: make "git bisect" use new "--next-all" bisect-helper function, 2009-05-09) started using the faithful C-rewrite introduced at ef24c7c (bisect--helper: add "--next-exit" to output bisect results, 2009-04-19). Showing "[<full hex>] <subject>" is simple enough with our helper pretty.c::format_commit_message() and spawning show-branch is an overkill. Let's lose one external process. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ebf3c04 commit ffcb4e9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎bisect.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ static struct oid_array skipped_revs;
2323
static struct object_id *current_bad_oid;
2424

2525
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
26-
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
2726

2827
static const char *term_bad;
2928
static const char *term_good;
@@ -729,6 +728,9 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
729728
{
730729
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
731730
enum bisect_error res = BISECT_OK;
731+
struct commit *commit;
732+
struct pretty_print_context pp = {0};
733+
struct strbuf commit_msg = STRBUF_INIT;
732734

733735
oid_to_hex_r(bisect_rev_hex, bisect_rev);
734736
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
@@ -748,13 +750,11 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
748750
return -abs(res);
749751
}
750752

751-
argv_show_branch[1] = bisect_rev_hex;
752-
res = run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
753-
/*
754-
* Errors in `run_command()` itself, signaled by res < 0,
755-
* and errors in the child process, signaled by res > 0
756-
* can both be treated as regular BISECT_FAILURE (-1).
757-
*/
753+
commit = lookup_commit_reference(the_repository, bisect_rev);
754+
format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
755+
fputs(commit_msg.buf, stdout);
756+
strbuf_release(&commit_msg);
757+
758758
return -abs(res);
759759
}
760760

0 commit comments

Comments
 (0)