Skip to content

Commit 87ee87d

Browse files
avargitster
authored andcommitted
run-command tests: use strvec_pushv(), not argv assignment
As in the preceding commit change this API user to use strvec_pushv() instead of assigning to the "argv" member directly. This leaves us without test coverage of how the "argv" assignment in this API works, but we'll be removing it in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6def0ff commit 87ee87d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

t/helper/test-run-command.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int parallel_next(struct child_process *cp,
3131
if (number_callbacks >= 4)
3232
return 0;
3333

34-
strvec_pushv(&cp->args, d->argv);
34+
strvec_pushv(&cp->args, d->args.v);
3535
strbuf_addstr(err, "preloaded output of a child\n");
3636
number_callbacks++;
3737
return 1;
@@ -274,7 +274,7 @@ static int quote_stress_test(int argc, const char **argv)
274274
if (i < skip)
275275
continue;
276276

277-
cp.argv = args.v;
277+
strvec_pushv(&cp.args, args.v);
278278
strbuf_reset(&out);
279279
if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
280280
return error("Failed to spawn child process");
@@ -396,7 +396,7 @@ int cmd__run_command(int argc, const char **argv)
396396
}
397397
if (argc < 3)
398398
return 1;
399-
proc.argv = (const char **)argv + 2;
399+
strvec_pushv(&proc.args, (const char **)argv + 2);
400400

401401
if (!strcmp(argv[1], "start-command-ENOENT")) {
402402
if (start_command(&proc) < 0 && errno == ENOENT)
@@ -408,7 +408,8 @@ int cmd__run_command(int argc, const char **argv)
408408
exit(run_command(&proc));
409409

410410
jobs = atoi(argv[2]);
411-
proc.argv = (const char **)argv + 3;
411+
strvec_clear(&proc.args);
412+
strvec_pushv(&proc.args, (const char **)argv + 3);
412413

413414
if (!strcmp(argv[1], "run-command-parallel"))
414415
exit(run_processes_parallel(jobs, parallel_next,

0 commit comments

Comments
 (0)