Skip to content

Commit c21fa3b

Browse files
committed
Merge branch 'ab/env-array'
Rename .env_array member to .env in the child_process structure. * ab/env-array: run-command API users: use "env" not "env_array" in comments & names run-command API: rename "env_array" to "env"
2 parents 597553e + b319325 commit c21fa3b

25 files changed

+127
-125
lines changed

add-patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void setup_child_process(struct add_p_state *s,
305305
va_end(ap);
306306

307307
cp->git_cmd = 1;
308-
strvec_pushf(&cp->env_array,
308+
strvec_pushf(&cp->env,
309309
INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
310310
}
311311

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static int submodule_create_branch(struct repository *r,
587587
child.err = -1;
588588
child.stdout_to_stderr = 1;
589589

590-
prepare_other_repo_env(&child.env_array, r->gitdir);
590+
prepare_other_repo_env(&child.env, r->gitdir);
591591
/*
592592
* submodule_create_branch() is indirectly invoked by "git
593593
* branch", but we cannot invoke "git branch" in the child

builtin/difftool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
217217
update_index.use_shell = 0;
218218
update_index.clean_on_exit = 1;
219219
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);
221221
/* Ignore any errors of update-index */
222222
run_command(&update_index);
223223

@@ -230,7 +230,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
230230
diff_files.clean_on_exit = 1;
231231
diff_files.out = -1;
232232
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);
234234
if (start_command(&diff_files))
235235
die("could not obtain raw diff");
236236
fp = xfdopen(diff_files.out, "r");
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix,
675675

676676
child->git_cmd = 1;
677677
child->dir = prefix;
678-
strvec_pushv(&child->env_array, env);
678+
strvec_pushv(&child->env, env);
679679

680680
return run_command(child);
681681
}

builtin/receive-pack.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -764,23 +764,23 @@ static void prepare_push_cert_sha1(struct child_process *proc)
764764
nonce_status = check_nonce(push_cert.buf, bogs);
765765
}
766766
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",
768768
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",
770770
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",
772772
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",
774774
sigcheck.result);
775775
if (push_cert_nonce) {
776-
strvec_pushf(&proc->env_array,
776+
strvec_pushf(&proc->env,
777777
"GIT_PUSH_CERT_NONCE=%s",
778778
push_cert_nonce);
779-
strvec_pushf(&proc->env_array,
779+
strvec_pushf(&proc->env,
780780
"GIT_PUSH_CERT_NONCE_STATUS=%s",
781781
nonce_status);
782782
if (nonce_status == NONCE_SLOP)
783-
strvec_pushf(&proc->env_array,
783+
strvec_pushf(&proc->env,
784784
"GIT_PUSH_CERT_NONCE_SLOP=%ld",
785785
nonce_stamp_slop);
786786
}
@@ -815,17 +815,17 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,
815815
if (feed_state->push_options) {
816816
size_t i;
817817
for (i = 0; i < feed_state->push_options->nr; i++)
818-
strvec_pushf(&proc.env_array,
818+
strvec_pushf(&proc.env,
819819
"GIT_PUSH_OPTION_%"PRIuMAX"=%s",
820820
(uintmax_t)i,
821821
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"",
823823
(uintmax_t)feed_state->push_options->nr);
824824
} else
825-
strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT");
825+
strvec_pushf(&proc.env, "GIT_PUSH_OPTION_COUNT");
826826

827827
if (tmp_objdir)
828-
strvec_pushv(&proc.env_array, tmp_objdir_env(tmp_objdir));
828+
strvec_pushv(&proc.env, tmp_objdir_env(tmp_objdir));
829829

830830
if (use_sideband) {
831831
memset(&muxer, 0, sizeof(muxer));
@@ -1357,7 +1357,7 @@ static const char *push_to_deploy(unsigned char *sha1,
13571357

13581358
strvec_pushl(&child.args, "update-index", "-q", "--ignore-submodules",
13591359
"--refresh", NULL);
1360-
strvec_pushv(&child.env_array, env->v);
1360+
strvec_pushv(&child.env, env->v);
13611361
child.dir = work_tree;
13621362
child.no_stdin = 1;
13631363
child.stdout_to_stderr = 1;
@@ -1369,7 +1369,7 @@ static const char *push_to_deploy(unsigned char *sha1,
13691369
child_process_init(&child);
13701370
strvec_pushl(&child.args, "diff-files", "--quiet",
13711371
"--ignore-submodules", "--", NULL);
1372-
strvec_pushv(&child.env_array, env->v);
1372+
strvec_pushv(&child.env, env->v);
13731373
child.dir = work_tree;
13741374
child.no_stdin = 1;
13751375
child.stdout_to_stderr = 1;
@@ -1383,7 +1383,7 @@ static const char *push_to_deploy(unsigned char *sha1,
13831383
/* diff-index with either HEAD or an empty tree */
13841384
head_has_history() ? "HEAD" : empty_tree_oid_hex(),
13851385
"--", NULL);
1386-
strvec_pushv(&child.env_array, env->v);
1386+
strvec_pushv(&child.env, env->v);
13871387
child.no_stdin = 1;
13881388
child.no_stdout = 1;
13891389
child.stdout_to_stderr = 0;
@@ -1394,7 +1394,7 @@ static const char *push_to_deploy(unsigned char *sha1,
13941394
child_process_init(&child);
13951395
strvec_pushl(&child.args, "read-tree", "-u", "-m", hash_to_hex(sha1),
13961396
NULL);
1397-
strvec_pushv(&child.env_array, env->v);
1397+
strvec_pushv(&child.env, env->v);
13981398
child.dir = work_tree;
13991399
child.no_stdin = 1;
14001400
child.no_stdout = 1;
@@ -2214,7 +2214,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
22142214
close(err_fd);
22152215
return "unable to create temporary object directory";
22162216
}
2217-
strvec_pushv(&child.env_array, tmp_objdir_env(tmp_objdir));
2217+
strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
22182218

22192219
/*
22202220
* Normally we just pass the tmp_objdir environment to the child

builtin/stash.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static int restore_untracked(struct object_id *u_tree)
356356
cp.git_cmd = 1;
357357
strvec_push(&cp.args, "read-tree");
358358
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",
360360
stash_index_path.buf);
361361
if (run_command(&cp)) {
362362
remove_path(stash_index_path.buf);
@@ -366,7 +366,7 @@ static int restore_untracked(struct object_id *u_tree)
366366
child_process_init(&cp);
367367
cp.git_cmd = 1;
368368
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",
370370
stash_index_path.buf);
371371

372372
res = run_command(&cp);
@@ -602,9 +602,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
602602
*/
603603
cp.git_cmd = 1;
604604
cp.dir = prefix;
605-
strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
605+
strvec_pushf(&cp.env, GIT_WORK_TREE_ENVIRONMENT"=%s",
606606
absolute_path(get_git_work_tree()));
607-
strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
607+
strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
608608
absolute_path(get_git_dir()));
609609
strvec_push(&cp.args, "status");
610610
run_command(&cp);
@@ -1115,7 +1115,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg,
11151115
cp_upd_index.git_cmd = 1;
11161116
strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
11171117
"--remove", "--stdin", NULL);
1118-
strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1118+
strvec_pushf(&cp_upd_index.env, "GIT_INDEX_FILE=%s",
11191119
stash_index_path.buf);
11201120

11211121
strbuf_addf(&untracked_msg, "untracked files on %s\n", msg->buf);
@@ -1189,7 +1189,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
11891189

11901190
cp_read_tree.git_cmd = 1;
11911191
strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1192-
strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1192+
strvec_pushf(&cp_read_tree.env, "GIT_INDEX_FILE=%s",
11931193
stash_index_path.buf);
11941194
if (run_command(&cp_read_tree)) {
11951195
ret = -1;
@@ -1276,7 +1276,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
12761276
strvec_pushl(&cp_upd_index.args, "update-index",
12771277
"--ignore-skip-worktree-entries",
12781278
"-z", "--add", "--remove", "--stdin", NULL);
1279-
strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1279+
strvec_pushf(&cp_upd_index.env, "GIT_INDEX_FILE=%s",
12801280
stash_index_path.buf);
12811281

12821282
if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1551,7 +1551,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
15511551
cp.git_cmd = 1;
15521552
if (startup_info->original_cwd) {
15531553
cp.dir = startup_info->original_cwd;
1554-
strvec_pushf(&cp.env_array, "%s=%s",
1554+
strvec_pushf(&cp.env, "%s=%s",
15551555
GIT_WORK_TREE_ENVIRONMENT,
15561556
the_repository->worktree);
15571557
}

builtin/submodule--helper.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static char *compute_rev_name(const char *sub_path, const char* object_id)
163163

164164
for (d = describe_argv; *d; d++) {
165165
struct child_process cp = CHILD_PROCESS_INIT;
166-
prepare_submodule_repo_env(&cp.env_array);
166+
prepare_submodule_repo_env(&cp.env);
167167
cp.dir = sub_path;
168168
cp.git_cmd = 1;
169169
cp.no_stderr = 1;
@@ -350,7 +350,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
350350
if (!is_submodule_populated_gently(path, NULL))
351351
goto cleanup;
352352

353-
prepare_submodule_repo_env(&cp.env_array);
353+
prepare_submodule_repo_env(&cp.env);
354354

355355
/*
356356
* For the purpose of executing <command> in the submodule,
@@ -370,12 +370,12 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
370370
char *toplevel = xgetcwd();
371371
struct strbuf sb = STRBUF_INIT;
372372

373-
strvec_pushf(&cp.env_array, "name=%s", sub->name);
374-
strvec_pushf(&cp.env_array, "sm_path=%s", path);
375-
strvec_pushf(&cp.env_array, "displaypath=%s", displaypath);
376-
strvec_pushf(&cp.env_array, "sha1=%s",
373+
strvec_pushf(&cp.env, "name=%s", sub->name);
374+
strvec_pushf(&cp.env, "sm_path=%s", path);
375+
strvec_pushf(&cp.env, "displaypath=%s", displaypath);
376+
strvec_pushf(&cp.env, "sha1=%s",
377377
oid_to_hex(ce_oid));
378-
strvec_pushf(&cp.env_array, "toplevel=%s", toplevel);
378+
strvec_pushf(&cp.env, "toplevel=%s", toplevel);
379379

380380
/*
381381
* Since the path variable was accessible from the script
@@ -384,7 +384,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
384384
* on windows. And since environment variables are
385385
* case-insensitive in windows, it interferes with the
386386
* existing PATH variable. Hence, to avoid that, we expose
387-
* path via the args strvec and not via env_array.
387+
* path via the args strvec and not via env.
388388
*/
389389
sq_quote_buf(&sb, path);
390390
strvec_pushf(&cp.args, "path=%s; %s",
@@ -407,7 +407,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
407407

408408
cpr.git_cmd = 1;
409409
cpr.dir = path;
410-
prepare_submodule_repo_env(&cpr.env_array);
410+
prepare_submodule_repo_env(&cpr.env);
411411

412412
strvec_pushl(&cpr.args, "--super-prefix", NULL);
413413
strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -716,7 +716,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
716716

717717
cpr.git_cmd = 1;
718718
cpr.dir = path;
719-
prepare_submodule_repo_env(&cpr.env_array);
719+
prepare_submodule_repo_env(&cpr.env);
720720

721721
strvec_push(&cpr.args, "--super-prefix");
722722
strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -839,7 +839,7 @@ static char *verify_submodule_committish(const char *sm_path,
839839

840840
cp_rev_parse.git_cmd = 1;
841841
cp_rev_parse.dir = sm_path;
842-
prepare_submodule_repo_env(&cp_rev_parse.env_array);
842+
prepare_submodule_repo_env(&cp_rev_parse.env);
843843
strvec_pushl(&cp_rev_parse.args, "rev-parse", "-q", "--short", NULL);
844844
strvec_pushf(&cp_rev_parse.args, "%s^0", committish);
845845
strvec_push(&cp_rev_parse.args, "--");
@@ -880,7 +880,7 @@ static void print_submodule_summary(struct summary_cb *info, char *errmsg,
880880

881881
cp_log.git_cmd = 1;
882882
cp_log.dir = p->sm_path;
883-
prepare_submodule_repo_env(&cp_log.env_array);
883+
prepare_submodule_repo_env(&cp_log.env);
884884
strvec_pushl(&cp_log.args, "log", NULL);
885885

886886
if (S_ISGITLINK(p->mod_src) && S_ISGITLINK(p->mod_dst)) {
@@ -997,7 +997,7 @@ static void generate_submodule_summary(struct summary_cb *info,
997997

998998
cp_rev_list.git_cmd = 1;
999999
cp_rev_list.dir = p->sm_path;
1000-
prepare_submodule_repo_env(&cp_rev_list.env_array);
1000+
prepare_submodule_repo_env(&cp_rev_list.env);
10011001

10021002
if (!capture_command(&cp_rev_list, &sb_rev_list, 0))
10031003
total_commits = atoi(sb_rev_list.buf);
@@ -1303,7 +1303,7 @@ static void sync_submodule(const char *path, const char *prefix,
13031303

13041304
cpr.git_cmd = 1;
13051305
cpr.dir = path;
1306-
prepare_submodule_repo_env(&cpr.env_array);
1306+
prepare_submodule_repo_env(&cpr.env);
13071307

13081308
strvec_push(&cpr.args, "--super-prefix");
13091309
strvec_pushf(&cpr.args, "%s/", displaypath);
@@ -1708,7 +1708,7 @@ static int clone_submodule(struct module_clone_data *clone_data)
17081708
strvec_push(&cp.args, clone_data->path);
17091709

17101710
cp.git_cmd = 1;
1711-
prepare_submodule_repo_env(&cp.env_array);
1711+
prepare_submodule_repo_env(&cp.env);
17121712
cp.no_stdin = 1;
17131713

17141714
if(run_command(&cp))
@@ -2183,7 +2183,7 @@ static int is_tip_reachable(const char *path, struct object_id *oid)
21832183
cp.no_stderr = 1;
21842184
strvec_pushl(&cp.args, "rev-list", "-n", "1", hex, "--not", "--all", NULL);
21852185

2186-
prepare_submodule_repo_env(&cp.env_array);
2186+
prepare_submodule_repo_env(&cp.env);
21872187

21882188
if (capture_command(&cp, &rev, GIT_MAX_HEXSZ + 1) || rev.len)
21892189
return 0;
@@ -2195,7 +2195,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str
21952195
{
21962196
struct child_process cp = CHILD_PROCESS_INIT;
21972197

2198-
prepare_submodule_repo_env(&cp.env_array);
2198+
prepare_submodule_repo_env(&cp.env);
21992199
cp.git_cmd = 1;
22002200
cp.dir = xstrdup(module_path);
22012201

@@ -2252,7 +2252,7 @@ static int run_update_command(struct update_data *ud, int subforce)
22522252
strvec_push(&cp.args, oid);
22532253

22542254
cp.dir = xstrdup(ud->sm_path);
2255-
prepare_submodule_repo_env(&cp.env_array);
2255+
prepare_submodule_repo_env(&cp.env);
22562256
if (run_command(&cp)) {
22572257
switch (ud->update_strategy.type) {
22582258
case SM_UPDATE_CHECKOUT:
@@ -2518,7 +2518,7 @@ static int update_submodule(struct update_data *update_data)
25182518

25192519
cp.dir = update_data->sm_path;
25202520
cp.git_cmd = 1;
2521-
prepare_submodule_repo_env(&cp.env_array);
2521+
prepare_submodule_repo_env(&cp.env);
25222522
update_data_to_args(&next, &cp.args);
25232523

25242524
/* die() if child process die()'d */
@@ -3011,9 +3011,9 @@ static void append_fetch_remotes(struct strbuf *msg, const char *git_dir_path)
30113011
struct strbuf sb_remote_out = STRBUF_INIT;
30123012

30133013
cp_remote.git_cmd = 1;
3014-
strvec_pushf(&cp_remote.env_array,
3014+
strvec_pushf(&cp_remote.env,
30153015
"GIT_DIR=%s", git_dir_path);
3016-
strvec_push(&cp_remote.env_array, "GIT_WORK_TREE=.");
3016+
strvec_push(&cp_remote.env, "GIT_WORK_TREE=.");
30173017
strvec_pushl(&cp_remote.args, "remote", "-v", NULL);
30183018
if (!capture_command(&cp_remote, &sb_remote_out, 0)) {
30193019
char *next_line;
@@ -3097,7 +3097,7 @@ static int add_submodule(const struct add_data *add_data)
30973097
if (clone_submodule(&clone_data))
30983098
return -1;
30993099

3100-
prepare_submodule_repo_env(&cp.env_array);
3100+
prepare_submodule_repo_env(&cp.env);
31013101
cp.git_cmd = 1;
31023102
cp.dir = add_data->sm_path;
31033103
/*

0 commit comments

Comments
 (0)