run-command API: rename "env_array" to "env"
Start following-up on the rename mentioned inc7c4bdeccf
(run-command API: remove "env" member, always use "env_array", 2021-11-25) of "env_array" to "env". The "env_array" name was picked in19a583dc39
(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:

committed by
Junio C Hamano

parent
07330a41d6
commit
29fda24dd1
@ -292,7 +292,7 @@ static char *compute_rev_name(const char *sub_path, const char* object_id)
|
||||
|
||||
for (d = describe_argv; *d; d++) {
|
||||
struct child_process cp = CHILD_PROCESS_INIT;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
cp.dir = sub_path;
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stderr = 1;
|
||||
@ -479,7 +479,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
|
||||
if (!is_submodule_populated_gently(path, NULL))
|
||||
goto cleanup;
|
||||
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
|
||||
/*
|
||||
* For the purpose of executing <command> in the submodule,
|
||||
@ -499,12 +499,12 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
|
||||
char *toplevel = xgetcwd();
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
strvec_pushf(&cp.env_array, "name=%s", sub->name);
|
||||
strvec_pushf(&cp.env_array, "sm_path=%s", path);
|
||||
strvec_pushf(&cp.env_array, "displaypath=%s", displaypath);
|
||||
strvec_pushf(&cp.env_array, "sha1=%s",
|
||||
strvec_pushf(&cp.env, "name=%s", sub->name);
|
||||
strvec_pushf(&cp.env, "sm_path=%s", path);
|
||||
strvec_pushf(&cp.env, "displaypath=%s", displaypath);
|
||||
strvec_pushf(&cp.env, "sha1=%s",
|
||||
oid_to_hex(ce_oid));
|
||||
strvec_pushf(&cp.env_array, "toplevel=%s", toplevel);
|
||||
strvec_pushf(&cp.env, "toplevel=%s", toplevel);
|
||||
|
||||
/*
|
||||
* Since the path variable was accessible from the script
|
||||
@ -536,7 +536,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
|
||||
|
||||
cpr.git_cmd = 1;
|
||||
cpr.dir = path;
|
||||
prepare_submodule_repo_env(&cpr.env_array);
|
||||
prepare_submodule_repo_env(&cpr.env);
|
||||
|
||||
strvec_pushl(&cpr.args, "--super-prefix", NULL);
|
||||
strvec_pushf(&cpr.args, "%s/", displaypath);
|
||||
@ -833,7 +833,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
|
||||
|
||||
cpr.git_cmd = 1;
|
||||
cpr.dir = path;
|
||||
prepare_submodule_repo_env(&cpr.env_array);
|
||||
prepare_submodule_repo_env(&cpr.env);
|
||||
|
||||
strvec_push(&cpr.args, "--super-prefix");
|
||||
strvec_pushf(&cpr.args, "%s/", displaypath);
|
||||
@ -955,7 +955,7 @@ static char *verify_submodule_committish(const char *sm_path,
|
||||
|
||||
cp_rev_parse.git_cmd = 1;
|
||||
cp_rev_parse.dir = sm_path;
|
||||
prepare_submodule_repo_env(&cp_rev_parse.env_array);
|
||||
prepare_submodule_repo_env(&cp_rev_parse.env);
|
||||
strvec_pushl(&cp_rev_parse.args, "rev-parse", "-q", "--short", NULL);
|
||||
strvec_pushf(&cp_rev_parse.args, "%s^0", committish);
|
||||
strvec_push(&cp_rev_parse.args, "--");
|
||||
@ -996,7 +996,7 @@ static void print_submodule_summary(struct summary_cb *info, char *errmsg,
|
||||
|
||||
cp_log.git_cmd = 1;
|
||||
cp_log.dir = p->sm_path;
|
||||
prepare_submodule_repo_env(&cp_log.env_array);
|
||||
prepare_submodule_repo_env(&cp_log.env);
|
||||
strvec_pushl(&cp_log.args, "log", NULL);
|
||||
|
||||
if (S_ISGITLINK(p->mod_src) && S_ISGITLINK(p->mod_dst)) {
|
||||
@ -1113,7 +1113,7 @@ static void generate_submodule_summary(struct summary_cb *info,
|
||||
|
||||
cp_rev_list.git_cmd = 1;
|
||||
cp_rev_list.dir = p->sm_path;
|
||||
prepare_submodule_repo_env(&cp_rev_list.env_array);
|
||||
prepare_submodule_repo_env(&cp_rev_list.env);
|
||||
|
||||
if (!capture_command(&cp_rev_list, &sb_rev_list, 0))
|
||||
total_commits = atoi(sb_rev_list.buf);
|
||||
@ -1414,7 +1414,7 @@ static void sync_submodule(const char *path, const char *prefix,
|
||||
|
||||
cpr.git_cmd = 1;
|
||||
cpr.dir = path;
|
||||
prepare_submodule_repo_env(&cpr.env_array);
|
||||
prepare_submodule_repo_env(&cpr.env);
|
||||
|
||||
strvec_push(&cpr.args, "--super-prefix");
|
||||
strvec_pushf(&cpr.args, "%s/", displaypath);
|
||||
@ -1819,7 +1819,7 @@ static int clone_submodule(struct module_clone_data *clone_data)
|
||||
strvec_push(&cp.args, clone_data->path);
|
||||
|
||||
cp.git_cmd = 1;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
cp.no_stdin = 1;
|
||||
|
||||
if(run_command(&cp))
|
||||
@ -2295,7 +2295,7 @@ static int is_tip_reachable(const char *path, struct object_id *oid)
|
||||
cp.no_stderr = 1;
|
||||
strvec_pushl(&cp.args, "rev-list", "-n", "1", hex, "--not", "--all", NULL);
|
||||
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
|
||||
if (capture_command(&cp, &rev, GIT_MAX_HEXSZ + 1) || rev.len)
|
||||
return 0;
|
||||
@ -2307,7 +2307,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str
|
||||
{
|
||||
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.dir = xstrdup(module_path);
|
||||
|
||||
@ -2364,7 +2364,7 @@ static int run_update_command(struct update_data *ud, int subforce)
|
||||
strvec_push(&cp.args, oid);
|
||||
|
||||
cp.dir = xstrdup(ud->sm_path);
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
if (run_command(&cp)) {
|
||||
switch (ud->update_strategy.type) {
|
||||
case SM_UPDATE_CHECKOUT:
|
||||
@ -2630,7 +2630,7 @@ static int update_submodule(struct update_data *update_data)
|
||||
|
||||
cp.dir = update_data->sm_path;
|
||||
cp.git_cmd = 1;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
update_data_to_args(&next, &cp.args);
|
||||
|
||||
/* die() if child process die()'d */
|
||||
@ -3123,9 +3123,9 @@ static void append_fetch_remotes(struct strbuf *msg, const char *git_dir_path)
|
||||
struct strbuf sb_remote_out = STRBUF_INIT;
|
||||
|
||||
cp_remote.git_cmd = 1;
|
||||
strvec_pushf(&cp_remote.env_array,
|
||||
strvec_pushf(&cp_remote.env,
|
||||
"GIT_DIR=%s", git_dir_path);
|
||||
strvec_push(&cp_remote.env_array, "GIT_WORK_TREE=.");
|
||||
strvec_push(&cp_remote.env, "GIT_WORK_TREE=.");
|
||||
strvec_pushl(&cp_remote.args, "remote", "-v", NULL);
|
||||
if (!capture_command(&cp_remote, &sb_remote_out, 0)) {
|
||||
char *next_line;
|
||||
@ -3209,7 +3209,7 @@ static int add_submodule(const struct add_data *add_data)
|
||||
if (clone_submodule(&clone_data))
|
||||
return -1;
|
||||
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
prepare_submodule_repo_env(&cp.env);
|
||||
cp.git_cmd = 1;
|
||||
cp.dir = add_data->sm_path;
|
||||
/*
|
||||
|
Reference in New Issue
Block a user