Skip to content

Commit 1f87293

Browse files
rscharfegitster
authored andcommitted
run-command: inline prepare_run_command_v_opt()
Merge prepare_run_command_v_opt() and its only caller. This removes a pointer indirection and allows to initialize the struct child_process using CHILD_PROCESS_INIT. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 41e9bad commit 1f87293

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

run-command.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -561,29 +561,21 @@ int run_command(struct child_process *cmd)
561561
return finish_command(cmd);
562562
}
563563

564-
static void prepare_run_command_v_opt(struct child_process *cmd,
565-
const char **argv,
566-
int opt)
567-
{
568-
memset(cmd, 0, sizeof(*cmd));
569-
cmd->argv = argv;
570-
cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
571-
cmd->git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
572-
cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
573-
cmd->silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
574-
cmd->use_shell = opt & RUN_USING_SHELL ? 1 : 0;
575-
cmd->clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
576-
}
577-
578564
int run_command_v_opt(const char **argv, int opt)
579565
{
580566
return run_command_v_opt_cd_env(argv, opt, NULL, NULL);
581567
}
582568

583569
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
584570
{
585-
struct child_process cmd;
586-
prepare_run_command_v_opt(&cmd, argv, opt);
571+
struct child_process cmd = CHILD_PROCESS_INIT;
572+
cmd.argv = argv;
573+
cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
574+
cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
575+
cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
576+
cmd.silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
577+
cmd.use_shell = opt & RUN_USING_SHELL ? 1 : 0;
578+
cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
587579
cmd.dir = dir;
588580
cmd.env = env;
589581
return run_command(&cmd);

0 commit comments

Comments
 (0)