summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-07-28 20:25:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-28 22:02:18 (GMT)
commitc972bf4cf546a56fe1c54ddde1d33ebb9f454a0f (patch)
tree3a97c304c0e0ed4656cc5049ba44b4eb26e87a16 /run-command.c
parentef8d7ac42a6a62d678166fe25ea743315809d2bb (diff)
downloadgit-c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f.zip
git-c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f.tar.gz
git-c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f.tar.bz2
strvec: convert remaining callers away from argv_array name
We eventually want to drop the argv_array name and just use strvec consistently. There's no particular reason we have to do it all at once, or care about interactions between converted and unconverted bits. Because of our preprocessor compat layer, the names are interchangeable to the compiler (so even a definition and declaration using different names is OK). This patch converts all of the remaining files, as the resulting diff is reasonably sized. The conversion was done purely mechanically with: git ls-files '*.c' '*.h' | xargs perl -i -pe ' s/ARGV_ARRAY/STRVEC/g; s/argv_array/strvec/g; ' We'll deal with any indentation/style fallouts separately. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/run-command.c b/run-command.c
index 8f57661..b9630a1 100644
--- a/run-command.c
+++ b/run-command.c
@@ -11,14 +11,14 @@
void child_process_init(struct child_process *child)
{
memset(child, 0, sizeof(*child));
- argv_array_init(&child->args);
- argv_array_init(&child->env_array);
+ strvec_init(&child->args);
+ strvec_init(&child->env_array);
}
void child_process_clear(struct child_process *child)
{
- argv_array_clear(&child->args);
- argv_array_clear(&child->env_array);
+ strvec_clear(&child->args);
+ strvec_clear(&child->env_array);
}
struct child_to_clean {
@@ -263,30 +263,30 @@ int sane_execvp(const char *file, char * const argv[])
return -1;
}
-static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
+static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
{
if (!argv[0])
BUG("shell command is empty");
if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
#ifndef GIT_WINDOWS_NATIVE
- argv_array_push(out, SHELL_PATH);
+ strvec_push(out, SHELL_PATH);
#else
- argv_array_push(out, "sh");
+ strvec_push(out, "sh");
#endif
- argv_array_push(out, "-c");
+ strvec_push(out, "-c");
/*
* If we have no extra arguments, we do not even need to
* bother with the "$@" magic.
*/
if (!argv[1])
- argv_array_push(out, argv[0]);
+ strvec_push(out, argv[0]);
else
- argv_array_pushf(out, "%s \"$@\"", argv[0]);
+ strvec_pushf(out, "%s \"$@\"", argv[0]);
}
- argv_array_pushv(out, argv);
+ strvec_pushv(out, argv);
return out->argv;
}
@@ -401,7 +401,7 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
set_error_routine(old_errfn);
}
-static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
+static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
{
if (!cmd->argv[0])
BUG("command is empty");
@@ -410,14 +410,14 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
* Add SHELL_PATH so in the event exec fails with ENOEXEC we can
* attempt to interpret the command with 'sh'.
*/
- argv_array_push(out, SHELL_PATH);
+ strvec_push(out, SHELL_PATH);
if (cmd->git_cmd) {
prepare_git_cmd(out, cmd->argv);
} else if (cmd->use_shell) {
prepare_shell_cmd(out, cmd->argv);
} else {
- argv_array_pushv(out, cmd->argv);
+ strvec_pushv(out, cmd->argv);
}
/*
@@ -432,7 +432,7 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
free((char *)out->argv[1]);
out->argv[1] = program;
} else {
- argv_array_clear(out);
+ strvec_clear(out);
errno = ENOENT;
return -1;
}
@@ -742,7 +742,7 @@ fail_pipe:
int notify_pipe[2];
int null_fd = -1;
char **childenv;
- struct argv_array argv = ARGV_ARRAY_INIT;
+ struct strvec argv = STRVEC_INIT;
struct child_err cerr;
struct atfork_state as;
@@ -888,7 +888,7 @@ fail_pipe:
if (null_fd >= 0)
close(null_fd);
- argv_array_clear(&argv);
+ strvec_clear(&argv);
free(childenv);
}
end_of_spawn:
@@ -897,7 +897,7 @@ end_of_spawn:
{
int fhin = 0, fhout = 1, fherr = 2;
const char **sargv = cmd->argv;
- struct argv_array nargv = ARGV_ARRAY_INIT;
+ struct strvec nargv = STRVEC_INIT;
if (cmd->no_stdin)
fhin = open("/dev/null", O_RDWR);
@@ -935,7 +935,7 @@ end_of_spawn:
if (cmd->clean_on_exit && cmd->pid >= 0)
mark_child_for_cleanup(cmd->pid, cmd);
- argv_array_clear(&nargv);
+ strvec_clear(&nargv);
cmd->argv = sargv;
if (fhin != 0)
close(fhin);
@@ -1352,9 +1352,9 @@ int run_hook_ve(const char *const *env, const char *name, va_list args)
if (!p)
return 0;
- argv_array_push(&hook.args, p);
+ strvec_push(&hook.args, p);
while ((p = va_arg(args, const char *)))
- argv_array_push(&hook.args, p);
+ strvec_push(&hook.args, p);
hook.env = env;
hook.no_stdin = 1;
hook.stdout_to_stderr = 1;
@@ -1868,13 +1868,13 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
int run_auto_gc(int quiet)
{
- struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
+ struct strvec argv_gc_auto = STRVEC_INIT;
int status;
- argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+ strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
if (quiet)
- argv_array_push(&argv_gc_auto, "--quiet");
+ strvec_push(&argv_gc_auto, "--quiet");
status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
- argv_array_clear(&argv_gc_auto);
+ strvec_clear(&argv_gc_auto);
return status;
}