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

Start following-up on the rename mentioned in c7c4bdeccf3 (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 19a583dc39e (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>

Ævar Arnfjörð Bjarmason committed Jun 2, 2022 at 11:09 UTC 29fda24dd11e90583f3ea9ff2f90ee9acacd7792
24 files changed +115 -113
add-patch.c
+1 -1
@@ -305,7 +305,7 @@ static void setup_child_process(struct add_p_state *s,
305 va_end(ap);
306
307 cp->git_cmd = 1;
308 - strvec_pushf(&cp->env_array,
308 + strvec_pushf(&cp->env,
309 INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
310 }
311
branch.c
+1 -1
@@ -564,7 +564,7 @@ static int submodule_create_branch(struct repository *r,
564 child.err = -1;
565 child.stdout_to_stderr = 1;
566
567 - prepare_other_repo_env(&child.env_array, r->gitdir);
567 + prepare_other_repo_env(&child.env, r->gitdir);
568 /*
569 * submodule_create_branch() is indirectly invoked by "git
570 * branch", but we cannot invoke "git branch" in the child
builtin/difftool.c
+3 -3
@@ -217,7 +217,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
217 update_index.use_shell = 0;
218 update_index.clean_on_exit = 1;
219 update_index.dir = workdir;
220 - strvec_pushf(&update_index.env_array, "GIT_INDEX_FILE=%s", index_path);
220 + strvec_pushf(&update_index.env, "GIT_INDEX_FILE=%s", index_path);
221 /* Ignore any errors of update-index */
222 run_command(&update_index);
223
@@ -230,7 +230,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
230 diff_files.clean_on_exit = 1;
231 diff_files.out = -1;
232 diff_files.dir = workdir;
233 - strvec_pushf(&diff_files.env_array, "GIT_INDEX_FILE=%s", index_path);
233 + strvec_pushf(&diff_files.env, "GIT_INDEX_FILE=%s", index_path);
234 if (start_command(&diff_files))
235 die("could not obtain raw diff");
236 fp = xfdopen(diff_files.out, "r");
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix,
675
676 child->git_cmd = 1;
677 child->dir = prefix;
678 - strvec_pushv(&child->env_array, env);
678 + strvec_pushv(&child->env, env);
679
680 return run_command(child);
681 }
builtin/receive-pack.c
+16 -16
@@ -764,23 +764,23 @@ static void prepare_push_cert_sha1(struct child_process *proc)
764 nonce_status = check_nonce(push_cert.buf, bogs);
765 }
766 if (!is_null_oid(&push_cert_oid)) {
767 - strvec_pushf(&proc->env_array, "GIT_PUSH_CERT=%s",
767 + strvec_pushf(&proc->env, "GIT_PUSH_CERT=%s",
768 oid_to_hex(&push_cert_oid));
769 - strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_SIGNER=%s",
769 + strvec_pushf(&proc->env, "GIT_PUSH_CERT_SIGNER=%s",
770 sigcheck.signer ? sigcheck.signer : "");
771 - strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_KEY=%s",
771 + strvec_pushf(&proc->env, "GIT_PUSH_CERT_KEY=%s",
772 sigcheck.key ? sigcheck.key : "");
773 - strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_STATUS=%c",
773 + strvec_pushf(&proc->env, "GIT_PUSH_CERT_STATUS=%c",
774 sigcheck.result);
775 if (push_cert_nonce) {
776 - strvec_pushf(&proc->env_array,
776 + strvec_pushf(&proc->env,
777 "GIT_PUSH_CERT_NONCE=%s",
778 push_cert_nonce);
779 - strvec_pushf(&proc->env_array,
779 + strvec_pushf(&proc->env,
780 "GIT_PUSH_CERT_NONCE_STATUS=%s",
781 nonce_status);
782 if (nonce_status == NONCE_SLOP)
783 - strvec_pushf(&proc->env_array,
783 + strvec_pushf(&proc->env,
784 "GIT_PUSH_CERT_NONCE_SLOP=%ld",
785 nonce_stamp_slop);
786 }
@@ -815,17 +815,17 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,
815 if (feed_state->push_options) {
816 size_t i;
817 for (i = 0; i < feed_state->push_options->nr; i++)
818 - strvec_pushf(&proc.env_array,
818 + strvec_pushf(&proc.env,
819 "GIT_PUSH_OPTION_%"PRIuMAX"=%s",
820 (uintmax_t)i,
821 feed_state->push_options->items[i].string);
822 - strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%"PRIuMAX"",
822 + strvec_pushf(&proc.env, "GIT_PUSH_OPTION_COUNT=%"PRIuMAX"",
823 (uintmax_t)feed_state->push_options->nr);
824 } else
825 - strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT");
825 + strvec_pushf(&proc.env, "GIT_PUSH_OPTION_COUNT");
826
827 if (tmp_objdir)
828 - strvec_pushv(&proc.env_array, tmp_objdir_env(tmp_objdir));
828 + strvec_pushv(&proc.env, tmp_objdir_env(tmp_objdir));
829
830 if (use_sideband) {
831 memset(&muxer, 0, sizeof(muxer));
@@ -1357,7 +1357,7 @@ static const char *push_to_deploy(unsigned char *sha1,
1357
1358 strvec_pushl(&child.args, "update-index", "-q", "--ignore-submodules",
1359 "--refresh", NULL);
1360 - strvec_pushv(&child.env_array, env->v);
1360 + strvec_pushv(&child.env, env->v);
1361 child.dir = work_tree;
1362 child.no_stdin = 1;
1363 child.stdout_to_stderr = 1;
@@ -1369,7 +1369,7 @@ static const char *push_to_deploy(unsigned char *sha1,
1369 child_process_init(&child);
1370 strvec_pushl(&child.args, "diff-files", "--quiet",
1371 "--ignore-submodules", "--", NULL);
1372 - strvec_pushv(&child.env_array, env->v);
1372 + strvec_pushv(&child.env, env->v);
1373 child.dir = work_tree;
1374 child.no_stdin = 1;
1375 child.stdout_to_stderr = 1;
@@ -1383,7 +1383,7 @@ static const char *push_to_deploy(unsigned char *sha1,
1383 /* diff-index with either HEAD or an empty tree */
1384 head_has_history() ? "HEAD" : empty_tree_oid_hex(),
1385 "--", NULL);
1386 - strvec_pushv(&child.env_array, env->v);
1386 + strvec_pushv(&child.env, env->v);
1387 child.no_stdin = 1;
1388 child.no_stdout = 1;
1389 child.stdout_to_stderr = 0;
@@ -1394,7 +1394,7 @@ static const char *push_to_deploy(unsigned char *sha1,
1394 child_process_init(&child);
1395 strvec_pushl(&child.args, "read-tree", "-u", "-m", hash_to_hex(sha1),
1396 NULL);
1397 - strvec_pushv(&child.env_array, env->v);
1397 + strvec_pushv(&child.env, env->v);
1398 child.dir = work_tree;
1399 child.no_stdin = 1;
1400 child.no_stdout = 1;
@@ -2215,7 +2215,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
2215 return "unable to create temporary object directory";
2216 }
2217 if (tmp_objdir)
2218 - strvec_pushv(&child.env_array, tmp_objdir_env(tmp_objdir));
2218 + strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
2219
2220 /*
2221 * Normally we just pass the tmp_objdir environment to the child
builtin/stash.c
+8 -8
@@ -356,7 +356,7 @@ static int restore_untracked(struct object_id *u_tree)
356 cp.git_cmd = 1;
357 strvec_push(&cp.args, "read-tree");
358 strvec_push(&cp.args, oid_to_hex(u_tree));
359 - strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
359 + strvec_pushf(&cp.env, "GIT_INDEX_FILE=%s",
360 stash_index_path.buf);
361 if (run_command(&cp)) {
362 remove_path(stash_index_path.buf);
@@ -366,7 +366,7 @@ static int restore_untracked(struct object_id *u_tree)
366 child_process_init(&cp);
367 cp.git_cmd = 1;
368 strvec_pushl(&cp.args, "checkout-index", "--all", NULL);
369 - strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
369 + strvec_pushf(&cp.env, "GIT_INDEX_FILE=%s",
370 stash_index_path.buf);
371
372 res = run_command(&cp);
@@ -585,9 +585,9 @@ restore_untracked:
585 */
586 cp.git_cmd = 1;
587 cp.dir = prefix;
588 - strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
588 + strvec_pushf(&cp.env, GIT_WORK_TREE_ENVIRONMENT"=%s",
589 absolute_path(get_git_work_tree()));
590 - strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
590 + strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
591 absolute_path(get_git_dir()));
592 strvec_push(&cp.args, "status");
593 run_command(&cp);
@@ -1088,7 +1088,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg,
1088 cp_upd_index.git_cmd = 1;
1089 strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
1090 "--remove", "--stdin", NULL);
1091 - strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1091 + strvec_pushf(&cp_upd_index.env, "GIT_INDEX_FILE=%s",
1092 stash_index_path.buf);
1093
1094 strbuf_addf(&untracked_msg, "untracked files on %s\n", msg->buf);
@@ -1162,7 +1162,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
1162
1163 cp_read_tree.git_cmd = 1;
1164 strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1165 - strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1165 + strvec_pushf(&cp_read_tree.env, "GIT_INDEX_FILE=%s",
1166 stash_index_path.buf);
1167 if (run_command(&cp_read_tree)) {
1168 ret = -1;
@@ -1249,7 +1249,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
1249 strvec_pushl(&cp_upd_index.args, "update-index",
1250 "--ignore-skip-worktree-entries",
1251 "-z", "--add", "--remove", "--stdin", NULL);
1252 - strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1252 + strvec_pushf(&cp_upd_index.env, "GIT_INDEX_FILE=%s",
1253 stash_index_path.buf);
1254
1255 if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1525,7 +1525,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1525 cp.git_cmd = 1;
1526 if (startup_info->original_cwd) {
1527 cp.dir = startup_info->original_cwd;
1528 - strvec_pushf(&cp.env_array, "%s=%s",
1528 + strvec_pushf(&cp.env, "%s=%s",
1529 GIT_WORK_TREE_ENVIRONMENT,
1530 the_repository->worktree);
1531 }
builtin/submodule--helper.c
+21 -21
@@ -292,7 +292,7 @@ static char *compute_rev_name(const char *sub_path, const char* object_id)
292
293 for (d = describe_argv; *d; d++) {
294 struct child_process cp = CHILD_PROCESS_INIT;
295 - prepare_submodule_repo_env(&cp.env_array);
295 + prepare_submodule_repo_env(&cp.env);
296 cp.dir = sub_path;
297 cp.git_cmd = 1;
298 cp.no_stderr = 1;
@@ -479,7 +479,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
479 if (!is_submodule_populated_gently(path, NULL))
480 goto cleanup;
481
482 - prepare_submodule_repo_env(&cp.env_array);
482 + prepare_submodule_repo_env(&cp.env);
483
484 /*
485 * 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,
499 char *toplevel = xgetcwd();
500 struct strbuf sb = STRBUF_INIT;
501
502 - strvec_pushf(&cp.env_array, "name=%s", sub->name);
503 - strvec_pushf(&cp.env_array, "sm_path=%s", path);
504 - strvec_pushf(&cp.env_array, "displaypath=%s", displaypath);
505 - strvec_pushf(&cp.env_array, "sha1=%s",
502 + strvec_pushf(&cp.env, "name=%s", sub->name);
503 + strvec_pushf(&cp.env, "sm_path=%s", path);
504 + strvec_pushf(&cp.env, "displaypath=%s", displaypath);
505 + strvec_pushf(&cp.env, "sha1=%s",
506 oid_to_hex(ce_oid));
507 - strvec_pushf(&cp.env_array, "toplevel=%s", toplevel);
507 + strvec_pushf(&cp.env, "toplevel=%s", toplevel);
508
509 /*
510 * 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,
536
537 cpr.git_cmd = 1;
538 cpr.dir = path;
539 - prepare_submodule_repo_env(&cpr.env_array);
539 + prepare_submodule_repo_env(&cpr.env);
540
541 strvec_pushl(&cpr.args, "--super-prefix", NULL);
542 strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -833,7 +833,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
833
834 cpr.git_cmd = 1;
835 cpr.dir = path;
836 - prepare_submodule_repo_env(&cpr.env_array);
836 + prepare_submodule_repo_env(&cpr.env);
837
838 strvec_push(&cpr.args, "--super-prefix");
839 strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -955,7 +955,7 @@ static char *verify_submodule_committish(const char *sm_path,
955
956 cp_rev_parse.git_cmd = 1;
957 cp_rev_parse.dir = sm_path;
958 - prepare_submodule_repo_env(&cp_rev_parse.env_array);
958 + prepare_submodule_repo_env(&cp_rev_parse.env);
959 strvec_pushl(&cp_rev_parse.args, "rev-parse", "-q", "--short", NULL);
960 strvec_pushf(&cp_rev_parse.args, "%s^0", committish);
961 strvec_push(&cp_rev_parse.args, "--");
@@ -996,7 +996,7 @@ static void print_submodule_summary(struct summary_cb *info, char *errmsg,
996
997 cp_log.git_cmd = 1;
998 cp_log.dir = p->sm_path;
999 - prepare_submodule_repo_env(&cp_log.env_array);
999 + prepare_submodule_repo_env(&cp_log.env);
1000 strvec_pushl(&cp_log.args, "log", NULL);
1001
1002 if (S_ISGITLINK(p->mod_src) && S_ISGITLINK(p->mod_dst)) {
@@ -1113,7 +1113,7 @@ static void generate_submodule_summary(struct summary_cb *info,
1113
1114 cp_rev_list.git_cmd = 1;
1115 cp_rev_list.dir = p->sm_path;
1116 - prepare_submodule_repo_env(&cp_rev_list.env_array);
1116 + prepare_submodule_repo_env(&cp_rev_list.env);
1117
1118 if (!capture_command(&cp_rev_list, &sb_rev_list, 0))
1119 total_commits = atoi(sb_rev_list.buf);
@@ -1414,7 +1414,7 @@ static void sync_submodule(const char *path, const char *prefix,
1414
1415 cpr.git_cmd = 1;
1416 cpr.dir = path;
1417 - prepare_submodule_repo_env(&cpr.env_array);
1417 + prepare_submodule_repo_env(&cpr.env);
1418
1419 strvec_push(&cpr.args, "--super-prefix");
1420 strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -1819,7 +1819,7 @@ static int clone_submodule(struct module_clone_data *clone_data)
1819 strvec_push(&cp.args, clone_data->path);
1820
1821 cp.git_cmd = 1;
1822 - prepare_submodule_repo_env(&cp.env_array);
1822 + prepare_submodule_repo_env(&cp.env);
1823 cp.no_stdin = 1;
1824
1825 if(run_command(&cp))
@@ -2295,7 +2295,7 @@ static int is_tip_reachable(const char *path, struct object_id *oid)
2295 cp.no_stderr = 1;
2296 strvec_pushl(&cp.args, "rev-list", "-n", "1", hex, "--not", "--all", NULL);
2297
2298 - prepare_submodule_repo_env(&cp.env_array);
2298 + prepare_submodule_repo_env(&cp.env);
2299
2300 if (capture_command(&cp, &rev, GIT_MAX_HEXSZ + 1) || rev.len)
2301 return 0;
@@ -2307,7 +2307,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str
2307 {
2308 struct child_process cp = CHILD_PROCESS_INIT;
2309
2310 - prepare_submodule_repo_env(&cp.env_array);
2310 + prepare_submodule_repo_env(&cp.env);
2311 cp.git_cmd = 1;
2312 cp.dir = xstrdup(module_path);
2313
@@ -2364,7 +2364,7 @@ static int run_update_command(struct update_data *ud, int subforce)
2364 strvec_push(&cp.args, oid);
2365
2366 cp.dir = xstrdup(ud->sm_path);
2367 - prepare_submodule_repo_env(&cp.env_array);
2367 + prepare_submodule_repo_env(&cp.env);
2368 if (run_command(&cp)) {
2369 switch (ud->update_strategy.type) {
2370 case SM_UPDATE_CHECKOUT:
@@ -2630,7 +2630,7 @@ static int update_submodule(struct update_data *update_data)
2630
2631 cp.dir = update_data->sm_path;
2632 cp.git_cmd = 1;
2633 - prepare_submodule_repo_env(&cp.env_array);
2633 + prepare_submodule_repo_env(&cp.env);
2634 update_data_to_args(&next, &cp.args);
2635
2636 /* die() if child process die()'d */
@@ -3123,9 +3123,9 @@ static void append_fetch_remotes(struct strbuf *msg, const char *git_dir_path)
3123 struct strbuf sb_remote_out = STRBUF_INIT;
3124
3125 cp_remote.git_cmd = 1;
3126 - strvec_pushf(&cp_remote.env_array,
3126 + strvec_pushf(&cp_remote.env,
3127 "GIT_DIR=%s", git_dir_path);
3128 - strvec_push(&cp_remote.env_array, "GIT_WORK_TREE=.");
3128 + strvec_push(&cp_remote.env, "GIT_WORK_TREE=.");
3129 strvec_pushl(&cp_remote.args, "remote", "-v", NULL);
3130 if (!capture_command(&cp_remote, &sb_remote_out, 0)) {
3131 char *next_line;
@@ -3209,7 +3209,7 @@ static int add_submodule(const struct add_data *add_data)
3209 if (clone_submodule(&clone_data))
3210 return -1;
3211
3212 - prepare_submodule_repo_env(&cp.env_array);
3212 + prepare_submodule_repo_env(&cp.env);
3213 cp.git_cmd = 1;
3214 cp.dir = add_data->sm_path;
3215 /*
builtin/worktree.c
+4 -4
@@ -301,7 +301,7 @@ static int checkout_worktree(const struct add_opts *opts,
301 strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
302 if (opts->quiet)
303 strvec_push(&cp.args, "--quiet");
304 - strvec_pushv(&cp.env_array, child_env->v);
304 + strvec_pushv(&cp.env, child_env->v);
305 return run_command(&cp);
306 }
307
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,
433 strvec_push(&cp.args, "--quiet");
434 }
435
436 - strvec_pushv(&cp.env_array, child_env.v);
436 + strvec_pushv(&cp.env, child_env.v);
437 ret = run_command(&cp);
438 if (ret)
439 goto done;
@@ -989,9 +989,9 @@ static void check_clean_worktree(struct worktree *wt,
989 validate_no_submodules(wt);
990
991 child_process_init(&cp);
992 - strvec_pushf(&cp.env_array, "%s=%s/.git",
992 + strvec_pushf(&cp.env, "%s=%s/.git",
993 GIT_DIR_ENVIRONMENT, wt->path);
994 - strvec_pushf(&cp.env_array, "%s=%s",
994 + strvec_pushf(&cp.env, "%s=%s",
995 GIT_WORK_TREE_ENVIRONMENT, wt->path);
996 strvec_pushl(&cp.args, "status",
997 "--porcelain", "--ignore-submodules=none",
connect.c
+5 -4
@@ -1327,7 +1327,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1327
1328 strvec_push(&detect.args, ssh);
1329 strvec_push(&detect.args, "-G");
1330 - push_ssh_options(&detect.args, &detect.env_array,
1330 + push_ssh_options(&detect.args, &detect.env,
1331 VARIANT_SSH, port, version, flags);
1332 strvec_push(&detect.args, ssh_host);
1333
@@ -1335,7 +1335,8 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1335 }
1336
1337 strvec_push(&conn->args, ssh);
1338 - push_ssh_options(&conn->args, &conn->env_array, variant, port, version, flags);
1338 + push_ssh_options(&conn->args, &conn->env, variant, port, version,
1339 + flags);
1340 strvec_push(&conn->args, ssh_host);
1341 }
1342
@@ -1397,7 +1398,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1398
1399 /* remove repo-local variables from the environment */
1400 for (var = local_repo_env; *var; var++)
1400 - strvec_push(&conn->env_array, *var);
1401 + strvec_push(&conn->env, *var);
1402
1403 conn->use_shell = 1;
1404 conn->in = conn->out = -1;
@@ -1429,7 +1430,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1430 transport_check_allowed("file");
1431 conn->trace2_child_class = "transport/file";
1432 if (version > 0) {
1432 - strvec_pushf(&conn->env_array,
1433 + strvec_pushf(&conn->env,
1434 GIT_PROTOCOL_ENVIRONMENT "=version=%d",
1435 version);
1436 }
connected.c
+1 -1
@@ -110,7 +110,7 @@ no_promisor_pack_found:
110
111 rev_list.git_cmd = 1;
112 if (opt->env)
113 - strvec_pushv(&rev_list.env_array, opt->env);
113 + strvec_pushv(&rev_list.env, opt->env);
114 rev_list.in = -1;
115 rev_list.no_stdout = 1;
116 if (opt->err_fd)
daemon.c
+7 -7
@@ -484,7 +484,7 @@ static int upload_pack(const struct strvec *env)
484 strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
485 strvec_pushf(&cld.args, "--timeout=%u", timeout);
486
487 - strvec_pushv(&cld.env_array, env->v);
487 + strvec_pushv(&cld.env, env->v);
488
489 return run_service_command(&cld);
490 }
@@ -494,7 +494,7 @@ static int upload_archive(const struct strvec *env)
494 struct child_process cld = CHILD_PROCESS_INIT;
495 strvec_push(&cld.args, "upload-archive");
496
497 - strvec_pushv(&cld.env_array, env->v);
497 + strvec_pushv(&cld.env, env->v);
498
499 return run_service_command(&cld);
500 }
@@ -504,7 +504,7 @@ static int receive_pack(const struct strvec *env)
504 struct child_process cld = CHILD_PROCESS_INIT;
505 strvec_push(&cld.args, "receive-pack");
506
507 - strvec_pushv(&cld.env_array, env->v);
507 + strvec_pushv(&cld.env, env->v);
508
509 return run_service_command(&cld);
510 }
@@ -904,16 +904,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
904 char buf[128] = "";
905 struct sockaddr_in *sin_addr = (void *) addr;
906 inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf));
907 - strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf);
908 - strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
907 + strvec_pushf(&cld.env, "REMOTE_ADDR=%s", buf);
908 + strvec_pushf(&cld.env, "REMOTE_PORT=%d",
909 ntohs(sin_addr->sin_port));
910 #ifndef NO_IPV6
911 } else if (addr->sa_family == AF_INET6) {
912 char buf[128] = "";
913 struct sockaddr_in6 *sin6_addr = (void *) addr;
914 inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf));
915 - strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf);
916 - strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
915 + strvec_pushf(&cld.env, "REMOTE_ADDR=[%s]", buf);
916 + strvec_pushf(&cld.env, "REMOTE_PORT=%d",
917 ntohs(sin6_addr->sin6_port));
918 #endif
919 }
editor.c
+1 -1
@@ -80,7 +80,7 @@ static int launch_specified_editor(const char *editor, const char *path,
80
81 strvec_pushl(&p.args, editor, realpath.buf, NULL);
82 if (env)
83 - strvec_pushv(&p.env_array, (const char **)env);
83 + strvec_pushv(&p.env, (const char **)env);
84 p.use_shell = 1;
85 p.trace2_child_class = "editor";
86 if (start_command(&p) < 0) {
hook.c
+1 -1
@@ -54,7 +54,7 @@ static int pick_next_hook(struct child_process *cp,
54 return 0;
55
56 cp->no_stdin = 1;
57 - strvec_pushv(&cp->env_array, hook_cb->options->env.v);
57 + strvec_pushv(&cp->env, hook_cb->options->env.v);
58 cp->stdout_to_stderr = 1;
59 cp->trace2_hook_name = hook_cb->hook_name;
60 cp->dir = hook_cb->options->dir;
http-backend.c
+2 -2
@@ -476,9 +476,9 @@ static void run_service(const char **argv, int buffer_input)
476 host = "(none)";
477
478 if (!getenv("GIT_COMMITTER_NAME"))
479 - strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
479 + strvec_pushf(&cld.env, "GIT_COMMITTER_NAME=%s", user);
480 if (!getenv("GIT_COMMITTER_EMAIL"))
481 - strvec_pushf(&cld.env_array,
481 + strvec_pushf(&cld.env,
482 "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
483
484 strvec_pushv(&cld.args, argv);
object-file.c
+1 -1
@@ -838,7 +838,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,
838 }
839 }
840
841 - strvec_pushv(&cmd->env_array, (const char **)local_repo_env);
841 + strvec_pushv(&cmd->env, (const char **)local_repo_env);
842 cmd->out = -1;
843 }
844
pager.c
+2 -2
@@ -99,7 +99,7 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager)
99 {
100 strvec_push(&pager_process->args, pager);
101 pager_process->use_shell = 1;
102 - setup_pager_env(&pager_process->env_array);
102 + setup_pager_env(&pager_process->env);
103 pager_process->trace2_child_class = "pager";
104 }
105
@@ -129,7 +129,7 @@ void setup_pager(void)
129 /* spawn the pager */
130 prepare_pager_args(&pager_process, pager);
131 pager_process.in = -1;
132 - strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
132 + strvec_push(&pager_process.env, "GIT_PAGER_IN_USE");
133 if (start_command(&pager_process))
134 return;
135
promisor-remote.c
+1 -1
@@ -22,7 +22,7 @@ static int fetch_objects(struct repository *repo,
22 child.git_cmd = 1;
23 child.in = -1;
24 if (repo != the_repository)
25 - prepare_other_repo_env(&child.env_array, repo->gitdir);
25 + prepare_other_repo_env(&child.env, repo->gitdir);
26 strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop",
27 "fetch", remote_name, "--no-tags",
28 "--no-write-fetch-head", "--recurse-submodules=no",
run-command.c
+7 -6
@@ -20,7 +20,7 @@ void child_process_init(struct child_process *child)
20 void child_process_clear(struct child_process *child)
21 {
22 strvec_clear(&child->args);
23 - strvec_clear(&child->env_array);
23 + strvec_clear(&child->env);
24 }
25
26 struct child_to_clean {
@@ -646,7 +646,7 @@ static void trace_run_command(const struct child_process *cp)
646 sq_quote_buf_pretty(&buf, cp->dir);
647 strbuf_addch(&buf, ';');
648 }
649 - trace_add_env(&buf, cp->env_array.v);
649 + trace_add_env(&buf, cp->env.v);
650 if (cp->git_cmd)
651 strbuf_addstr(&buf, " git");
652 sq_quote_argv_pretty(&buf, cp->args.v);
@@ -751,7 +751,7 @@ fail_pipe:
751 set_cloexec(null_fd);
752 }
753
754 - childenv = prep_childenv(cmd->env_array.v);
754 + childenv = prep_childenv(cmd->env.v);
755 atfork_prepare(&as);
756
757 /*
@@ -914,8 +914,9 @@ end_of_spawn:
914 else if (cmd->use_shell)
915 cmd->args.v = prepare_shell_cmd(&nargv, sargv);
916
917 - cmd->pid = mingw_spawnvpe(cmd->args.v[0], cmd->args.v, (char**) cmd->env_array.v,
918 - cmd->dir, fhin, fhout, fherr);
917 + cmd->pid = mingw_spawnvpe(cmd->args.v[0], cmd->args.v,
918 + (char**) cmd->env.v,
919 + cmd->dir, fhin, fhout, fherr);
920 failed_errno = errno;
921 if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
922 error_errno("cannot spawn %s", cmd->args.v[0]);
@@ -1031,7 +1032,7 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
1032 cmd.close_object_store = opt & RUN_CLOSE_OBJECT_STORE ? 1 : 0;
1033 cmd.dir = dir;
1034 if (env)
1034 - strvec_pushv(&cmd.env_array, (const char **)env);
1035 + strvec_pushv(&cmd.env, (const char **)env);
1036 cmd.trace2_child_class = tr2_class;
1037 return run_command(&cmd);
1038 }
run-command.h
+2 -2
@@ -73,7 +73,7 @@ struct child_process {
73 * The memory in .env_array will be cleaned up automatically during
74 * `finish_command` (or during `start_command` when it is unsuccessful).
75 */
76 - struct strvec env_array;
76 + struct strvec env;
77 pid_t pid;
78
79 int trace2_child_id;
@@ -147,7 +147,7 @@ struct child_process {
147
148 #define CHILD_PROCESS_INIT { \
149 .args = STRVEC_INIT, \
150 - .env_array = STRVEC_INIT, \
150 + .env = STRVEC_INIT, \
151 }
152
153 /**
sequencer.c
+8 -8
@@ -1000,7 +1000,7 @@ static int run_git_commit(const char *defmsg,
1000 if (is_rebase_i(opts) &&
1001 ((opts->committer_date_is_author_date && !opts->ignore_date) ||
1002 !(!defmsg && (flags & AMEND_MSG))) &&
1003 - read_env_script(&cmd.env_array)) {
1003 + read_env_script(&cmd.env)) {
1004 const char *gpg_opt = gpg_sign_opt_quoted(opts);
1005
1006 return error(_(staged_changes_advice),
@@ -1008,12 +1008,12 @@ static int run_git_commit(const char *defmsg,
1008 }
1009
1010 if (opts->committer_date_is_author_date)
1011 - strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
1011 + strvec_pushf(&cmd.env, "GIT_COMMITTER_DATE=%s",
1012 opts->ignore_date ?
1013 "" :
1014 - author_date_from_env_array(&cmd.env_array));
1014 + author_date_from_env_array(&cmd.env));
1015 if (opts->ignore_date)
1016 - strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
1016 + strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
1017
1018 strvec_push(&cmd.args, "commit");
1019
@@ -3912,7 +3912,7 @@ static int do_merge(struct repository *r,
3912 /* Octopus merge */
3913 struct child_process cmd = CHILD_PROCESS_INIT;
3914
3915 - if (read_env_script(&cmd.env_array)) {
3915 + if (read_env_script(&cmd.env)) {
3916 const char *gpg_opt = gpg_sign_opt_quoted(opts);
3917
3918 ret = error(_(staged_changes_advice), gpg_opt, gpg_opt);
@@ -3920,12 +3920,12 @@ static int do_merge(struct repository *r,
3920 }
3921
3922 if (opts->committer_date_is_author_date)
3923 - strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
3923 + strvec_pushf(&cmd.env, "GIT_COMMITTER_DATE=%s",
3924 opts->ignore_date ?
3925 "" :
3926 - author_date_from_env_array(&cmd.env_array));
3926 + author_date_from_env_array(&cmd.env));
3927 if (opts->ignore_date)
3928 - strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
3928 + strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
3929
3930 cmd.git_cmd = 1;
3931 strvec_push(&cmd.args, "merge");
submodule.c
+19 -19
@@ -711,15 +711,15 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
711 if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED))
712 strvec_push(&cp.args, oid_to_hex(new_oid));
713
714 - prepare_submodule_repo_env(&cp.env_array);
714 + prepare_submodule_repo_env(&cp.env);
715
716 if (!is_directory(path)) {
717 /* fall back to absorbed git dir, if any */
718 if (!sub)
719 goto done;
720 cp.dir = sub->gitdir;
721 - strvec_push(&cp.env_array, GIT_DIR_ENVIRONMENT "=.");
722 - strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
721 + strvec_push(&cp.env, GIT_DIR_ENVIRONMENT "=.");
722 + strvec_push(&cp.env, GIT_WORK_TREE_ENVIRONMENT "=.");
723 }
724
725 if (start_command(&cp)) {
@@ -1019,7 +1019,7 @@ static int submodule_has_commits(struct repository *r,
1019 oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
1020 strvec_pushl(&cp.args, "--not", "--all", NULL);
1021
1022 - prepare_submodule_repo_env(&cp.env_array);
1022 + prepare_submodule_repo_env(&cp.env);
1023 cp.git_cmd = 1;
1024 cp.no_stdin = 1;
1025 cp.dir = path;
@@ -1060,7 +1060,7 @@ static int submodule_needs_pushing(struct repository *r,
1060 oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
1061 strvec_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
1062
1063 - prepare_submodule_repo_env(&cp.env_array);
1063 + prepare_submodule_repo_env(&cp.env);
1064 cp.git_cmd = 1;
1065 cp.no_stdin = 1;
1066 cp.out = -1;
@@ -1146,7 +1146,7 @@ static int push_submodule(const char *path,
1146 strvec_push(&cp.args, rs->raw[i]);
1147 }
1148
1149 - prepare_submodule_repo_env(&cp.env_array);
1149 + prepare_submodule_repo_env(&cp.env);
1150 cp.git_cmd = 1;
1151 cp.no_stdin = 1;
1152 cp.dir = path;
@@ -1177,7 +1177,7 @@ static void submodule_push_check(const char *path, const char *head,
1177 for (i = 0; i < rs->raw_nr; i++)
1178 strvec_push(&cp.args, rs->raw[i]);
1179
1180 - prepare_submodule_repo_env(&cp.env_array);
1180 + prepare_submodule_repo_env(&cp.env);
1181 cp.git_cmd = 1;
1182 cp.no_stdin = 1;
1183 cp.no_stdout = 1;
@@ -1678,7 +1678,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
1678
1679 child_process_init(cp);
1680 cp->dir = task->repo->gitdir;
1681 - prepare_submodule_repo_env_in_gitdir(&cp->env_array);
1681 + prepare_submodule_repo_env_in_gitdir(&cp->env);
1682 cp->git_cmd = 1;
1683 strvec_init(&cp->args);
1684 if (task->git_args.nr)
@@ -1708,7 +1708,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
1708 spf->prefix, task->sub->path);
1709
1710 child_process_init(cp);
1711 - prepare_submodule_repo_env_in_gitdir(&cp->env_array);
1711 + prepare_submodule_repo_env_in_gitdir(&cp->env);
1712 cp->git_cmd = 1;
1713 cp->dir = task->repo->gitdir;
1714
@@ -1882,7 +1882,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
1882 if (ignore_untracked)
1883 strvec_push(&cp.args, "-uno");
1884
1885 - prepare_submodule_repo_env(&cp.env_array);
1885 + prepare_submodule_repo_env(&cp.env);
1886 cp.git_cmd = 1;
1887 cp.no_stdin = 1;
1888 cp.out = -1;
@@ -1954,7 +1954,7 @@ int submodule_uses_gitfile(const char *path)
1954 "submodule", "foreach", "--quiet", "--recursive",
1955 "test -f .git", NULL);
1956
1957 - prepare_submodule_repo_env(&cp.env_array);
1957 + prepare_submodule_repo_env(&cp.env);
1958 cp.git_cmd = 1;
1959 cp.no_stdin = 1;
1960 cp.no_stderr = 1;
@@ -1997,7 +1997,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
1997 if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
1998 strvec_push(&cp.args, "--ignored");
1999
2000 - prepare_submodule_repo_env(&cp.env_array);
2000 + prepare_submodule_repo_env(&cp.env);
2001 cp.git_cmd = 1;
2002 cp.no_stdin = 1;
2003 cp.out = -1;
@@ -2052,7 +2052,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
2052 {
2053 struct child_process cp = CHILD_PROCESS_INIT;
2054
2055 - prepare_submodule_repo_env(&cp.env_array);
2055 + prepare_submodule_repo_env(&cp.env);
2056
2057 cp.git_cmd = 1;
2058 strvec_pushl(&cp.args, "diff-index", "--quiet",
@@ -2069,7 +2069,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
2069 static void submodule_reset_index(const char *path)
2070 {
2071 struct child_process cp = CHILD_PROCESS_INIT;
2072 - prepare_submodule_repo_env(&cp.env_array);
2072 + prepare_submodule_repo_env(&cp.env);
2073
2074 cp.git_cmd = 1;
2075 cp.no_stdin = 1;
@@ -2153,7 +2153,7 @@ int submodule_move_head(const char *path,
2153 }
2154 }
2155
2156 - prepare_submodule_repo_env(&cp.env_array);
2156 + prepare_submodule_repo_env(&cp.env);
2157
2158 cp.git_cmd = 1;
2159 cp.no_stdin = 1;
@@ -2191,7 +2191,7 @@ int submodule_move_head(const char *path,
2191 cp.no_stdin = 1;
2192 cp.dir = path;
2193
2194 - prepare_submodule_repo_env(&cp.env_array);
2194 + prepare_submodule_repo_env(&cp.env);
2195 strvec_pushl(&cp.args, "update-ref", "HEAD",
2196 "--no-deref", new_head, NULL);
2197
@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,
2374 strvec_pushl(&cp.args, "--super-prefix", sb.buf,
2375 "submodule--helper",
2376 "absorb-git-dirs", NULL);
2377 - prepare_submodule_repo_env(&cp.env_array);
2377 + prepare_submodule_repo_env(&cp.env);
2378 if (run_command(&cp))
2379 die(_("could not recurse into submodule '%s'"), path);
2380
@@ -2407,8 +2407,8 @@ int get_superproject_working_tree(struct strbuf *buf)
2407 subpath = relative_path(cwd, one_up.buf, &sb);
2408 strbuf_release(&one_up);
2409
2410 - prepare_submodule_repo_env(&cp.env_array);
2411 - strvec_pop(&cp.env_array);
2410 + prepare_submodule_repo_env(&cp.env);
2411 + strvec_pop(&cp.env);
2412
2413 strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
2414 "ls-files", "-z", "--stage", "--full-name", "--",
t/helper/test-run-command.c
+1 -1
@@ -390,7 +390,7 @@ int cmd__run_command(int argc, const char **argv)
390 while (!strcmp(argv[1], "env")) {
391 if (!argv[2])
392 die("env specifier without a value");
393 - strvec_push(&proc.env_array, argv[2]);
393 + strvec_push(&proc.env, argv[2]);
394 argv += 2;
395 argc -= 2;
396 }
trailer.c
+1 -1
@@ -236,7 +236,7 @@ static char *apply_command(struct conf_info *conf, const char *arg)
236 strbuf_replace(&cmd, TRAILER_ARG_STRING, arg);
237 strvec_push(&cp.args, cmd.buf);
238 }
239 - strvec_pushv(&cp.env_array, (const char **)local_repo_env);
239 + strvec_pushv(&cp.env, (const char **)local_repo_env);
240 cp.no_stdin = 1;
241 cp.use_shell = 1;
242
transport-helper.c
+1 -1
@@ -135,7 +135,7 @@ static struct child_process *get_helper(struct transport *transport)
135 helper->silent_exec_failure = 1;
136
137 if (have_git_dir())
138 - strvec_pushf(&helper->env_array, "%s=%s",
138 + strvec_pushf(&helper->env, "%s=%s",
139 GIT_DIR_ENVIRONMENT, get_git_dir());
140
141 helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */
wt-status.c
+1 -1
@@ -982,7 +982,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
982 struct strbuf summary = STRBUF_INIT;
983 char *summary_content;
984
985 - strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s", s->index_file);
985 + strvec_pushf(&sm_summary.env, "GIT_INDEX_FILE=%s", s->index_file);
986
987 strvec_push(&sm_summary.args, "submodule");
988 strvec_push(&sm_summary.args, "summary");