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 <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
René Scharfe committed
Oct 30, 2022 at 12:47 UTC
48750b2d0d22f07d60c6179a7c3726446060136a
1 file changed
+4
-5
bisect.c
+4
-5
@@ -22,8 +22,6 @@ static struct oid_array skipped_revs;
22
23
static struct object_id *current_bad_oid;
24
25
-static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
26
-
25
static const char *term_bad;
26
static const char *term_good;
27
@@ -729,19 +727,20 @@ static int is_expected_rev(const struct object_id *oid)
727
enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
728
int no_checkout)
729
{
732
- char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
730
struct commit *commit;
731
struct pretty_print_context pp = {0};
732
struct strbuf commit_msg = STRBUF_INIT;
733
737
- oid_to_hex_r(bisect_rev_hex, bisect_rev);
734
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
735
740
- argv_checkout[2] = bisect_rev_hex;
736
if (no_checkout) {
737
update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
738
UPDATE_REFS_DIE_ON_ERR);
739
} else {
740
+ const char *argv_checkout[] = {
741
+ "checkout", "-q", oid_to_hex(bisect_rev), "--", NULL
742
+ };
743
+
744
if (run_command_v_opt(argv_checkout, RUN_GIT_CMD))
745
/*
746
* Errors in `run_command()` itself, signaled by res < 0,