run-command API: rename "env_array" to "env"

Start following-up on the rename mentioned in c7c4bdeccf (run-command
API: remove "env" member, always use "env_array", 2021-11-25) of
"env_array" to "env".

The "env_array" name was picked in 19a583dc39 (run-command: add
env_array, an optional argv_array for env, 2014-10-19) because "env"
was taken. Let's not forever keep the oddity of "*_array" for this
"struct strvec", but not for its "args" sibling.

This commit is almost entirely made with a coccinelle rule[1]. The
only manual change here is in run-command.h to rename the struct
member itself and to change "env_array" to "env" in the
CHILD_PROCESS_INIT initializer.

The rest of this is all a result of applying [1]:

 * make contrib/coccinelle/run_command.cocci.patch
 * patch -p1 <contrib/coccinelle/run_command.cocci.patch
 * git add -u

1. cat contrib/coccinelle/run_command.pending.cocci
   @@
   struct child_process E;
   @@
   - E.env_array
   + E.env

   @@
   struct child_process *E;
   @@
   - E->env_array
   + E->env

I've avoided changing any comments and derived variable names here,
that will all be done in the next commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2022-06-02 11:09:50 +02:00
committed by Junio C Hamano
parent 07330a41d6
commit 29fda24dd1
24 changed files with 115 additions and 113 deletions

View File

@ -711,15 +711,15 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED))
strvec_push(&cp.args, oid_to_hex(new_oid));
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
if (!is_directory(path)) {
/* fall back to absorbed git dir, if any */
if (!sub)
goto done;
cp.dir = sub->gitdir;
strvec_push(&cp.env_array, GIT_DIR_ENVIRONMENT "=.");
strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
strvec_push(&cp.env, GIT_DIR_ENVIRONMENT "=.");
strvec_push(&cp.env, GIT_WORK_TREE_ENVIRONMENT "=.");
}
if (start_command(&cp)) {
@ -1019,7 +1019,7 @@ static int submodule_has_commits(struct repository *r,
oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
strvec_pushl(&cp.args, "--not", "--all", NULL);
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.dir = path;
@ -1060,7 +1060,7 @@ static int submodule_needs_pushing(struct repository *r,
oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
strvec_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
@ -1146,7 +1146,7 @@ static int push_submodule(const char *path,
strvec_push(&cp.args, rs->raw[i]);
}
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.dir = path;
@ -1177,7 +1177,7 @@ static void submodule_push_check(const char *path, const char *head,
for (i = 0; i < rs->raw_nr; i++)
strvec_push(&cp.args, rs->raw[i]);
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.no_stdout = 1;
@ -1678,7 +1678,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
child_process_init(cp);
cp->dir = task->repo->gitdir;
prepare_submodule_repo_env_in_gitdir(&cp->env_array);
prepare_submodule_repo_env_in_gitdir(&cp->env);
cp->git_cmd = 1;
strvec_init(&cp->args);
if (task->git_args.nr)
@ -1708,7 +1708,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
spf->prefix, task->sub->path);
child_process_init(cp);
prepare_submodule_repo_env_in_gitdir(&cp->env_array);
prepare_submodule_repo_env_in_gitdir(&cp->env);
cp->git_cmd = 1;
cp->dir = task->repo->gitdir;
@ -1882,7 +1882,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
if (ignore_untracked)
strvec_push(&cp.args, "-uno");
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
@ -1954,7 +1954,7 @@ int submodule_uses_gitfile(const char *path)
"submodule", "foreach", "--quiet", "--recursive",
"test -f .git", NULL);
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.no_stderr = 1;
@ -1997,7 +1997,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
strvec_push(&cp.args, "--ignored");
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
@ -2052,7 +2052,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
{
struct child_process cp = CHILD_PROCESS_INIT;
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
strvec_pushl(&cp.args, "diff-index", "--quiet",
@ -2069,7 +2069,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
static void submodule_reset_index(const char *path)
{
struct child_process cp = CHILD_PROCESS_INIT;
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
@ -2153,7 +2153,7 @@ int submodule_move_head(const char *path,
}
}
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
cp.git_cmd = 1;
cp.no_stdin = 1;
@ -2191,7 +2191,7 @@ int submodule_move_head(const char *path,
cp.no_stdin = 1;
cp.dir = path;
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
strvec_pushl(&cp.args, "update-ref", "HEAD",
"--no-deref", new_head, NULL);
@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,
strvec_pushl(&cp.args, "--super-prefix", sb.buf,
"submodule--helper",
"absorb-git-dirs", NULL);
prepare_submodule_repo_env(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
if (run_command(&cp))
die(_("could not recurse into submodule '%s'"), path);
@ -2407,8 +2407,8 @@ int get_superproject_working_tree(struct strbuf *buf)
subpath = relative_path(cwd, one_up.buf, &sb);
strbuf_release(&one_up);
prepare_submodule_repo_env(&cp.env_array);
strvec_pop(&cp.env_array);
prepare_submodule_repo_env(&cp.env);
strvec_pop(&cp.env);
strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
"ls-files", "-z", "--stage", "--full-name", "--",