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

@ -1000,7 +1000,7 @@ static int run_git_commit(const char *defmsg,
if (is_rebase_i(opts) &&
((opts->committer_date_is_author_date && !opts->ignore_date) ||
!(!defmsg && (flags & AMEND_MSG))) &&
read_env_script(&cmd.env_array)) {
read_env_script(&cmd.env)) {
const char *gpg_opt = gpg_sign_opt_quoted(opts);
return error(_(staged_changes_advice),
@ -1008,12 +1008,12 @@ static int run_git_commit(const char *defmsg,
}
if (opts->committer_date_is_author_date)
strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
strvec_pushf(&cmd.env, "GIT_COMMITTER_DATE=%s",
opts->ignore_date ?
"" :
author_date_from_env_array(&cmd.env_array));
author_date_from_env_array(&cmd.env));
if (opts->ignore_date)
strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
strvec_push(&cmd.args, "commit");
@ -3912,7 +3912,7 @@ static int do_merge(struct repository *r,
/* Octopus merge */
struct child_process cmd = CHILD_PROCESS_INIT;
if (read_env_script(&cmd.env_array)) {
if (read_env_script(&cmd.env)) {
const char *gpg_opt = gpg_sign_opt_quoted(opts);
ret = error(_(staged_changes_advice), gpg_opt, gpg_opt);
@ -3920,12 +3920,12 @@ static int do_merge(struct repository *r,
}
if (opts->committer_date_is_author_date)
strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
strvec_pushf(&cmd.env, "GIT_COMMITTER_DATE=%s",
opts->ignore_date ?
"" :
author_date_from_env_array(&cmd.env_array));
author_date_from_env_array(&cmd.env));
if (opts->ignore_date)
strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
cmd.git_cmd = 1;
strvec_push(&cmd.args, "merge");