diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-11-25 23:52:20 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-11-26 07:15:07 +0100 |
commit | 2b7098936c9e91d527aa53b8d4af0b25d7e912b4 (patch) | |
tree | d0042309f280e1246533b9bd0bcc70d5ff6ebbbc /sequencer.c | |
parent | run-command tests: use strvec_pushv(), not argv assignment (diff) | |
download | git-2b7098936c9e91d527aa53b8d4af0b25d7e912b4.tar.xz git-2b7098936c9e91d527aa53b8d4af0b25d7e912b4.zip |
run-command API users: use strvec_pushl(), not argv construction
Change a pattern of hardcoding an "argv" array size, populating it and
assigning to the "argv" member of "struct child_process" to instead
use "strvec_pushl()" to add data to the "args" member.
This implements the same behavior as before in fewer lines of code,
and moves us further towards being able to remove the "argv" member in
a subsequent commit.
Since we've entirely removed the "argv" variable(s) we can be sure
that no potential logic errors of the type discussed in a preceding
commit are being introduced here, i.e. ones where the local "argv" was
being modified after the assignment to "struct child_process"'s
"argv".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/sequencer.c b/sequencer.c index ea96837cde..6e02210db7 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1164,18 +1164,14 @@ static int run_rewrite_hook(const struct object_id *oldoid, const struct object_id *newoid) { struct child_process proc = CHILD_PROCESS_INIT; - const char *argv[3]; int code; struct strbuf sb = STRBUF_INIT; + const char *hook_path = find_hook("post-rewrite"); - argv[0] = find_hook("post-rewrite"); - if (!argv[0]) + if (!hook_path) return 0; - argv[1] = "amend"; - argv[2] = NULL; - - proc.argv = argv; + strvec_pushl(&proc.args, hook_path, "amend", NULL); proc.in = -1; proc.stdout_to_stderr = 1; proc.trace2_hook_name = "post-rewrite"; |