Skip to content

Commit ae2d05d

Browse files
committed
Merge branch 'jc/bisect-sans-show-branch'
"git bisect" spawned "git show-branch" only to pretty-print the title of the commit after checking out the next version to be tested; this has been rewritten in C. * jc/bisect-sans-show-branch: bisect: simplify return code from bisect_checkout() bisect: do not run show-branch just to show the current commit
2 parents 225bc32 + 1fcc40c commit ae2d05d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

bisect.c

Lines changed: 12 additions & 14 deletions
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;
@@ -728,7 +727,9 @@ static int is_expected_rev(const struct object_id *oid)
728727
static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
729728
{
730729
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
731-
enum bisect_error res = BISECT_OK;
730+
struct commit *commit;
731+
struct pretty_print_context pp = {0};
732+
struct strbuf commit_msg = STRBUF_INIT;
732733

733734
oid_to_hex_r(bisect_rev_hex, bisect_rev);
734735
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
@@ -738,24 +739,21 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
738739
update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
739740
UPDATE_REFS_DIE_ON_ERR);
740741
} else {
741-
res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
742-
if (res)
742+
if (run_command_v_opt(argv_checkout, RUN_GIT_CMD))
743743
/*
744744
* Errors in `run_command()` itself, signaled by res < 0,
745745
* and errors in the child process, signaled by res > 0
746-
* can both be treated as regular BISECT_FAILURE (-1).
746+
* can both be treated as regular BISECT_FAILED (-1).
747747
*/
748-
return -abs(res);
748+
return BISECT_FAILED;
749749
}
750750

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-
*/
758-
return -abs(res);
751+
commit = lookup_commit_reference(the_repository, bisect_rev);
752+
format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
753+
fputs(commit_msg.buf, stdout);
754+
strbuf_release(&commit_msg);
755+
756+
return BISECT_OK;
759757
}
760758

761759
static struct commit *get_commit_reference(struct repository *r,

0 commit comments

Comments
 (0)