Skip to content

Commit 48750b2

Browse files
rscharfettaylorr
authored andcommitted
bisect: simplify building "checkout" argument list
Reduce the scope of argv_checkout, which allows to fully build it during initialization. Use oid_to_hex() instead of oid_to_hex_r(), because that's simpler and using the static buffer of the former is just as safe as the old static argv_checkout. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 75c92a0 commit 48750b2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

bisect.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ static struct oid_array skipped_revs;
2222

2323
static struct object_id *current_bad_oid;
2424

25-
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
26-
2725
static const char *term_bad;
2826
static const char *term_good;
2927

@@ -729,19 +727,20 @@ static int is_expected_rev(const struct object_id *oid)
729727
enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
730728
int no_checkout)
731729
{
732-
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
733730
struct commit *commit;
734731
struct pretty_print_context pp = {0};
735732
struct strbuf commit_msg = STRBUF_INIT;
736733

737-
oid_to_hex_r(bisect_rev_hex, bisect_rev);
738734
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
739735

740-
argv_checkout[2] = bisect_rev_hex;
741736
if (no_checkout) {
742737
update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
743738
UPDATE_REFS_DIE_ON_ERR);
744739
} else {
740+
const char *argv_checkout[] = {
741+
"checkout", "-q", oid_to_hex(bisect_rev), "--", NULL
742+
};
743+
745744
if (run_command_v_opt(argv_checkout, RUN_GIT_CMD))
746745
/*
747746
* Errors in `run_command()` itself, signaled by res < 0,

0 commit comments

Comments
 (0)