Re: [PATCH 4/8] use child_process member "args" instead of string array variable
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 29, 2022, 18:26 UTC
- Message-ID
- <Y11wVpgoD0KrHm55@nand.local>
- In-Reply-To
- <0e889c96-6004-96e4-9505-19ce1e7f9900@web.de>
On Thu, Oct 27, 2022 at 06:37:52PM +0200, René Scharfe wrote:
Show 23 quoted lines
> @@ -729,20 +727,22 @@ static int is_expected_rev(const struct object_id *oid)
> enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
> int no_checkout)
> {
> - char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
> struct commit *commit;
> struct pretty_print_context pp = {0};
> struct strbuf commit_msg = STRBUF_INIT;
>
> - oid_to_hex_r(bisect_rev_hex, bisect_rev);
> update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
>
> - argv_checkout[2] = bisect_rev_hex;
> if (no_checkout) {
> update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
> UPDATE_REFS_DIE_ON_ERR);
> } else {
> - if (run_command_v_opt(argv_checkout, RUN_GIT_CMD))
> + struct child_process cmd = CHILD_PROCESS_INIT;
> +
> + cmd.git_cmd = 1;
> + strvec_pushl(&cmd.args, "checkout", "-q",
> + oid_to_hex(bisect_rev), "--", NULL);I was wondering if this part of the conversion was right, since oid_to_hex() uses a ring of output buffers (see hash_to_hex_algop()). But we do call xstrdup() on the argument from strvec_push(), so we are OK here.
Thanks, Taylor