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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
41e9bad75e
commit
1f87293d78
@ -561,20 +561,6 @@ int run_command(struct child_process *cmd)
|
|||||||
return finish_command(cmd);
|
return finish_command(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_run_command_v_opt(struct child_process *cmd,
|
|
||||||
const char **argv,
|
|
||||||
int opt)
|
|
||||||
{
|
|
||||||
memset(cmd, 0, sizeof(*cmd));
|
|
||||||
cmd->argv = argv;
|
|
||||||
cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
|
|
||||||
cmd->git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
|
|
||||||
cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
|
|
||||||
cmd->silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
|
|
||||||
cmd->use_shell = opt & RUN_USING_SHELL ? 1 : 0;
|
|
||||||
cmd->clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int run_command_v_opt(const char **argv, int opt)
|
int run_command_v_opt(const char **argv, int opt)
|
||||||
{
|
{
|
||||||
return run_command_v_opt_cd_env(argv, opt, NULL, NULL);
|
return run_command_v_opt_cd_env(argv, opt, NULL, NULL);
|
||||||
@ -582,8 +568,14 @@ int run_command_v_opt(const char **argv, int opt)
|
|||||||
|
|
||||||
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
|
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
|
||||||
{
|
{
|
||||||
struct child_process cmd;
|
struct child_process cmd = CHILD_PROCESS_INIT;
|
||||||
prepare_run_command_v_opt(&cmd, argv, opt);
|
cmd.argv = argv;
|
||||||
|
cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
|
||||||
|
cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
|
||||||
|
cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
|
||||||
|
cmd.silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
|
||||||
|
cmd.use_shell = opt & RUN_USING_SHELL ? 1 : 0;
|
||||||
|
cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
|
||||||
cmd.dir = dir;
|
cmd.dir = dir;
|
||||||
cmd.env = env;
|
cmd.env = env;
|
||||||
return run_command(&cmd);
|
return run_command(&cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user