summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorLibravatar Ævar Arnfjörð Bjarmason <avarab@gmail.com>2021-11-25 23:52:20 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-11-25 22:15:07 -0800
commit2b7098936c9e91d527aa53b8d4af0b25d7e912b4 (patch)
treed0042309f280e1246533b9bd0bcc70d5ff6ebbbc /builtin/merge.c
parentrun-command tests: use strvec_pushv(), not argv assignment (diff)
downloadtgif-2b7098936c9e91d527aa53b8d4af0b25d7e912b4.tar.xz
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 'builtin/merge.c')
-rw-r--r--builtin/merge.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index ea3112e0c0..5f0476b0b7 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -310,10 +310,9 @@ static int save_state(struct object_id *stash)
int len;
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf buffer = STRBUF_INIT;
- const char *argv[] = {"stash", "create", NULL};
int rc = -1;
- cp.argv = argv;
+ strvec_pushl(&cp.args, "stash", "create", NULL);
cp.out = -1;
cp.git_cmd = 1;