@matheusbsbs / matheus-bagliano / commits / 22f9b7f3f5
Fork 0

strvec: convert builtin/ callers away from argv_array name

We eventually want to drop the argv_array name and just use strvec consistently. There's no particular reason we have to do it all at once, or care about interactions between converted and unconverted bits. Because of our preprocessor compat layer, the names are interchangeable to the compiler (so even a definition and declaration using different names is OK). This patch converts all of the files in builtin/ to keep the diff to a manageable size. The conversion was done purely mechanically with: git ls-files '*.c' '*.h' | xargs perl -i -pe ' s/ARGV_ARRAY/STRVEC/g; s/argv_array/strvec/g; ' and then selectively staging files with "git add builtin/". We'll deal with any indentation/style fallouts separately. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 28, 2020 at 16:24 UTC 22f9b7f3f59549735a480042a4b9ce292eedfae0
28 files changed +503 -503
builtin/add.c
+7 -7
@@ -188,7 +188,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
188 const struct pathspec *pathspec)
189 {
190 int status, i;
191 - struct argv_array argv = ARGV_ARRAY_INIT;
191 + struct strvec argv = STRVEC_INIT;
192 int use_builtin_add_i =
193 git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1);
194
@@ -218,18 +218,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,
218 return !!run_add_p(the_repository, mode, revision, pathspec);
219 }
220
221 - argv_array_push(&argv, "add--interactive");
221 + strvec_push(&argv, "add--interactive");
222 if (patch_mode)
223 - argv_array_push(&argv, patch_mode);
223 + strvec_push(&argv, patch_mode);
224 if (revision)
225 - argv_array_push(&argv, revision);
226 - argv_array_push(&argv, "--");
225 + strvec_push(&argv, revision);
226 + strvec_push(&argv, "--");
227 for (i = 0; i < pathspec->nr; i++)
228 /* pass original pathspec, to be re-parsed */
229 - argv_array_push(&argv, pathspec->items[i].original);
229 + strvec_push(&argv, pathspec->items[i].original);
230
231 status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
232 - argv_array_clear(&argv);
232 + strvec_clear(&argv);
233 return status;
234 }
235
builtin/am.c
+33 -33
@@ -116,7 +116,7 @@ struct am_state {
116 int keep; /* enum keep_type */
117 int message_id;
118 int scissors; /* enum scissors_type */
119 - struct argv_array git_apply_opts;
119 + struct strvec git_apply_opts;
120 const char *resolvemsg;
121 int committer_date_is_author_date;
122 int ignore_date;
@@ -146,7 +146,7 @@ static void am_state_init(struct am_state *state)
146
147 state->scissors = SCISSORS_UNSET;
148
149 - argv_array_init(&state->git_apply_opts);
149 + strvec_init(&state->git_apply_opts);
150
151 if (!git_config_get_bool("commit.gpgsign", &gpgsign))
152 state->sign_commit = gpgsign ? "" : NULL;
@@ -162,7 +162,7 @@ static void am_state_release(struct am_state *state)
162 free(state->author_email);
163 free(state->author_date);
164 free(state->msg);
165 - argv_array_clear(&state->git_apply_opts);
165 + strvec_clear(&state->git_apply_opts);
166 }
167
168 /**
@@ -398,7 +398,7 @@ static void am_load(struct am_state *state)
398 state->scissors = SCISSORS_UNSET;
399
400 read_state_file(&sb, state, "apply-opt", 1);
401 - argv_array_clear(&state->git_apply_opts);
401 + strvec_clear(&state->git_apply_opts);
402 if (sq_dequote_to_strvec(sb.buf, &state->git_apply_opts) < 0)
403 die(_("could not parse %s"), am_path(state, "apply-opt"));
404
@@ -452,8 +452,8 @@ static int run_post_rewrite_hook(const struct am_state *state)
452 if (!hook)
453 return 0;
454
455 - argv_array_push(&cp.args, hook);
456 - argv_array_push(&cp.args, "rebase");
455 + strvec_push(&cp.args, hook);
456 + strvec_push(&cp.args, "rebase");
457
458 cp.in = xopen(am_path(state, "rewritten"), O_RDONLY);
459 cp.stdout_to_stderr = 1;
@@ -651,16 +651,16 @@ static int split_mail_mbox(struct am_state *state, const char **paths,
651 int ret;
652
653 cp.git_cmd = 1;
654 - argv_array_push(&cp.args, "mailsplit");
655 - argv_array_pushf(&cp.args, "-d%d", state->prec);
656 - argv_array_pushf(&cp.args, "-o%s", state->dir);
657 - argv_array_push(&cp.args, "-b");
654 + strvec_push(&cp.args, "mailsplit");
655 + strvec_pushf(&cp.args, "-d%d", state->prec);
656 + strvec_pushf(&cp.args, "-o%s", state->dir);
657 + strvec_push(&cp.args, "-b");
658 if (keep_cr)
659 - argv_array_push(&cp.args, "--keep-cr");
659 + strvec_push(&cp.args, "--keep-cr");
660 if (mboxrd)
661 - argv_array_push(&cp.args, "--mboxrd");
662 - argv_array_push(&cp.args, "--");
663 - argv_array_pushv(&cp.args, paths);
661 + strvec_push(&cp.args, "--mboxrd");
662 + strvec_push(&cp.args, "--");
663 + strvec_pushv(&cp.args, paths);
664
665 ret = capture_command(&cp, &last, 8);
666 if (ret)
@@ -787,7 +787,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
787 const char *series_dir;
788 char *series_dir_buf;
789 FILE *fp;
790 - struct argv_array patches = ARGV_ARRAY_INIT;
790 + struct strvec patches = STRVEC_INIT;
791 struct strbuf sb = STRBUF_INIT;
792 int ret;
793
@@ -805,7 +805,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
805 if (*sb.buf == '#')
806 continue; /* skip comment lines */
807
808 - argv_array_push(&patches, mkpath("%s/%s", series_dir, sb.buf));
808 + strvec_push(&patches, mkpath("%s/%s", series_dir, sb.buf));
809 }
810
811 fclose(fp);
@@ -814,7 +814,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
814
815 ret = split_mail_conv(stgit_patch_to_mail, state, patches.argv, keep_cr);
816
817 - argv_array_clear(&patches);
817 + strvec_clear(&patches);
818 return ret;
819 }
820
@@ -1390,8 +1390,8 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
1390 */
1391 static int run_apply(const struct am_state *state, const char *index_file)
1392 {
1393 - struct argv_array apply_paths = ARGV_ARRAY_INIT;
1394 - struct argv_array apply_opts = ARGV_ARRAY_INIT;
1393 + struct strvec apply_paths = STRVEC_INIT;
1394 + struct strvec apply_opts = STRVEC_INIT;
1395 struct apply_state apply_state;
1396 int res, opts_left;
1397 int force_apply = 0;
@@ -1400,8 +1400,8 @@ static int run_apply(const struct am_state *state, const char *index_file)
1400 if (init_apply_state(&apply_state, the_repository, NULL))
1401 BUG("init_apply_state() failed");
1402
1403 - argv_array_push(&apply_opts, "apply");
1404 - argv_array_pushv(&apply_opts, state->git_apply_opts.argv);
1403 + strvec_push(&apply_opts, "apply");
1404 + strvec_pushv(&apply_opts, state->git_apply_opts.argv);
1405
1406 opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
1407 &apply_state, &force_apply, &options,
@@ -1426,12 +1426,12 @@ static int run_apply(const struct am_state *state, const char *index_file)
1426 if (check_apply_state(&apply_state, force_apply))
1427 BUG("check_apply_state() failed");
1428
1429 - argv_array_push(&apply_paths, am_path(state, "patch"));
1429 + strvec_push(&apply_paths, am_path(state, "patch"));
1430
1431 res = apply_all_patches(&apply_state, apply_paths.argc, apply_paths.argv, options);
1432
1433 - argv_array_clear(&apply_paths);
1434 - argv_array_clear(&apply_opts);
1433 + strvec_clear(&apply_paths);
1434 + strvec_clear(&apply_opts);
1435 clear_apply_state(&apply_state);
1436
1437 if (res)
@@ -1454,10 +1454,10 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
1454 struct child_process cp = CHILD_PROCESS_INIT;
1455
1456 cp.git_cmd = 1;
1457 - argv_array_push(&cp.args, "apply");
1458 - argv_array_pushv(&cp.args, state->git_apply_opts.argv);
1459 - argv_array_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
1460 - argv_array_push(&cp.args, am_path(state, "patch"));
1457 + strvec_push(&cp.args, "apply");
1458 + strvec_pushv(&cp.args, state->git_apply_opts.argv);
1459 + strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
1460 + strvec_push(&cp.args, am_path(state, "patch"));
1461
1462 if (run_command(&cp))
1463 return -1;
@@ -1676,7 +1676,7 @@ static int do_interactive(struct am_state *state)
1676 if (!pager)
1677 pager = "cat";
1678 prepare_pager_args(&cp, pager);
1679 - argv_array_push(&cp.args, am_path(state, "patch"));
1679 + strvec_push(&cp.args, am_path(state, "patch"));
1680 run_command(&cp);
1681 }
1682 }
@@ -2346,7 +2346,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2346 if (state.signoff == SIGNOFF_EXPLICIT)
2347 am_append_signoff(&state);
2348 } else {
2349 - struct argv_array paths = ARGV_ARRAY_INIT;
2349 + struct strvec paths = STRVEC_INIT;
2350 int i;
2351
2352 /*
@@ -2371,9 +2371,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2371
2372 for (i = 0; i < argc; i++) {
2373 if (is_absolute_path(argv[i]) || !prefix)
2374 - argv_array_push(&paths, argv[i]);
2374 + strvec_push(&paths, argv[i]);
2375 else
2376 - argv_array_push(&paths, mkpath("%s/%s", prefix, argv[i]));
2376 + strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
2377 }
2378
2379 if (state.interactive && !paths.argc)
@@ -2381,7 +2381,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2381
2382 am_setup(&state, patch_format, paths.argv, keep_cr);
2383
2384 - argv_array_clear(&paths);
2384 + strvec_clear(&paths);
2385 }
2386
2387 switch (resume.mode) {
builtin/annotate.c
+3 -3
@@ -9,13 +9,13 @@
9
10 int cmd_annotate(int argc, const char **argv, const char *prefix)
11 {
12 - struct argv_array args = ARGV_ARRAY_INIT;
12 + struct strvec args = STRVEC_INIT;
13 int i;
14
15 - argv_array_pushl(&args, "annotate", "-c", NULL);
15 + strvec_pushl(&args, "annotate", "-c", NULL);
16
17 for (i = 1; i < argc; i++) {
18 - argv_array_push(&args, argv[i]);
18 + strvec_push(&args, argv[i]);
19 }
20
21 return cmd_blame(args.argc, args.argv, prefix);
builtin/bisect--helper.c
+6 -6
@@ -165,18 +165,18 @@ static int bisect_reset(const char *commit)
165 }
166
167 if (!file_exists(git_path_bisect_head())) {
168 - struct argv_array argv = ARGV_ARRAY_INIT;
168 + struct strvec argv = STRVEC_INIT;
169
170 - argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL);
170 + strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
171 if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
172 error(_("could not check out original"
173 " HEAD '%s'. Try 'git bisect"
174 " reset <commit>'."), branch.buf);
175 strbuf_release(&branch);
176 - argv_array_clear(&argv);
176 + strvec_clear(&argv);
177 return -1;
178 }
179 - argv_array_clear(&argv);
179 + strvec_clear(&argv);
180 }
181
182 strbuf_release(&branch);
@@ -526,9 +526,9 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
526 strbuf_read_file(&start_head, git_path_bisect_start(), 0);
527 strbuf_trim(&start_head);
528 if (!no_checkout) {
529 - struct argv_array argv = ARGV_ARRAY_INIT;
529 + struct strvec argv = STRVEC_INIT;
530
531 - argv_array_pushl(&argv, "checkout", start_head.buf,
531 + strvec_pushl(&argv, "checkout", start_head.buf,
532 "--", NULL);
533 if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
534 res = error(_("checking out '%s' failed."
builtin/bundle.c
+6 -6
@@ -59,7 +59,7 @@ static int parse_options_cmd_bundle(int argc,
59 static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
60 int all_progress_implied = 0;
61 int progress = isatty(STDERR_FILENO);
62 - struct argv_array pack_opts;
62 + struct strvec pack_opts;
63
64 struct option options[] = {
65 OPT_SET_INT('q', "quiet", &progress,
@@ -79,15 +79,15 @@ static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
79 builtin_bundle_create_usage, options, &bundle_file);
80 /* bundle internals use argv[1] as further parameters */
81
82 - argv_array_init(&pack_opts);
82 + strvec_init(&pack_opts);
83 if (progress == 0)
84 - argv_array_push(&pack_opts, "--quiet");
84 + strvec_push(&pack_opts, "--quiet");
85 else if (progress == 1)
86 - argv_array_push(&pack_opts, "--progress");
86 + strvec_push(&pack_opts, "--progress");
87 else if (progress == 2)
88 - argv_array_push(&pack_opts, "--all-progress");
88 + strvec_push(&pack_opts, "--all-progress");
89 if (progress && all_progress_implied)
90 - argv_array_push(&pack_opts, "--all-progress-implied");
90 + strvec_push(&pack_opts, "--all-progress-implied");
91
92 if (!startup_info->have_repository)
93 die(_("Need a repository to create a bundle."));
builtin/clone.c
+17 -17
@@ -742,9 +742,9 @@ static void update_head(const struct ref *our, const struct ref *remote,
742
743 static int git_sparse_checkout_init(const char *repo)
744 {
745 - struct argv_array argv = ARGV_ARRAY_INIT;
745 + struct strvec argv = STRVEC_INIT;
746 int result = 0;
747 - argv_array_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);
747 + strvec_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);
748
749 /*
750 * We must apply the setting in the current process
@@ -757,7 +757,7 @@ static int git_sparse_checkout_init(const char *repo)
757 result = 1;
758 }
759
760 - argv_array_clear(&argv);
760 + strvec_clear(&argv);
761 return result;
762 }
763
@@ -819,33 +819,33 @@ static int checkout(int submodule_progress)
819 oid_to_hex(&oid), "1", NULL);
820
821 if (!err && (option_recurse_submodules.nr > 0)) {
822 - struct argv_array args = ARGV_ARRAY_INIT;
823 - argv_array_pushl(&args, "submodule", "update", "--require-init", "--recursive", NULL);
822 + struct strvec args = STRVEC_INIT;
823 + strvec_pushl(&args, "submodule", "update", "--require-init", "--recursive", NULL);
824
825 if (option_shallow_submodules == 1)
826 - argv_array_push(&args, "--depth=1");
826 + strvec_push(&args, "--depth=1");
827
828 if (max_jobs != -1)
829 - argv_array_pushf(&args, "--jobs=%d", max_jobs);
829 + strvec_pushf(&args, "--jobs=%d", max_jobs);
830
831 if (submodule_progress)
832 - argv_array_push(&args, "--progress");
832 + strvec_push(&args, "--progress");
833
834 if (option_verbosity < 0)
835 - argv_array_push(&args, "--quiet");
835 + strvec_push(&args, "--quiet");
836
837 if (option_remote_submodules) {
838 - argv_array_push(&args, "--remote");
839 - argv_array_push(&args, "--no-fetch");
838 + strvec_push(&args, "--remote");
839 + strvec_push(&args, "--no-fetch");
840 }
841
842 if (option_single_branch >= 0)
843 - argv_array_push(&args, option_single_branch ?
843 + strvec_push(&args, option_single_branch ?
844 "--single-branch" :
845 "--no-single-branch");
846
847 err = run_command_v_opt(args.argv, RUN_GIT_CMD);
848 - argv_array_clear(&args);
848 + strvec_clear(&args);
849 }
850
851 return err;
@@ -961,7 +961,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
961 int err = 0, complete_refs_before_fetch = 1;
962 int submodule_progress;
963
964 - struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
964 + struct strvec ref_prefixes = STRVEC_INIT;
965
966 packet_trace_identity("clone");
967 argc = parse_options(argc, argv, prefix, builtin_clone_options,
@@ -1211,12 +1211,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1211 transport->smart_options->check_self_contained_and_connected = 1;
1212
1213
1214 - argv_array_push(&ref_prefixes, "HEAD");
1214 + strvec_push(&ref_prefixes, "HEAD");
1215 refspec_ref_prefixes(&remote->fetch, &ref_prefixes);
1216 if (option_branch)
1217 expand_ref_prefix(&ref_prefixes, option_branch);
1218 if (!option_no_tags)
1219 - argv_array_push(&ref_prefixes, "refs/tags/");
1219 + strvec_push(&ref_prefixes, "refs/tags/");
1220
1221 refs = transport_get_remote_refs(transport, &ref_prefixes);
1222
@@ -1327,6 +1327,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1327 strbuf_release(&default_refspec);
1328 junk_mode = JUNK_LEAVE_ALL;
1329
1330 - argv_array_clear(&ref_prefixes);
1330 + strvec_clear(&ref_prefixes);
1331 return err;
1332 }
builtin/commit.c
+3 -3
@@ -1005,15 +1005,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1005 return 0;
1006
1007 if (use_editor) {
1008 - struct argv_array env = ARGV_ARRAY_INIT;
1008 + struct strvec env = STRVEC_INIT;
1009
1010 - argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
1010 + strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
1011 if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
1012 fprintf(stderr,
1013 _("Please supply the message using either -m or -F option.\n"));
1014 exit(1);
1015 }
1016 - argv_array_clear(&env);
1016 + strvec_clear(&env);
1017 }
1018
1019 if (!no_verify &&
builtin/describe.c
+14 -14
@@ -501,10 +501,10 @@ static void process_object(struct object *obj, const char *path, void *data)
501 static void describe_blob(struct object_id oid, struct strbuf *dst)
502 {
503 struct rev_info revs;
504 - struct argv_array args = ARGV_ARRAY_INIT;
504 + struct strvec args = STRVEC_INIT;
505 struct process_commit_data pcd = { null_oid, oid, dst, &revs};
506
507 - argv_array_pushl(&args, "internal: The first arg is not parsed",
507 + strvec_pushl(&args, "internal: The first arg is not parsed",
508 "--objects", "--in-commit-order", "--reverse", "HEAD",
509 NULL);
510
@@ -594,25 +594,25 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
594
595 if (contains) {
596 struct string_list_item *item;
597 - struct argv_array args;
597 + struct strvec args;
598
599 - argv_array_init(&args);
600 - argv_array_pushl(&args, "name-rev",
599 + strvec_init(&args);
600 + strvec_pushl(&args, "name-rev",
601 "--peel-tag", "--name-only", "--no-undefined",
602 NULL);
603 if (always)
604 - argv_array_push(&args, "--always");
604 + strvec_push(&args, "--always");
605 if (!all) {
606 - argv_array_push(&args, "--tags");
606 + strvec_push(&args, "--tags");
607 for_each_string_list_item(item, &patterns)
608 - argv_array_pushf(&args, "--refs=refs/tags/%s", item->string);
608 + strvec_pushf(&args, "--refs=refs/tags/%s", item->string);
609 for_each_string_list_item(item, &exclude_patterns)
610 - argv_array_pushf(&args, "--exclude=refs/tags/%s", item->string);
610 + strvec_pushf(&args, "--exclude=refs/tags/%s", item->string);
611 }
612 if (argc)
613 - argv_array_pushv(&args, argv);
613 + strvec_pushv(&args, argv);
614 else
615 - argv_array_push(&args, "HEAD");
615 + strvec_push(&args, "HEAD");
616 return cmd_name_rev(args.argc, args.argv, prefix);
617 }
618
@@ -624,7 +624,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
624 if (argc == 0) {
625 if (broken) {
626 struct child_process cp = CHILD_PROCESS_INIT;
627 - argv_array_pushv(&cp.args, diff_index_args);
627 + strvec_pushv(&cp.args, diff_index_args);
628 cp.git_cmd = 1;
629 cp.no_stdin = 1;
630 cp.no_stdout = 1;
@@ -646,7 +646,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
646 } else if (dirty) {
647 struct lock_file index_lock = LOCK_INIT;
648 struct rev_info revs;
649 - struct argv_array args = ARGV_ARRAY_INIT;
649 + struct strvec args = STRVEC_INIT;
650 int fd, result;
651
652 setup_work_tree();
@@ -658,7 +658,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
658 repo_update_index_if_able(the_repository, &index_lock);
659
660 repo_init_revisions(the_repository, &revs, prefix);
661 - argv_array_pushv(&args, diff_index_args);
661 + strvec_pushv(&args, diff_index_args);
662 if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
663 BUG("malformed internal diff-index command line");
664 result = run_diff_index(&revs, 0);
builtin/difftool.c
+7 -7
@@ -210,7 +210,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
210 strbuf_addf(&index_env, "GIT_INDEX_FILE=%s", index_path);
211 env[0] = index_env.buf;
212
213 - argv_array_pushl(&update_index.args,
213 + strvec_pushl(&update_index.args,
214 "--git-dir", git_dir, "--work-tree", workdir,
215 "update-index", "--really-refresh", "-q",
216 "--unmerged", NULL);
@@ -225,7 +225,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
225 /* Ignore any errors of update-index */
226 run_command(&update_index);
227
228 - argv_array_pushl(&diff_files.args,
228 + strvec_pushl(&diff_files.args,
229 "--git-dir", git_dir, "--work-tree", workdir,
230 "diff-files", "--name-only", "-z", NULL);
231 diff_files.no_stdin = 1;
@@ -393,10 +393,10 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
393 child.clean_on_exit = 1;
394 child.dir = prefix;
395 child.out = -1;
396 - argv_array_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z",
396 + strvec_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z",
397 NULL);
398 for (i = 0; i < argc; i++)
399 - argv_array_push(&child.args, argv[i]);
399 + strvec_push(&child.args, argv[i]);
400 if (start_command(&child))
401 die("could not obtain raw diff");
402 fp = xfdopen(child.out, "r");
@@ -667,7 +667,7 @@ finish:
667 static int run_file_diff(int prompt, const char *prefix,
668 int argc, const char **argv)
669 {
670 - struct argv_array args = ARGV_ARRAY_INIT;
670 + struct strvec args = STRVEC_INIT;
671 const char *env[] = {
672 "GIT_PAGER=", "GIT_EXTERNAL_DIFF=git-difftool--helper", NULL,
673 NULL
@@ -680,9 +680,9 @@ static int run_file_diff(int prompt, const char *prefix,
680 env[2] = "GIT_DIFFTOOL_NO_PROMPT=true";
681
682
683 - argv_array_push(&args, "diff");
683 + strvec_push(&args, "diff");
684 for (i = 0; i < argc; i++)
685 - argv_array_push(&args, argv[i]);
685 + strvec_push(&args, argv[i]);
686 ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
687 exit(ret);
688 }
builtin/fetch.c
+27 -27
@@ -1316,7 +1316,7 @@ static int do_fetch(struct transport *transport,
1316 int autotags = (transport->remote->fetch_tags == 1);
1317 int retcode = 0;
1318 const struct ref *remote_refs;
1319 - struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
1319 + struct strvec ref_prefixes = STRVEC_INIT;
1320 int must_list_refs = 1;
1321
1322 if (tags == TAGS_DEFAULT) {
@@ -1355,7 +1355,7 @@ static int do_fetch(struct transport *transport,
1355 if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
1356 must_list_refs = 1;
1357 if (ref_prefixes.argc)
1358 - argv_array_push(&ref_prefixes, "refs/tags/");
1358 + strvec_push(&ref_prefixes, "refs/tags/");
1359 }
1360
1361 if (must_list_refs) {
@@ -1365,7 +1365,7 @@ static int do_fetch(struct transport *transport,
1365 } else
1366 remote_refs = NULL;
1367
1368 - argv_array_clear(&ref_prefixes);
1368 + strvec_clear(&ref_prefixes);
1369
1370 ref_map = get_ref_map(transport->remote, remote_refs, rs,
1371 tags, &autotags);
@@ -1503,34 +1503,34 @@ static int add_remote_or_group(const char *name, struct string_list *list)
1503 return 1;
1504 }
1505
1506 -static void add_options_to_argv(struct argv_array *argv)
1506 +static void add_options_to_argv(struct strvec *argv)
1507 {
1508 if (dry_run)
1509 - argv_array_push(argv, "--dry-run");
1509 + strvec_push(argv, "--dry-run");
1510 if (prune != -1)
1511 - argv_array_push(argv, prune ? "--prune" : "--no-prune");
1511 + strvec_push(argv, prune ? "--prune" : "--no-prune");
1512 if (prune_tags != -1)
1513 - argv_array_push(argv, prune_tags ? "--prune-tags" : "--no-prune-tags");
1513 + strvec_push(argv, prune_tags ? "--prune-tags" : "--no-prune-tags");
1514 if (update_head_ok)
1515 - argv_array_push(argv, "--update-head-ok");
1515 + strvec_push(argv, "--update-head-ok");
1516 if (force)
1517 - argv_array_push(argv, "--force");
1517 + strvec_push(argv, "--force");
1518 if (keep)
1519 - argv_array_push(argv, "--keep");
1519 + strvec_push(argv, "--keep");
1520 if (recurse_submodules == RECURSE_SUBMODULES_ON)
1521 - argv_array_push(argv, "--recurse-submodules");
1521 + strvec_push(argv, "--recurse-submodules");
1522 else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
1523 - argv_array_push(argv, "--recurse-submodules=on-demand");
1523 + strvec_push(argv, "--recurse-submodules=on-demand");
1524 if (tags == TAGS_SET)
1525 - argv_array_push(argv, "--tags");
1525 + strvec_push(argv, "--tags");
1526 else if (tags == TAGS_UNSET)
1527 - argv_array_push(argv, "--no-tags");
1527 + strvec_push(argv, "--no-tags");
1528 if (verbosity >= 2)
1529 - argv_array_push(argv, "-v");
1529 + strvec_push(argv, "-v");
1530 if (verbosity >= 1)
1531 - argv_array_push(argv, "-v");
1531 + strvec_push(argv, "-v");
1532 else if (verbosity < 0)
1533 - argv_array_push(argv, "-q");
1533 + strvec_push(argv, "-q");
1534
1535 }
1536
@@ -1554,8 +1554,8 @@ static int fetch_next_remote(struct child_process *cp, struct strbuf *out,
1554 remote = state->remotes->items[state->next++].string;
1555 *task_cb = remote;
1556
1557 - argv_array_pushv(&cp->args, state->argv);
1558 - argv_array_push(&cp->args, remote);
1557 + strvec_pushv(&cp->args, state->argv);
1558 + strvec_push(&cp->args, remote);
1559 cp->git_cmd = 1;
1560
1561 if (verbosity >= 0)
@@ -1592,7 +1592,7 @@ static int fetch_finished(int result, struct strbuf *out,
1592 static int fetch_multiple(struct string_list *list, int max_children)
1593 {
1594 int i, result = 0;
1595 - struct argv_array argv = ARGV_ARRAY_INIT;
1595 + struct strvec argv = STRVEC_INIT;
1596
1597 if (!append && !dry_run) {
1598 int errcode = truncate_fetch_head();
@@ -1600,14 +1600,14 @@ static int fetch_multiple(struct string_list *list, int max_children)
1600 return errcode;
1601 }
1602
1603 - argv_array_pushl(&argv, "fetch", "--append", "--no-auto-gc",
1603 + strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc",
1604 "--no-write-commit-graph", NULL);
1605 add_options_to_argv(&argv);
1606
1607 if (max_children != 1 && list->nr != 1) {
1608 struct parallel_fetch_state state = { argv.argv, list, 0, 0 };
1609
1610 - argv_array_push(&argv, "--end-of-options");
1610 + strvec_push(&argv, "--end-of-options");
1611 result = run_processes_parallel_tr2(max_children,
1612 &fetch_next_remote,
1613 &fetch_failed_to_start,
@@ -1620,17 +1620,17 @@ static int fetch_multiple(struct string_list *list, int max_children)
1620 } else
1621 for (i = 0; i < list->nr; i++) {
1622 const char *name = list->items[i].string;
1623 - argv_array_push(&argv, name);
1623 + strvec_push(&argv, name);
1624 if (verbosity >= 0)
1625 printf(_("Fetching %s\n"), name);
1626 if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
1627 error(_("Could not fetch %s"), name);
1628 result = 1;
1629 }
1630 - argv_array_pop(&argv);
1630 + strvec_pop(&argv);
1631 }
1632
1633 - argv_array_clear(&argv);
1633 + strvec_clear(&argv);
1634 return !!result;
1635 }
1636
@@ -1844,7 +1844,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1844 }
1845
1846 if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
1847 - struct argv_array options = ARGV_ARRAY_INIT;
1847 + struct strvec options = STRVEC_INIT;
1848 int max_children = max_jobs;
1849
1850 if (max_children < 0)
@@ -1860,7 +1860,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1860 recurse_submodules_default,
1861 verbosity < 0,
1862 max_children);
1863 - argv_array_clear(&options);
1863 + strvec_clear(&options);
1864 }
1865
1866 string_list_clear(&list, 0);
builtin/gc.c
+25 -25
@@ -50,12 +50,12 @@ static const char *prune_worktrees_expire = "3.months.ago";
50 static unsigned long big_pack_threshold;
51 static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
52
53 -static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
54 -static struct argv_array reflog = ARGV_ARRAY_INIT;
55 -static struct argv_array repack = ARGV_ARRAY_INIT;
56 -static struct argv_array prune = ARGV_ARRAY_INIT;
57 -static struct argv_array prune_worktrees = ARGV_ARRAY_INIT;
58 -static struct argv_array rerere = ARGV_ARRAY_INIT;
53 +static struct strvec pack_refs_cmd = STRVEC_INIT;
54 +static struct strvec reflog = STRVEC_INIT;
55 +static struct strvec repack = STRVEC_INIT;
56 +static struct strvec prune = STRVEC_INIT;
57 +static struct strvec prune_worktrees = STRVEC_INIT;
58 +static struct strvec rerere = STRVEC_INIT;
59
60 static struct tempfile *pidfile;
61 static struct lock_file log_lock;
@@ -311,18 +311,18 @@ static uint64_t estimate_repack_memory(struct packed_git *pack)
311
312 static int keep_one_pack(struct string_list_item *item, void *data)
313 {
314 - argv_array_pushf(&repack, "--keep-pack=%s", basename(item->string));
314 + strvec_pushf(&repack, "--keep-pack=%s", basename(item->string));
315 return 0;
316 }
317
318 static void add_repack_all_option(struct string_list *keep_pack)
319 {
320 if (prune_expire && !strcmp(prune_expire, "now"))
321 - argv_array_push(&repack, "-a");
321 + strvec_push(&repack, "-a");
322 else {
323 - argv_array_push(&repack, "-A");
323 + strvec_push(&repack, "-A");
324 if (prune_expire)
325 - argv_array_pushf(&repack, "--unpack-unreachable=%s", prune_expire);
325 + strvec_pushf(&repack, "--unpack-unreachable=%s", prune_expire);
326 }
327
328 if (keep_pack)
@@ -331,7 +331,7 @@ static void add_repack_all_option(struct string_list *keep_pack)
331
332 static void add_repack_incremental_option(void)
333 {
334 - argv_array_push(&repack, "--no-write-bitmap-index");
334 + strvec_push(&repack, "--no-write-bitmap-index");
335 }
336
337 static int need_to_gc(void)
@@ -552,12 +552,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
552 if (argc == 2 && !strcmp(argv[1], "-h"))
553 usage_with_options(builtin_gc_usage, builtin_gc_options);
554
555 - argv_array_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
556 - argv_array_pushl(&reflog, "reflog", "expire", "--all", NULL);
557 - argv_array_pushl(&repack, "repack", "-d", "-l", NULL);
558 - argv_array_pushl(&prune, "prune", "--expire", NULL);
559 - argv_array_pushl(&prune_worktrees, "worktree", "prune", "--expire", NULL);
560 - argv_array_pushl(&rerere, "rerere", "gc", NULL);
555 + strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
556 + strvec_pushl(&reflog, "reflog", "expire", "--all", NULL);
557 + strvec_pushl(&repack, "repack", "-d", "-l", NULL);
558 + strvec_pushl(&prune, "prune", "--expire", NULL);
559 + strvec_pushl(&prune_worktrees, "worktree", "prune", "--expire", NULL);
560 + strvec_pushl(&rerere, "rerere", "gc", NULL);
561
562 /* default expiry time, overwritten in gc_config */
563 gc_config();
@@ -576,14 +576,14 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
576 die(_("failed to parse prune expiry value %s"), prune_expire);
577
578 if (aggressive) {
579 - argv_array_push(&repack, "-f");
579 + strvec_push(&repack, "-f");
580 if (aggressive_depth > 0)
581 - argv_array_pushf(&repack, "--depth=%d", aggressive_depth);
581 + strvec_pushf(&repack, "--depth=%d", aggressive_depth);
582 if (aggressive_window > 0)
583 - argv_array_pushf(&repack, "--window=%d", aggressive_window);
583 + strvec_pushf(&repack, "--window=%d", aggressive_window);
584 }
585 if (quiet)
586 - argv_array_push(&repack, "-q");
586 + strvec_push(&repack, "-q");
587
588 if (auto_gc) {
589 /*
@@ -657,11 +657,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
657 die(FAILED_RUN, repack.argv[0]);
658
659 if (prune_expire) {
660 - argv_array_push(&prune, prune_expire);
660 + strvec_push(&prune, prune_expire);
661 if (quiet)
662 - argv_array_push(&prune, "--no-progress");
662 + strvec_push(&prune, "--no-progress");
663 if (has_promisor_remote())
664 - argv_array_push(&prune,
664 + strvec_push(&prune,
665 "--exclude-promisor-objects");
666 if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
667 die(FAILED_RUN, prune.argv[0]);
@@ -669,7 +669,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
669 }
670
671 if (prune_worktrees_expire) {
672 - argv_array_push(&prune_worktrees, prune_worktrees_expire);
672 + strvec_push(&prune_worktrees, prune_worktrees_expire);
673 if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD))
674 die(FAILED_RUN, prune_worktrees.argv[0]);
675 }
builtin/grep.c
+1 -1
@@ -397,7 +397,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
397 int i, status;
398
399 for (i = 0; i < path_list->nr; i++)
400 - argv_array_push(&child.args, path_list->items[i].string);
400 + strvec_push(&child.args, path_list->items[i].string);
401 child.dir = prefix;
402 child.use_shell = 1;
403
builtin/log.c
+6 -6
@@ -1128,18 +1128,18 @@ do_pp:
1128
1129 static int get_notes_refs(struct string_list_item *item, void *arg)
1130 {
1131 - argv_array_pushf(arg, "--notes=%s", item->string);
1131 + strvec_pushf(arg, "--notes=%s", item->string);
1132 return 0;
1133 }
1134
1135 -static void get_notes_args(struct argv_array *arg, struct rev_info *rev)
1135 +static void get_notes_args(struct strvec *arg, struct rev_info *rev)
1136 {
1137 if (!rev->show_notes) {
1138 - argv_array_push(arg, "--no-notes");
1138 + strvec_push(arg, "--no-notes");
1139 } else if (rev->notes_opt.use_default_notes > 0 ||
1140 (rev->notes_opt.use_default_notes == -1 &&
1141 !rev->notes_opt.extra_notes_refs.nr)) {
1142 - argv_array_push(arg, "--notes");
1142 + strvec_push(arg, "--notes");
1143 } else {
1144 for_each_string_list(&rev->notes_opt.extra_notes_refs, get_notes_refs, arg);
1145 }
@@ -1217,7 +1217,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
1217 * can be added later if deemed desirable.
1218 */
1219 struct diff_options opts;
1220 - struct argv_array other_arg = ARGV_ARRAY_INIT;
1220 + struct strvec other_arg = STRVEC_INIT;
1221 diff_setup(&opts);
1222 opts.file = rev->diffopt.file;
1223 opts.use_color = rev->diffopt.use_color;
@@ -1226,7 +1226,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
1226 get_notes_args(&other_arg, rev);
1227 show_range_diff(rev->rdiff1, rev->rdiff2,
1228 rev->creation_factor, 1, &opts, &other_arg);
1229 - argv_array_clear(&other_arg);
1229 + strvec_clear(&other_arg);
1230 }
1231 }
1232
builtin/ls-remote.c
+3 -3
@@ -45,7 +45,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
45 int show_symref_target = 0;
46 const char *uploadpack = NULL;
47 const char **pattern = NULL;
48 - struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
48 + struct strvec ref_prefixes = STRVEC_INIT;
49 int i;
50 struct string_list server_options = STRING_LIST_INIT_DUP;
51
@@ -92,9 +92,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
92 }
93
94 if (flags & REF_TAGS)
95 - argv_array_push(&ref_prefixes, "refs/tags/");
95 + strvec_push(&ref_prefixes, "refs/tags/");
96 if (flags & REF_HEADS)
97 - argv_array_push(&ref_prefixes, "refs/heads/");
97 + strvec_push(&ref_prefixes, "refs/heads/");
98
99 remote = remote_get(dest);
100 if (!remote) {
builtin/pack-objects.c
+11 -11
@@ -3439,7 +3439,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3439 int use_internal_rev_list = 0;
3440 int shallow = 0;
3441 int all_progress_implied = 0;
3442 - struct argv_array rp = ARGV_ARRAY_INIT;
3442 + struct strvec rp = STRVEC_INIT;
3443 int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
3444 int rev_list_index = 0;
3445 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
@@ -3575,36 +3575,36 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3575 cache_max_small_delta_size = (1U << OE_Z_DELTA_BITS) - 1;
3576 }
3577
3578 - argv_array_push(&rp, "pack-objects");
3578 + strvec_push(&rp, "pack-objects");
3579 if (thin) {
3580 use_internal_rev_list = 1;
3581 - argv_array_push(&rp, shallow
3581 + strvec_push(&rp, shallow
3582 ? "--objects-edge-aggressive"
3583 : "--objects-edge");
3584 } else
3585 - argv_array_push(&rp, "--objects");
3585 + strvec_push(&rp, "--objects");
3586
3587 if (rev_list_all) {
3588 use_internal_rev_list = 1;
3589 - argv_array_push(&rp, "--all");
3589 + strvec_push(&rp, "--all");
3590 }
3591 if (rev_list_reflog) {
3592 use_internal_rev_list = 1;
3593 - argv_array_push(&rp, "--reflog");
3593 + strvec_push(&rp, "--reflog");
3594 }
3595 if (rev_list_index) {
3596 use_internal_rev_list = 1;
3597 - argv_array_push(&rp, "--indexed-objects");
3597 + strvec_push(&rp, "--indexed-objects");
3598 }
3599 if (rev_list_unpacked) {
3600 use_internal_rev_list = 1;
3601 - argv_array_push(&rp, "--unpacked");
3601 + strvec_push(&rp, "--unpacked");
3602 }
3603
3604 if (exclude_promisor_objects) {
3605 use_internal_rev_list = 1;
3606 fetch_if_missing = 0;
3607 - argv_array_push(&rp, "--exclude-promisor-objects");
3607 + strvec_push(&rp, "--exclude-promisor-objects");
3608 }
3609 if (unpack_unreachable || keep_unreachable || pack_loose_unreachable)
3610 use_internal_rev_list = 1;
@@ -3666,7 +3666,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3666 write_bitmap_index = 0;
3667
3668 if (use_delta_islands)
3669 - argv_array_push(&rp, "--topo-order");
3669 + strvec_push(&rp, "--topo-order");
3670
3671 if (progress && all_progress_implied)
3672 progress = 2;
@@ -3705,7 +3705,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3705 read_object_list_from_stdin();
3706 else {
3707 get_object_list(rp.argc, rp.argv);
3708 - argv_array_clear(&rp);
3708 + strvec_clear(&rp);
3709 }
3710 cleanup_preferred_base();
3711 if (include_tag && nr_result)
builtin/pull.c
+74 -74
@@ -87,8 +87,8 @@ static char *opt_verify_signatures;
87 static int opt_autostash = -1;
88 static int config_autostash;
89 static int check_trust_level = 1;
90 -static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
91 -static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
90 +static struct strvec opt_strategies = STRVEC_INIT;
91 +static struct strvec opt_strategy_opts = STRVEC_INIT;
92 static char *opt_gpg_sign;
93 static int opt_allow_unrelated_histories;
94
@@ -110,7 +110,7 @@ static char *opt_ipv4;
110 static char *opt_ipv6;
111 static int opt_show_forced_updates = -1;
112 static char *set_upstream;
113 -static struct argv_array opt_fetch = ARGV_ARRAY_INIT;
113 +static struct strvec opt_fetch = STRVEC_INIT;
114
115 static struct option pull_options[] = {
116 /* Shared options */
@@ -251,25 +251,25 @@ static struct option pull_options[] = {
251 /**
252 * Pushes "-q" or "-v" switches into arr to match the opt_verbosity level.
253 */
254 -static void argv_push_verbosity(struct argv_array *arr)
254 +static void argv_push_verbosity(struct strvec *arr)
255 {
256 int verbosity;
257
258 for (verbosity = opt_verbosity; verbosity > 0; verbosity--)
259 - argv_array_push(arr, "-v");
259 + strvec_push(arr, "-v");
260
261 for (verbosity = opt_verbosity; verbosity < 0; verbosity++)
262 - argv_array_push(arr, "-q");
262 + strvec_push(arr, "-q");
263 }
264
265 /**
266 * Pushes "-f" switches into arr to match the opt_force level.
267 */
268 -static void argv_push_force(struct argv_array *arr)
268 +static void argv_push_force(struct strvec *arr)
269 {
270 int force = opt_force;
271 while (force-- > 0)
272 - argv_array_push(arr, "-f");
272 + strvec_push(arr, "-f");
273 }
274
275 /**
@@ -524,75 +524,75 @@ static void parse_repo_refspecs(int argc, const char **argv, const char **repo,
524 */
525 static int run_fetch(const char *repo, const char **refspecs)
526 {
527 - struct argv_array args = ARGV_ARRAY_INIT;
527 + struct strvec args = STRVEC_INIT;
528 int ret;
529
530 - argv_array_pushl(&args, "fetch", "--update-head-ok", NULL);
530 + strvec_pushl(&args, "fetch", "--update-head-ok", NULL);
531
532 /* Shared options */
533 argv_push_verbosity(&args);
534 if (opt_progress)
535 - argv_array_push(&args, opt_progress);
535 + strvec_push(&args, opt_progress);
536
537 /* Options passed to git-fetch */
538 if (opt_all)
539 - argv_array_push(&args, opt_all);
539 + strvec_push(&args, opt_all);
540 if (opt_append)
541 - argv_array_push(&args, opt_append);
541 + strvec_push(&args, opt_append);
542 if (opt_upload_pack)
543 - argv_array_push(&args, opt_upload_pack);
543 + strvec_push(&args, opt_upload_pack);
544 argv_push_force(&args);
545 if (opt_tags)
546 - argv_array_push(&args, opt_tags);
546 + strvec_push(&args, opt_tags);
547 if (opt_prune)
548 - argv_array_push(&args, opt_prune);
548 + strvec_push(&args, opt_prune);
549 if (recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
550 switch (recurse_submodules) {
551 case RECURSE_SUBMODULES_ON:
552 - argv_array_push(&args, "--recurse-submodules=on");
552 + strvec_push(&args, "--recurse-submodules=on");
553 break;
554 case RECURSE_SUBMODULES_OFF:
555 - argv_array_push(&args, "--recurse-submodules=no");
555 + strvec_push(&args, "--recurse-submodules=no");
556 break;
557 case RECURSE_SUBMODULES_ON_DEMAND:
558 - argv_array_push(&args, "--recurse-submodules=on-demand");
558 + strvec_push(&args, "--recurse-submodules=on-demand");
559 break;
560 default:
561 BUG("submodule recursion option not understood");
562 }
563 if (max_children)
564 - argv_array_push(&args, max_children);
564 + strvec_push(&args, max_children);
565 if (opt_dry_run)
566 - argv_array_push(&args, "--dry-run");
566 + strvec_push(&args, "--dry-run");
567 if (opt_keep)
568 - argv_array_push(&args, opt_keep);
568 + strvec_push(&args, opt_keep);
569 if (opt_depth)
570 - argv_array_push(&args, opt_depth);
570 + strvec_push(&args, opt_depth);
571 if (opt_unshallow)
572 - argv_array_push(&args, opt_unshallow);
572 + strvec_push(&args, opt_unshallow);
573 if (opt_update_shallow)
574 - argv_array_push(&args, opt_update_shallow);
574 + strvec_push(&args, opt_update_shallow);
575 if (opt_refmap)
576 - argv_array_push(&args, opt_refmap);
576 + strvec_push(&args, opt_refmap);
577 if (opt_ipv4)
578 - argv_array_push(&args, opt_ipv4);
578 + strvec_push(&args, opt_ipv4);
579 if (opt_ipv6)
580 - argv_array_push(&args, opt_ipv6);
580 + strvec_push(&args, opt_ipv6);
581 if (opt_show_forced_updates > 0)
582 - argv_array_push(&args, "--show-forced-updates");
582 + strvec_push(&args, "--show-forced-updates");
583 else if (opt_show_forced_updates == 0)
584 - argv_array_push(&args, "--no-show-forced-updates");
584 + strvec_push(&args, "--no-show-forced-updates");
585 if (set_upstream)
586 - argv_array_push(&args, set_upstream);
587 - argv_array_pushv(&args, opt_fetch.argv);
586 + strvec_push(&args, set_upstream);
587 + strvec_pushv(&args, opt_fetch.argv);
588
589 if (repo) {
590 - argv_array_push(&args, repo);
591 - argv_array_pushv(&args, refspecs);
590 + strvec_push(&args, repo);
591 + strvec_pushv(&args, refspecs);
592 } else if (*refspecs)
593 BUG("refspecs without repo?");
594 ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
595 - argv_array_clear(&args);
595 + strvec_clear(&args);
596 return ret;
597 }
598
@@ -637,7 +637,7 @@ static int rebase_submodules(void)
637
638 cp.git_cmd = 1;
639 cp.no_stdin = 1;
640 - argv_array_pushl(&cp.args, "submodule", "update",
640 + strvec_pushl(&cp.args, "submodule", "update",
641 "--recursive", "--rebase", NULL);
642 argv_push_verbosity(&cp.args);
643
@@ -650,7 +650,7 @@ static int update_submodules(void)
650
651 cp.git_cmd = 1;
652 cp.no_stdin = 1;
653 - argv_array_pushl(&cp.args, "submodule", "update",
653 + strvec_pushl(&cp.args, "submodule", "update",
654 "--recursive", "--checkout", NULL);
655 argv_push_verbosity(&cp.args);
656
@@ -663,48 +663,48 @@ static int update_submodules(void)
663 static int run_merge(void)
664 {
665 int ret;
666 - struct argv_array args = ARGV_ARRAY_INIT;
666 + struct strvec args = STRVEC_INIT;
667
668 - argv_array_pushl(&args, "merge", NULL);
668 + strvec_pushl(&args, "merge", NULL);
669
670 /* Shared options */
671 argv_push_verbosity(&args);
672 if (opt_progress)
673 - argv_array_push(&args, opt_progress);
673 + strvec_push(&args, opt_progress);
674
675 /* Options passed to git-merge */
676 if (opt_diffstat)
677 - argv_array_push(&args, opt_diffstat);
677 + strvec_push(&args, opt_diffstat);
678 if (opt_log)
679 - argv_array_push(&args, opt_log);
679 + strvec_push(&args, opt_log);
680 if (opt_signoff)
681 - argv_array_push(&args, opt_signoff);
681 + strvec_push(&args, opt_signoff);
682 if (opt_squash)
683 - argv_array_push(&args, opt_squash);
683 + strvec_push(&args, opt_squash);
684 if (opt_commit)
685 - argv_array_push(&args, opt_commit);
685 + strvec_push(&args, opt_commit);
686 if (opt_edit)
687 - argv_array_push(&args, opt_edit);
687 + strvec_push(&args, opt_edit);
688 if (cleanup_arg)
689 - argv_array_pushf(&args, "--cleanup=%s", cleanup_arg);
689 + strvec_pushf(&args, "--cleanup=%s", cleanup_arg);
690 if (opt_ff)
691 - argv_array_push(&args, opt_ff);
691 + strvec_push(&args, opt_ff);
692 if (opt_verify_signatures)
693 - argv_array_push(&args, opt_verify_signatures);
694 - argv_array_pushv(&args, opt_strategies.argv);
695 - argv_array_pushv(&args, opt_strategy_opts.argv);
693 + strvec_push(&args, opt_verify_signatures);
694 + strvec_pushv(&args, opt_strategies.argv);
695 + strvec_pushv(&args, opt_strategy_opts.argv);
696 if (opt_gpg_sign)
697 - argv_array_push(&args, opt_gpg_sign);
697 + strvec_push(&args, opt_gpg_sign);
698 if (opt_autostash == 0)
699 - argv_array_push(&args, "--no-autostash");
699 + strvec_push(&args, "--no-autostash");
700 else if (opt_autostash == 1)
701 - argv_array_push(&args, "--autostash");
701 + strvec_push(&args, "--autostash");
702 if (opt_allow_unrelated_histories > 0)
703 - argv_array_push(&args, "--allow-unrelated-histories");
703 + strvec_push(&args, "--allow-unrelated-histories");
704
705 - argv_array_push(&args, "FETCH_HEAD");
705 + strvec_push(&args, "FETCH_HEAD");
706 ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
707 - argv_array_clear(&args);
707 + strvec_clear(&args);
708 return ret;
709 }
710
@@ -801,7 +801,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
801 if (!remote_branch)
802 return -1;
803
804 - argv_array_pushl(&cp.args, "merge-base", "--fork-point",
804 + strvec_pushl(&cp.args, "merge-base", "--fork-point",
805 remote_branch, curr_branch->name, NULL);
806 cp.no_stdin = 1;
807 cp.no_stderr = 1;
@@ -862,48 +862,48 @@ static int run_rebase(const struct object_id *curr_head,
862 {
863 int ret;
864 struct object_id oct_merge_base;
865 - struct argv_array args = ARGV_ARRAY_INIT;
865 + struct strvec args = STRVEC_INIT;
866
867 if (!get_octopus_merge_base(&oct_merge_base, curr_head, merge_head, fork_point))
868 if (!is_null_oid(fork_point) && oideq(&oct_merge_base, fork_point))
869 fork_point = NULL;
870
871 - argv_array_push(&args, "rebase");
871 + strvec_push(&args, "rebase");
872
873 /* Shared options */
874 argv_push_verbosity(&args);
875
876 /* Options passed to git-rebase */
877 if (opt_rebase == REBASE_MERGES)
878 - argv_array_push(&args, "--rebase-merges");
878 + strvec_push(&args, "--rebase-merges");
879 else if (opt_rebase == REBASE_PRESERVE)
880 - argv_array_push(&args, "--preserve-merges");
880 + strvec_push(&args, "--preserve-merges");
881 else if (opt_rebase == REBASE_INTERACTIVE)
882 - argv_array_push(&args, "--interactive");
882 + strvec_push(&args, "--interactive");
883 if (opt_diffstat)
884 - argv_array_push(&args, opt_diffstat);
885 - argv_array_pushv(&args, opt_strategies.argv);
886 - argv_array_pushv(&args, opt_strategy_opts.argv);
884 + strvec_push(&args, opt_diffstat);
885 + strvec_pushv(&args, opt_strategies.argv);
886 + strvec_pushv(&args, opt_strategy_opts.argv);
887 if (opt_gpg_sign)
888 - argv_array_push(&args, opt_gpg_sign);
888 + strvec_push(&args, opt_gpg_sign);
889 if (opt_autostash == 0)
890 - argv_array_push(&args, "--no-autostash");
890 + strvec_push(&args, "--no-autostash");
891 else if (opt_autostash == 1)
892 - argv_array_push(&args, "--autostash");
892 + strvec_push(&args, "--autostash");
893 if (opt_verify_signatures &&
894 !strcmp(opt_verify_signatures, "--verify-signatures"))
895 warning(_("ignoring --verify-signatures for rebase"));
896
897 - argv_array_push(&args, "--onto");
898 - argv_array_push(&args, oid_to_hex(merge_head));
897 + strvec_push(&args, "--onto");
898 + strvec_push(&args, oid_to_hex(merge_head));
899
900 if (fork_point && !is_null_oid(fork_point))
901 - argv_array_push(&args, oid_to_hex(fork_point));
901 + strvec_push(&args, oid_to_hex(fork_point));
902 else
903 - argv_array_push(&args, oid_to_hex(merge_head));
903 + strvec_push(&args, oid_to_hex(merge_head));
904
905 ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
906 - argv_array_clear(&args);
906 + strvec_clear(&args);
907 return ret;
908 }
909
builtin/range-diff.c
+2 -2
@@ -15,7 +15,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
15 {
16 int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
17 struct diff_options diffopt = { NULL };
18 - struct argv_array other_arg = ARGV_ARRAY_INIT;
18 + struct strvec other_arg = STRVEC_INIT;
19 int simple_color = -1;
20 struct option range_diff_options[] = {
21 OPT_INTEGER(0, "creation-factor", &creation_factor,
@@ -84,7 +84,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
84 res = show_range_diff(range1.buf, range2.buf, creation_factor,
85 simple_color < 1, &diffopt, &other_arg);
86
87 - argv_array_clear(&other_arg);
87 + strvec_clear(&other_arg);
88 strbuf_release(&range1);
89 strbuf_release(&range2);
90
builtin/rebase.c
+30 -30
@@ -84,7 +84,7 @@ struct rebase_options {
84 REBASE_FORCE = 1<<3,
85 REBASE_INTERACTIVE_EXPLICIT = 1<<4,
86 } flags;
87 - struct argv_array git_am_opts;
87 + struct strvec git_am_opts;
88 const char *action;
89 int signoff;
90 int allow_rerere_autoupdate;
@@ -108,7 +108,7 @@ struct rebase_options {
108 .keep_empty = 1, \
109 .default_backend = "merge", \
110 .flags = REBASE_NO_QUIET, \
111 - .git_am_opts = ARGV_ARRAY_INIT, \
111 + .git_am_opts = STRVEC_INIT, \
112 .git_format_patch_opt = STRBUF_INIT \
113 }
114
@@ -323,7 +323,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
323 int ret;
324 const char *head_hash = NULL;
325 char *revisions = NULL, *shortrevisions = NULL;
326 - struct argv_array make_script_args = ARGV_ARRAY_INIT;
326 + struct strvec make_script_args = STRVEC_INIT;
327 struct todo_list todo_list = TODO_LIST_INIT;
328 struct replay_opts replay = get_replay_opts(opts);
329 struct string_list commands = STRING_LIST_INIT_DUP;
@@ -345,9 +345,9 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
345 write_file(path_squash_onto(), "%s\n",
346 oid_to_hex(opts->squash_onto));
347
348 - argv_array_pushl(&make_script_args, "", revisions, NULL);
348 + strvec_pushl(&make_script_args, "", revisions, NULL);
349 if (opts->restrict_revision)
350 - argv_array_pushf(&make_script_args, "^%s",
350 + strvec_pushf(&make_script_args, "^%s",
351 oid_to_hex(&opts->restrict_revision->object.oid));
352
353 ret = sequencer_make_script(the_repository, &todo_list.buf,
@@ -372,7 +372,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
372 free(revisions);
373 free(shortrevisions);
374 todo_list_release(&todo_list);
375 - argv_array_clear(&make_script_args);
375 + strvec_clear(&make_script_args);
376
377 return ret;
378 }
@@ -420,7 +420,7 @@ static int run_sequencer_rebase(struct rebase_options *opts,
420 struct child_process cmd = CHILD_PROCESS_INIT;
421
422 cmd.git_cmd = 1;
423 - argv_array_pushl(&cmd.args, "show", "REBASE_HEAD", "--", NULL);
423 + strvec_pushl(&cmd.args, "show", "REBASE_HEAD", "--", NULL);
424 ret = run_command(&cmd);
425
426 break;
@@ -811,13 +811,13 @@ static int run_am(struct rebase_options *opts)
811 char *rebased_patches;
812
813 am.git_cmd = 1;
814 - argv_array_push(&am.args, "am");
814 + strvec_push(&am.args, "am");
815
816 if (opts->action && !strcmp("continue", opts->action)) {
817 - argv_array_push(&am.args, "--resolved");
818 - argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
817 + strvec_push(&am.args, "--resolved");
818 + strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
819 if (opts->gpg_sign_opt)
820 - argv_array_push(&am.args, opts->gpg_sign_opt);
820 + strvec_push(&am.args, opts->gpg_sign_opt);
821 status = run_command(&am);
822 if (status)
823 return status;
@@ -825,8 +825,8 @@ static int run_am(struct rebase_options *opts)
825 return move_to_original_branch(opts);
826 }
827 if (opts->action && !strcmp("skip", opts->action)) {
828 - argv_array_push(&am.args, "--skip");
829 - argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
828 + strvec_push(&am.args, "--skip");
829 + strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
830 status = run_command(&am);
831 if (status)
832 return status;
@@ -834,7 +834,7 @@ static int run_am(struct rebase_options *opts)
834 return move_to_original_branch(opts);
835 }
836 if (opts->action && !strcmp("show-current-patch", opts->action)) {
837 - argv_array_push(&am.args, "--show-current-patch");
837 + strvec_push(&am.args, "--show-current-patch");
838 return run_command(&am);
839 }
840
@@ -852,29 +852,29 @@ static int run_am(struct rebase_options *opts)
852 status = error_errno(_("could not open '%s' for writing"),
853 rebased_patches);
854 free(rebased_patches);
855 - argv_array_clear(&am.args);
855 + strvec_clear(&am.args);
856 return status;
857 }
858
859 format_patch.git_cmd = 1;
860 - argv_array_pushl(&format_patch.args, "format-patch", "-k", "--stdout",
860 + strvec_pushl(&format_patch.args, "format-patch", "-k", "--stdout",
861 "--full-index", "--cherry-pick", "--right-only",
862 "--src-prefix=a/", "--dst-prefix=b/", "--no-renames",
863 "--no-cover-letter", "--pretty=mboxrd", "--topo-order",
864 "--no-base", NULL);
865 if (opts->git_format_patch_opt.len)
866 - argv_array_split(&format_patch.args,
866 + strvec_split(&format_patch.args,
867 opts->git_format_patch_opt.buf);
868 - argv_array_push(&format_patch.args, revisions.buf);
868 + strvec_push(&format_patch.args, revisions.buf);
869 if (opts->restrict_revision)
870 - argv_array_pushf(&format_patch.args, "^%s",
870 + strvec_pushf(&format_patch.args, "^%s",
871 oid_to_hex(&opts->restrict_revision->object.oid));
872
873 status = run_command(&format_patch);
874 if (status) {
875 unlink(rebased_patches);
876 free(rebased_patches);
877 - argv_array_clear(&am.args);
877 + strvec_clear(&am.args);
878
879 reset_head(the_repository, &opts->orig_head, "checkout",
880 opts->head_name, 0,
@@ -896,20 +896,20 @@ static int run_am(struct rebase_options *opts)
896 status = error_errno(_("could not open '%s' for reading"),
897 rebased_patches);
898 free(rebased_patches);
899 - argv_array_clear(&am.args);
899 + strvec_clear(&am.args);
900 return status;
901 }
902
903 - argv_array_pushv(&am.args, opts->git_am_opts.argv);
904 - argv_array_push(&am.args, "--rebasing");
905 - argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
906 - argv_array_push(&am.args, "--patch-format=mboxrd");
903 + strvec_pushv(&am.args, opts->git_am_opts.argv);
904 + strvec_push(&am.args, "--rebasing");
905 + strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
906 + strvec_push(&am.args, "--patch-format=mboxrd");
907 if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
908 - argv_array_push(&am.args, "--rerere-autoupdate");
908 + strvec_push(&am.args, "--rerere-autoupdate");
909 else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
910 - argv_array_push(&am.args, "--no-rerere-autoupdate");
910 + strvec_push(&am.args, "--no-rerere-autoupdate");
911 if (opts->gpg_sign_opt)
912 - argv_array_push(&am.args, opts->gpg_sign_opt);
912 + strvec_push(&am.args, opts->gpg_sign_opt);
913 status = run_command(&am);
914 unlink(rebased_patches);
915 free(rebased_patches);
@@ -1649,7 +1649,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1649 exit(1);
1650
1651 if (!(options.flags & REBASE_NO_QUIET))
1652 - argv_array_push(&options.git_am_opts, "-q");
1652 + strvec_push(&options.git_am_opts, "-q");
1653
1654 if (options.empty != EMPTY_UNSPECIFIED)
1655 imply_merge(&options, "--empty");
@@ -1776,7 +1776,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1776 if (options.type == REBASE_PRESERVE_MERGES)
1777 die("cannot combine '--signoff' with "
1778 "'--preserve-merges'");
1779 - argv_array_push(&options.git_am_opts, "--signoff");
1779 + strvec_push(&options.git_am_opts, "--signoff");
1780 options.flags |= REBASE_FORCE;
1781 }
1782
builtin/receive-pack.c
+34 -34
@@ -667,23 +667,23 @@ static void prepare_push_cert_sha1(struct child_process *proc)
667 nonce_status = check_nonce(push_cert.buf, bogs);
668 }
669 if (!is_null_oid(&push_cert_oid)) {
670 - argv_array_pushf(&proc->env_array, "GIT_PUSH_CERT=%s",
670 + strvec_pushf(&proc->env_array, "GIT_PUSH_CERT=%s",
671 oid_to_hex(&push_cert_oid));
672 - argv_array_pushf(&proc->env_array, "GIT_PUSH_CERT_SIGNER=%s",
672 + strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_SIGNER=%s",
673 sigcheck.signer ? sigcheck.signer : "");
674 - argv_array_pushf(&proc->env_array, "GIT_PUSH_CERT_KEY=%s",
674 + strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_KEY=%s",
675 sigcheck.key ? sigcheck.key : "");
676 - argv_array_pushf(&proc->env_array, "GIT_PUSH_CERT_STATUS=%c",
676 + strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_STATUS=%c",
677 sigcheck.result);
678 if (push_cert_nonce) {
679 - argv_array_pushf(&proc->env_array,
679 + strvec_pushf(&proc->env_array,
680 "GIT_PUSH_CERT_NONCE=%s",
681 push_cert_nonce);
682 - argv_array_pushf(&proc->env_array,
682 + strvec_pushf(&proc->env_array,
683 "GIT_PUSH_CERT_NONCE_STATUS=%s",
684 nonce_status);
685 if (nonce_status == NONCE_SLOP)
686 - argv_array_pushf(&proc->env_array,
686 + strvec_pushf(&proc->env_array,
687 "GIT_PUSH_CERT_NONCE_SLOP=%ld",
688 nonce_stamp_slop);
689 }
@@ -720,16 +720,16 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,
720 if (feed_state->push_options) {
721 int i;
722 for (i = 0; i < feed_state->push_options->nr; i++)
723 - argv_array_pushf(&proc.env_array,
723 + strvec_pushf(&proc.env_array,
724 "GIT_PUSH_OPTION_%d=%s", i,
725 feed_state->push_options->items[i].string);
726 - argv_array_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%d",
726 + strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%d",
727 feed_state->push_options->nr);
728 } else
729 - argv_array_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT");
729 + strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT");
730
731 if (tmp_objdir)
732 - argv_array_pushv(&proc.env_array, tmp_objdir_env(tmp_objdir));
732 + strvec_pushv(&proc.env_array, tmp_objdir_env(tmp_objdir));
733
734 if (use_sideband) {
735 memset(&muxer, 0, sizeof(muxer));
@@ -931,7 +931,7 @@ static int head_has_history(void)
931 }
932
933 static const char *push_to_deploy(unsigned char *sha1,
934 - struct argv_array *env,
934 + struct strvec *env,
935 const char *work_tree)
936 {
937 const char *update_refresh[] = {
@@ -1000,10 +1000,10 @@ static const char *push_to_deploy(unsigned char *sha1,
1000 static const char *push_to_checkout_hook = "push-to-checkout";
1001
1002 static const char *push_to_checkout(unsigned char *hash,
1003 - struct argv_array *env,
1003 + struct strvec *env,
1004 const char *work_tree)
1005 {
1006 - argv_array_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1006 + strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1007 if (run_hook_le(env->argv, push_to_checkout_hook,
1008 hash_to_hex(hash), NULL))
1009 return "push-to-checkout hook declined";
@@ -1014,7 +1014,7 @@ static const char *push_to_checkout(unsigned char *hash,
1014 static const char *update_worktree(unsigned char *sha1, const struct worktree *worktree)
1015 {
1016 const char *retval, *work_tree, *git_dir = NULL;
1017 - struct argv_array env = ARGV_ARRAY_INIT;
1017 + struct strvec env = STRVEC_INIT;
1018
1019 if (worktree && worktree->path)
1020 work_tree = worktree->path;
@@ -1030,14 +1030,14 @@ static const char *update_worktree(unsigned char *sha1, const struct worktree *w
1030 if (!git_dir)
1031 git_dir = get_git_dir();
1032
1033 - argv_array_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
1033 + strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
1034
1035 if (!find_hook(push_to_checkout_hook))
1036 retval = push_to_deploy(sha1, &env, work_tree);
1037 else
1038 retval = push_to_checkout(sha1, &env, work_tree);
1039
1040 - argv_array_clear(&env);
1040 + strvec_clear(&env);
1041 return retval;
1042 }
1043
@@ -1206,8 +1206,8 @@ static void run_update_post_hook(struct command *commands)
1206 if (cmd->error_string || cmd->did_not_exist)
1207 continue;
1208 if (!proc.args.argc)
1209 - argv_array_push(&proc.args, hook);
1210 - argv_array_push(&proc.args, cmd->ref_name);
1209 + strvec_push(&proc.args, hook);
1210 + strvec_push(&proc.args, cmd->ref_name);
1211 }
1212 if (!proc.args.argc)
1213 return;
@@ -1715,9 +1715,9 @@ static const char *parse_pack_header(struct pack_header *hdr)
1715
1716 static const char *pack_lockfile;
1717
1718 -static void push_header_arg(struct argv_array *args, struct pack_header *hdr)
1718 +static void push_header_arg(struct strvec *args, struct pack_header *hdr)
1719 {
1720 - argv_array_pushf(args, "--pack_header=%"PRIu32",%"PRIu32,
1720 + strvec_pushf(args, "--pack_header=%"PRIu32",%"PRIu32,
1721 ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries));
1722 }
1723
@@ -1742,8 +1742,8 @@ static const char *unpack(int err_fd, struct shallow_info *si)
1742
1743 if (si->nr_ours || si->nr_theirs) {
1744 alt_shallow_file = setup_temporary_shallow(si->shallow);
1745 - argv_array_push(&child.args, "--shallow-file");
1746 - argv_array_push(&child.args, alt_shallow_file);
1745 + strvec_push(&child.args, "--shallow-file");
1746 + strvec_push(&child.args, alt_shallow_file);
1747 }
1748
1749 tmp_objdir = tmp_objdir_create();
@@ -1762,15 +1762,15 @@ static const char *unpack(int err_fd, struct shallow_info *si)
1762 tmp_objdir_add_as_alternate(tmp_objdir);
1763
1764 if (ntohl(hdr.hdr_entries) < unpack_limit) {
1765 - argv_array_push(&child.args, "unpack-objects");
1765 + strvec_push(&child.args, "unpack-objects");
1766 push_header_arg(&child.args, &hdr);
1767 if (quiet)
1768 - argv_array_push(&child.args, "-q");
1768 + strvec_push(&child.args, "-q");
1769 if (fsck_objects)
1770 - argv_array_pushf(&child.args, "--strict%s",
1770 + strvec_pushf(&child.args, "--strict%s",
1771 fsck_msg_types.buf);
1772 if (max_input_size)
1773 - argv_array_pushf(&child.args, "--max-input-size=%"PRIuMAX,
1773 + strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX,
1774 (uintmax_t)max_input_size);
1775 child.no_stdout = 1;
1776 child.err = err_fd;
@@ -1781,27 +1781,27 @@ static const char *unpack(int err_fd, struct shallow_info *si)
1781 } else {
1782 char hostname[HOST_NAME_MAX + 1];
1783
1784 - argv_array_pushl(&child.args, "index-pack", "--stdin", NULL);
1784 + strvec_pushl(&child.args, "index-pack", "--stdin", NULL);
1785 push_header_arg(&child.args, &hdr);
1786
1787 if (xgethostname(hostname, sizeof(hostname)))
1788 xsnprintf(hostname, sizeof(hostname), "localhost");
1789 - argv_array_pushf(&child.args,
1789 + strvec_pushf(&child.args,
1790 "--keep=receive-pack %"PRIuMAX" on %s",
1791 (uintmax_t)getpid(),
1792 hostname);
1793
1794 if (!quiet && err_fd)
1795 - argv_array_push(&child.args, "--show-resolving-progress");
1795 + strvec_push(&child.args, "--show-resolving-progress");
1796 if (use_sideband)
1797 - argv_array_push(&child.args, "--report-end-of-input");
1797 + strvec_push(&child.args, "--report-end-of-input");
1798 if (fsck_objects)
1799 - argv_array_pushf(&child.args, "--strict%s",
1799 + strvec_pushf(&child.args, "--strict%s",
1800 fsck_msg_types.buf);
1801 if (!reject_thin)
1802 - argv_array_push(&child.args, "--fix-thin");
1802 + strvec_push(&child.args, "--fix-thin");
1803 if (max_input_size)
1804 - argv_array_pushf(&child.args, "--max-input-size=%"PRIuMAX,
1804 + strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX,
1805 (uintmax_t)max_input_size);
1806 child.out = -1;
1807 child.err = err_fd;
builtin/remote-ext.c
+2 -2
@@ -117,12 +117,12 @@ static char *strip_escapes(const char *str, const char *service,
117 }
118 }
119
120 -static void parse_argv(struct argv_array *out, const char *arg, const char *service)
120 +static void parse_argv(struct strvec *out, const char *arg, const char *service)
121 {
122 while (*arg) {
123 char *expanded = strip_escapes(arg, service, &arg);
124 if (expanded)
125 - argv_array_push(out, expanded);
125 + strvec_push(out, expanded);
126 free(expanded);
127 }
128 }
builtin/remote.c
+10 -10
@@ -1451,35 +1451,35 @@ static int update(int argc, const char **argv)
1451 N_("prune remotes after fetching")),
1452 OPT_END()
1453 };
1454 - struct argv_array fetch_argv = ARGV_ARRAY_INIT;
1454 + struct strvec fetch_argv = STRVEC_INIT;
1455 int default_defined = 0;
1456 int retval;
1457
1458 argc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage,
1459 PARSE_OPT_KEEP_ARGV0);
1460
1461 - argv_array_push(&fetch_argv, "fetch");
1461 + strvec_push(&fetch_argv, "fetch");
1462
1463 if (prune != -1)
1464 - argv_array_push(&fetch_argv, prune ? "--prune" : "--no-prune");
1464 + strvec_push(&fetch_argv, prune ? "--prune" : "--no-prune");
1465 if (verbose)
1466 - argv_array_push(&fetch_argv, "-v");
1467 - argv_array_push(&fetch_argv, "--multiple");
1466 + strvec_push(&fetch_argv, "-v");
1467 + strvec_push(&fetch_argv, "--multiple");
1468 if (argc < 2)
1469 - argv_array_push(&fetch_argv, "default");
1469 + strvec_push(&fetch_argv, "default");
1470 for (i = 1; i < argc; i++)
1471 - argv_array_push(&fetch_argv, argv[i]);
1471 + strvec_push(&fetch_argv, argv[i]);
1472
1473 if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
1474 git_config(get_remote_default, &default_defined);
1475 if (!default_defined) {
1476 - argv_array_pop(&fetch_argv);
1477 - argv_array_push(&fetch_argv, "--all");
1476 + strvec_pop(&fetch_argv);
1477 + strvec_push(&fetch_argv, "--all");
1478 }
1479 }
1480
1481 retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
1482 - argv_array_clear(&fetch_argv);
1482 + strvec_clear(&fetch_argv);
1483 return retval;
1484 }
1485
builtin/repack.c
+31 -31
@@ -153,28 +153,28 @@ struct pack_objects_args {
153 static void prepare_pack_objects(struct child_process *cmd,
154 const struct pack_objects_args *args)
155 {
156 - argv_array_push(&cmd->args, "pack-objects");
156 + strvec_push(&cmd->args, "pack-objects");
157 if (args->window)
158 - argv_array_pushf(&cmd->args, "--window=%s", args->window);
158 + strvec_pushf(&cmd->args, "--window=%s", args->window);
159 if (args->window_memory)
160 - argv_array_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
160 + strvec_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
161 if (args->depth)
162 - argv_array_pushf(&cmd->args, "--depth=%s", args->depth);
162 + strvec_pushf(&cmd->args, "--depth=%s", args->depth);
163 if (args->threads)
164 - argv_array_pushf(&cmd->args, "--threads=%s", args->threads);
164 + strvec_pushf(&cmd->args, "--threads=%s", args->threads);
165 if (args->max_pack_size)
166 - argv_array_pushf(&cmd->args, "--max-pack-size=%s", args->max_pack_size);
166 + strvec_pushf(&cmd->args, "--max-pack-size=%s", args->max_pack_size);
167 if (args->no_reuse_delta)
168 - argv_array_pushf(&cmd->args, "--no-reuse-delta");
168 + strvec_pushf(&cmd->args, "--no-reuse-delta");
169 if (args->no_reuse_object)
170 - argv_array_pushf(&cmd->args, "--no-reuse-object");
170 + strvec_pushf(&cmd->args, "--no-reuse-object");
171 if (args->local)
172 - argv_array_push(&cmd->args, "--local");
172 + strvec_push(&cmd->args, "--local");
173 if (args->quiet)
174 - argv_array_push(&cmd->args, "--quiet");
174 + strvec_push(&cmd->args, "--quiet");
175 if (delta_base_offset)
176 - argv_array_push(&cmd->args, "--delta-base-offset");
177 - argv_array_push(&cmd->args, packtmp);
176 + strvec_push(&cmd->args, "--delta-base-offset");
177 + strvec_push(&cmd->args, packtmp);
178 cmd->git_cmd = 1;
179 cmd->out = -1;
180 }
@@ -361,24 +361,24 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
361
362 prepare_pack_objects(&cmd, &po_args);
363
364 - argv_array_push(&cmd.args, "--keep-true-parents");
364 + strvec_push(&cmd.args, "--keep-true-parents");
365 if (!pack_kept_objects)
366 - argv_array_push(&cmd.args, "--honor-pack-keep");
366 + strvec_push(&cmd.args, "--honor-pack-keep");
367 for (i = 0; i < keep_pack_list.nr; i++)
368 - argv_array_pushf(&cmd.args, "--keep-pack=%s",
368 + strvec_pushf(&cmd.args, "--keep-pack=%s",
369 keep_pack_list.items[i].string);
370 - argv_array_push(&cmd.args, "--non-empty");
371 - argv_array_push(&cmd.args, "--all");
372 - argv_array_push(&cmd.args, "--reflog");
373 - argv_array_push(&cmd.args, "--indexed-objects");
370 + strvec_push(&cmd.args, "--non-empty");
371 + strvec_push(&cmd.args, "--all");
372 + strvec_push(&cmd.args, "--reflog");
373 + strvec_push(&cmd.args, "--indexed-objects");
374 if (has_promisor_remote())
375 - argv_array_push(&cmd.args, "--exclude-promisor-objects");
375 + strvec_push(&cmd.args, "--exclude-promisor-objects");
376 if (write_bitmaps > 0)
377 - argv_array_push(&cmd.args, "--write-bitmap-index");
377 + strvec_push(&cmd.args, "--write-bitmap-index");
378 else if (write_bitmaps < 0)
379 - argv_array_push(&cmd.args, "--write-bitmap-index-quiet");
379 + strvec_push(&cmd.args, "--write-bitmap-index-quiet");
380 if (use_delta_islands)
381 - argv_array_push(&cmd.args, "--delta-islands");
381 + strvec_push(&cmd.args, "--delta-islands");
382
383 if (pack_everything & ALL_INTO_ONE) {
384 get_non_kept_pack_filenames(&existing_packs, &keep_pack_list);
@@ -387,23 +387,23 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
387
388 if (existing_packs.nr && delete_redundant) {
389 if (unpack_unreachable) {
390 - argv_array_pushf(&cmd.args,
390 + strvec_pushf(&cmd.args,
391 "--unpack-unreachable=%s",
392 unpack_unreachable);
393 - argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
393 + strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
394 } else if (pack_everything & LOOSEN_UNREACHABLE) {
395 - argv_array_push(&cmd.args,
395 + strvec_push(&cmd.args,
396 "--unpack-unreachable");
397 } else if (keep_unreachable) {
398 - argv_array_push(&cmd.args, "--keep-unreachable");
399 - argv_array_push(&cmd.args, "--pack-loose-unreachable");
398 + strvec_push(&cmd.args, "--keep-unreachable");
399 + strvec_push(&cmd.args, "--pack-loose-unreachable");
400 } else {
401 - argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
401 + strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
402 }
403 }
404 } else {
405 - argv_array_push(&cmd.args, "--unpacked");
406 - argv_array_push(&cmd.args, "--incremental");
405 + strvec_push(&cmd.args, "--unpacked");
406 + strvec_push(&cmd.args, "--incremental");
407 }
408
409 cmd.no_stdin = 1;
builtin/replace.c
+8 -8
@@ -228,13 +228,13 @@ static int export_object(const struct object_id *oid, enum object_type type,
228 if (fd < 0)
229 return error_errno(_("unable to open %s for writing"), filename);
230
231 - argv_array_push(&cmd.args, "--no-replace-objects");
232 - argv_array_push(&cmd.args, "cat-file");
231 + strvec_push(&cmd.args, "--no-replace-objects");
232 + strvec_push(&cmd.args, "cat-file");
233 if (raw)
234 - argv_array_push(&cmd.args, type_name(type));
234 + strvec_push(&cmd.args, type_name(type));
235 else
236 - argv_array_push(&cmd.args, "-p");
237 - argv_array_push(&cmd.args, oid_to_hex(oid));
236 + strvec_push(&cmd.args, "-p");
237 + strvec_push(&cmd.args, oid_to_hex(oid));
238 cmd.git_cmd = 1;
239 cmd.out = fd;
240
@@ -502,7 +502,7 @@ static int convert_graft_file(int force)
502 const char *graft_file = get_graft_file(the_repository);
503 FILE *fp = fopen_or_warn(graft_file, "r");
504 struct strbuf buf = STRBUF_INIT, err = STRBUF_INIT;
505 - struct argv_array args = ARGV_ARRAY_INIT;
505 + struct strvec args = STRVEC_INIT;
506
507 if (!fp)
508 return -1;
@@ -512,10 +512,10 @@ static int convert_graft_file(int force)
512 if (*buf.buf == '#')
513 continue;
514
515 - argv_array_split(&args, buf.buf);
515 + strvec_split(&args, buf.buf);
516 if (args.argc && create_graft(args.argc, args.argv, force, 1))
517 strbuf_addf(&err, "\n\t%s", buf.buf);
518 - argv_array_clear(&args);
518 + strvec_clear(&args);
519 }
520 fclose(fp);
521
builtin/show-branch.c
+3 -3
@@ -20,7 +20,7 @@ static const char* show_branch_usage[] = {
20
21 static int showbranch_use_color = -1;
22
23 -static struct argv_array default_args = ARGV_ARRAY_INIT;
23 +static struct strvec default_args = STRVEC_INIT;
24
25 /*
26 * TODO: convert this use of commit->object.flags to commit-slab
@@ -562,8 +562,8 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
562 * mimic the real argv a bit better.
563 */
564 if (!default_args.argc)
565 - argv_array_push(&default_args, "show-branch");
566 - argv_array_push(&default_args, value);
565 + strvec_push(&default_args, "show-branch");
566 + strvec_push(&default_args, value);
567 return 0;
568 }
569
builtin/stash.c
+57 -57
@@ -277,8 +277,8 @@ static int diff_tree_binary(struct strbuf *out, struct object_id *w_commit)
277 * however it should be done together with apply_cached.
278 */
279 cp.git_cmd = 1;
280 - argv_array_pushl(&cp.args, "diff-tree", "--binary", NULL);
281 - argv_array_pushf(&cp.args, "%s^2^..%s^2", w_commit_hex, w_commit_hex);
280 + strvec_pushl(&cp.args, "diff-tree", "--binary", NULL);
281 + strvec_pushf(&cp.args, "%s^2^..%s^2", w_commit_hex, w_commit_hex);
282
283 return pipe_command(&cp, NULL, 0, out, 0, NULL, 0);
284 }
@@ -293,7 +293,7 @@ static int apply_cached(struct strbuf *out)
293 * buffer.
294 */
295 cp.git_cmd = 1;
296 - argv_array_pushl(&cp.args, "apply", "--cached", NULL);
296 + strvec_pushl(&cp.args, "apply", "--cached", NULL);
297 return pipe_command(&cp, out->buf, out->len, NULL, 0, NULL, 0);
298 }
299
@@ -306,7 +306,7 @@ static int reset_head(void)
306 * API for resetting.
307 */
308 cp.git_cmd = 1;
309 - argv_array_push(&cp.args, "reset");
309 + strvec_push(&cp.args, "reset");
310
311 return run_command(&cp);
312 }
@@ -335,9 +335,9 @@ static int get_newly_staged(struct strbuf *out, struct object_id *c_tree)
335 * converted together with update_index.
336 */
337 cp.git_cmd = 1;
338 - argv_array_pushl(&cp.args, "diff-index", "--cached", "--name-only",
338 + strvec_pushl(&cp.args, "diff-index", "--cached", "--name-only",
339 "--diff-filter=A", NULL);
340 - argv_array_push(&cp.args, c_tree_hex);
340 + strvec_push(&cp.args, c_tree_hex);
341 return pipe_command(&cp, NULL, 0, out, 0, NULL, 0);
342 }
343
@@ -350,7 +350,7 @@ static int update_index(struct strbuf *out)
350 * function exposed in order to remove this forking.
351 */
352 cp.git_cmd = 1;
353 - argv_array_pushl(&cp.args, "update-index", "--add", "--stdin", NULL);
353 + strvec_pushl(&cp.args, "update-index", "--add", "--stdin", NULL);
354 return pipe_command(&cp, out->buf, out->len, NULL, 0, NULL, 0);
355 }
356
@@ -365,9 +365,9 @@ static int restore_untracked(struct object_id *u_tree)
365 * run_command to fork processes that will not interfere.
366 */
367 cp.git_cmd = 1;
368 - argv_array_push(&cp.args, "read-tree");
369 - argv_array_push(&cp.args, oid_to_hex(u_tree));
370 - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
368 + strvec_push(&cp.args, "read-tree");
369 + strvec_push(&cp.args, oid_to_hex(u_tree));
370 + strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
371 stash_index_path.buf);
372 if (run_command(&cp)) {
373 remove_path(stash_index_path.buf);
@@ -376,8 +376,8 @@ static int restore_untracked(struct object_id *u_tree)
376
377 child_process_init(&cp);
378 cp.git_cmd = 1;
379 - argv_array_pushl(&cp.args, "checkout-index", "--all", NULL);
380 - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
379 + strvec_pushl(&cp.args, "checkout-index", "--all", NULL);
380 + strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
381 stash_index_path.buf);
382
383 res = run_command(&cp);
@@ -499,11 +499,11 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
499 */
500 cp.git_cmd = 1;
501 cp.dir = prefix;
502 - argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
502 + strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
503 absolute_path(get_git_work_tree()));
504 - argv_array_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
504 + strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
505 absolute_path(get_git_dir()));
506 - argv_array_push(&cp.args, "status");
506 + strvec_push(&cp.args, "status");
507 run_command(&cp);
508 }
509
@@ -546,9 +546,9 @@ static int do_drop_stash(struct stash_info *info, int quiet)
546 */
547
548 cp_reflog.git_cmd = 1;
549 - argv_array_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
549 + strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
550 "--rewrite", NULL);
551 - argv_array_push(&cp_reflog.args, info->revision.buf);
551 + strvec_push(&cp_reflog.args, info->revision.buf);
552 ret = run_command(&cp_reflog);
553 if (!ret) {
554 if (!quiet)
@@ -566,8 +566,8 @@ static int do_drop_stash(struct stash_info *info, int quiet)
566 cp.git_cmd = 1;
567 /* Even though --quiet is specified, rev-parse still outputs the hash */
568 cp.no_stdout = 1;
569 - argv_array_pushl(&cp.args, "rev-parse", "--verify", "--quiet", NULL);
570 - argv_array_pushf(&cp.args, "%s@{0}", ref_stash);
569 + strvec_pushl(&cp.args, "rev-parse", "--verify", "--quiet", NULL);
570 + strvec_pushf(&cp.args, "%s@{0}", ref_stash);
571 ret = run_command(&cp);
572
573 /* do_clear_stash if we just dropped the last stash entry */
@@ -663,9 +663,9 @@ static int branch_stash(int argc, const char **argv, const char *prefix)
663 return -1;
664
665 cp.git_cmd = 1;
666 - argv_array_pushl(&cp.args, "checkout", "-b", NULL);
667 - argv_array_push(&cp.args, branch);
668 - argv_array_push(&cp.args, oid_to_hex(&info.b_commit));
666 + strvec_pushl(&cp.args, "checkout", "-b", NULL);
667 + strvec_push(&cp.args, branch);
668 + strvec_push(&cp.args, oid_to_hex(&info.b_commit));
669 ret = run_command(&cp);
670 if (!ret)
671 ret = do_apply_stash(prefix, &info, 1, 0);
@@ -692,11 +692,11 @@ static int list_stash(int argc, const char **argv, const char *prefix)
692 return 0;
693
694 cp.git_cmd = 1;
695 - argv_array_pushl(&cp.args, "log", "--format=%gd: %gs", "-g",
695 + strvec_pushl(&cp.args, "log", "--format=%gd: %gs", "-g",
696 "--first-parent", "-m", NULL);
697 - argv_array_pushv(&cp.args, argv);
698 - argv_array_push(&cp.args, ref_stash);
699 - argv_array_push(&cp.args, "--");
697 + strvec_pushv(&cp.args, argv);
698 + strvec_push(&cp.args, ref_stash);
699 + strvec_push(&cp.args, "--");
700 return run_command(&cp);
701 }
702
@@ -727,8 +727,8 @@ static int show_stash(int argc, const char **argv, const char *prefix)
727 int ret = 0;
728 struct stash_info info;
729 struct rev_info rev;
730 - struct argv_array stash_args = ARGV_ARRAY_INIT;
731 - struct argv_array revision_args = ARGV_ARRAY_INIT;
730 + struct strvec stash_args = STRVEC_INIT;
731 + struct strvec revision_args = STRVEC_INIT;
732 struct option options[] = {
733 OPT_END()
734 };
@@ -737,16 +737,16 @@ static int show_stash(int argc, const char **argv, const char *prefix)
737 git_config(git_diff_ui_config, NULL);
738 init_revisions(&rev, prefix);
739
740 - argv_array_push(&revision_args, argv[0]);
740 + strvec_push(&revision_args, argv[0]);
741 for (i = 1; i < argc; i++) {
742 if (argv[i][0] != '-')
743 - argv_array_push(&stash_args, argv[i]);
743 + strvec_push(&stash_args, argv[i]);
744 else
745 - argv_array_push(&revision_args, argv[i]);
745 + strvec_push(&revision_args, argv[i]);
746 }
747
748 ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
749 - argv_array_clear(&stash_args);
749 + strvec_clear(&stash_args);
750 if (ret)
751 return -1;
752
@@ -842,12 +842,12 @@ static int store_stash(int argc, const char **argv, const char *prefix)
842 return do_store_stash(&obj, stash_msg, quiet);
843 }
844
845 -static void add_pathspecs(struct argv_array *args,
845 +static void add_pathspecs(struct strvec *args,
846 const struct pathspec *ps) {
847 int i;
848
849 for (i = 0; i < ps->nr; i++)
850 - argv_array_push(args, ps->items[i].original);
850 + strvec_push(args, ps->items[i].original);
851 }
852
853 /*
@@ -960,9 +960,9 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg,
960 struct index_state istate = { NULL };
961
962 cp_upd_index.git_cmd = 1;
963 - argv_array_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
963 + strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
964 "--remove", "--stdin", NULL);
965 - argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
965 + strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
966 stash_index_path.buf);
967
968 strbuf_addf(&untracked_msg, "untracked files on %s\n", msg->buf);
@@ -1003,8 +1003,8 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
1003 remove_path(stash_index_path.buf);
1004
1005 cp_read_tree.git_cmd = 1;
1006 - argv_array_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1007 - argv_array_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1006 + strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1007 + strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1008 stash_index_path.buf);
1009 if (run_command(&cp_read_tree)) {
1010 ret = -1;
@@ -1034,7 +1034,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
1034 }
1035
1036 cp_diff_tree.git_cmd = 1;
1037 - argv_array_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
1037 + strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
1038 oid_to_hex(&info->w_tree), "--", NULL);
1039 if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) {
1040 ret = -1;
@@ -1088,10 +1088,10 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
1088 }
1089
1090 cp_upd_index.git_cmd = 1;
1091 - argv_array_pushl(&cp_upd_index.args, "update-index",
1091 + strvec_pushl(&cp_upd_index.args, "update-index",
1092 "--ignore-skip-worktree-entries",
1093 "-z", "--add", "--remove", "--stdin", NULL);
1094 - argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1094 + strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1095 stash_index_path.buf);
1096
1097 if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1342,10 +1342,10 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1342 struct child_process cp = CHILD_PROCESS_INIT;
1343
1344 cp.git_cmd = 1;
1345 - argv_array_pushl(&cp.args, "clean", "--force",
1345 + strvec_pushl(&cp.args, "clean", "--force",
1346 "--quiet", "-d", NULL);
1347 if (include_untracked == INCLUDE_ALL_FILES)
1348 - argv_array_push(&cp.args, "-x");
1348 + strvec_push(&cp.args, "-x");
1349 if (run_command(&cp)) {
1350 ret = -1;
1351 goto done;
@@ -1359,12 +1359,12 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1359 struct strbuf out = STRBUF_INIT;
1360
1361 cp_add.git_cmd = 1;
1362 - argv_array_push(&cp_add.args, "add");
1362 + strvec_push(&cp_add.args, "add");
1363 if (!include_untracked)
1364 - argv_array_push(&cp_add.args, "-u");
1364 + strvec_push(&cp_add.args, "-u");
1365 if (include_untracked == INCLUDE_ALL_FILES)
1366 - argv_array_push(&cp_add.args, "--force");
1367 - argv_array_push(&cp_add.args, "--");
1366 + strvec_push(&cp_add.args, "--force");
1367 + strvec_push(&cp_add.args, "--");
1368 add_pathspecs(&cp_add.args, ps);
1369 if (run_command(&cp_add)) {
1370 ret = -1;
@@ -1372,7 +1372,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1372 }
1373
1374 cp_diff.git_cmd = 1;
1375 - argv_array_pushl(&cp_diff.args, "diff-index", "-p",
1375 + strvec_pushl(&cp_diff.args, "diff-index", "-p",
1376 "--cached", "--binary", "HEAD", "--",
1377 NULL);
1378 add_pathspecs(&cp_diff.args, ps);
@@ -1382,7 +1382,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1382 }
1383
1384 cp_apply.git_cmd = 1;
1385 - argv_array_pushl(&cp_apply.args, "apply", "--index",
1385 + strvec_pushl(&cp_apply.args, "apply", "--index",
1386 "-R", NULL);
1387 if (pipe_command(&cp_apply, out.buf, out.len, NULL, 0,
1388 NULL, 0)) {
@@ -1392,7 +1392,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1392 } else {
1393 struct child_process cp = CHILD_PROCESS_INIT;
1394 cp.git_cmd = 1;
1395 - argv_array_pushl(&cp.args, "reset", "--hard", "-q",
1395 + strvec_pushl(&cp.args, "reset", "--hard", "-q",
1396 "--no-recurse-submodules", NULL);
1397 if (run_command(&cp)) {
1398 ret = -1;
@@ -1404,10 +1404,10 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1404 struct child_process cp = CHILD_PROCESS_INIT;
1405
1406 cp.git_cmd = 1;
1407 - argv_array_pushl(&cp.args, "checkout", "--no-overlay",
1407 + strvec_pushl(&cp.args, "checkout", "--no-overlay",
1408 oid_to_hex(&info.i_tree), "--", NULL);
1409 if (!ps->nr)
1410 - argv_array_push(&cp.args, ":/");
1410 + strvec_push(&cp.args, ":/");
1411 else
1412 add_pathspecs(&cp.args, ps);
1413 if (run_command(&cp)) {
@@ -1420,7 +1420,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1420 struct child_process cp = CHILD_PROCESS_INIT;
1421
1422 cp.git_cmd = 1;
1423 - argv_array_pushl(&cp.args, "apply", "-R", NULL);
1423 + strvec_pushl(&cp.args, "apply", "-R", NULL);
1424
1425 if (pipe_command(&cp, patch.buf, patch.len, NULL, 0, NULL, 0)) {
1426 if (!quiet)
@@ -1434,7 +1434,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1434 struct child_process cp = CHILD_PROCESS_INIT;
1435
1436 cp.git_cmd = 1;
1437 - argv_array_pushl(&cp.args, "reset", "-q", "--", NULL);
1437 + strvec_pushl(&cp.args, "reset", "-q", "--", NULL);
1438 add_pathspecs(&cp.args, ps);
1439 if (run_command(&cp)) {
1440 ret = -1;
@@ -1560,7 +1560,7 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
1560 {
1561 pid_t pid = getpid();
1562 const char *index_file;
1563 - struct argv_array args = ARGV_ARRAY_INIT;
1563 + struct strvec args = STRVEC_INIT;
1564
1565 struct option options[] = {
1566 OPT_END()
@@ -1609,7 +1609,7 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
1609 git_stash_usage, options);
1610
1611 /* Assume 'stash push' */
1612 - argv_array_push(&args, "push");
1613 - argv_array_pushv(&args, argv);
1612 + strvec_push(&args, "push");
1613 + strvec_pushv(&args, argv);
1614 return !!push_stash(args.argc, args.argv, prefix, 1);
1615 }
builtin/submodule--helper.c
+59 -59
@@ -294,9 +294,9 @@ static char *compute_rev_name(const char *sub_path, const char* object_id)
294 cp.git_cmd = 1;
295 cp.no_stderr = 1;
296
297 - argv_array_push(&cp.args, "describe");
298 - argv_array_pushv(&cp.args, *d);
299 - argv_array_push(&cp.args, object_id);
297 + strvec_push(&cp.args, "describe");
298 + strvec_pushv(&cp.args, *d);
299 + strvec_push(&cp.args, object_id);
300
301 if (!capture_command(&cp, &sb, 0)) {
302 strbuf_strip_suffix(&sb, "\n");
@@ -495,12 +495,12 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
495 char *toplevel = xgetcwd();
496 struct strbuf sb = STRBUF_INIT;
497
498 - argv_array_pushf(&cp.env_array, "name=%s", sub->name);
499 - argv_array_pushf(&cp.env_array, "sm_path=%s", path);
500 - argv_array_pushf(&cp.env_array, "displaypath=%s", displaypath);
501 - argv_array_pushf(&cp.env_array, "sha1=%s",
498 + strvec_pushf(&cp.env_array, "name=%s", sub->name);
499 + strvec_pushf(&cp.env_array, "sm_path=%s", path);
500 + strvec_pushf(&cp.env_array, "displaypath=%s", displaypath);
501 + strvec_pushf(&cp.env_array, "sha1=%s",
502 oid_to_hex(ce_oid));
503 - argv_array_pushf(&cp.env_array, "toplevel=%s", toplevel);
503 + strvec_pushf(&cp.env_array, "toplevel=%s", toplevel);
504
505 /*
506 * Since the path variable was accessible from the script
@@ -509,15 +509,15 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
509 * on windows. And since environment variables are
510 * case-insensitive in windows, it interferes with the
511 * existing PATH variable. Hence, to avoid that, we expose
512 - * path via the args argv_array and not via env_array.
512 + * path via the args strvec and not via env_array.
513 */
514 sq_quote_buf(&sb, path);
515 - argv_array_pushf(&cp.args, "path=%s; %s",
515 + strvec_pushf(&cp.args, "path=%s; %s",
516 sb.buf, info->argv[0]);
517 strbuf_release(&sb);
518 free(toplevel);
519 } else {
520 - argv_array_pushv(&cp.args, info->argv);
520 + strvec_pushv(&cp.args, info->argv);
521 }
522
523 if (!info->quiet)
@@ -534,16 +534,16 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
534 cpr.dir = path;
535 prepare_submodule_repo_env(&cpr.env_array);
536
537 - argv_array_pushl(&cpr.args, "--super-prefix", NULL);
538 - argv_array_pushf(&cpr.args, "%s/", displaypath);
539 - argv_array_pushl(&cpr.args, "submodule--helper", "foreach", "--recursive",
537 + strvec_pushl(&cpr.args, "--super-prefix", NULL);
538 + strvec_pushf(&cpr.args, "%s/", displaypath);
539 + strvec_pushl(&cpr.args, "submodule--helper", "foreach", "--recursive",
540 NULL);
541
542 if (info->quiet)
543 - argv_array_push(&cpr.args, "--quiet");
543 + strvec_push(&cpr.args, "--quiet");
544
545 - argv_array_push(&cpr.args, "--");
546 - argv_array_pushv(&cpr.args, info->argv);
545 + strvec_push(&cpr.args, "--");
546 + strvec_pushv(&cpr.args, info->argv);
547
548 if (run_command(&cpr))
549 die(_("run_command returned non-zero status while "
@@ -779,7 +779,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
779 unsigned int flags)
780 {
781 char *displaypath;
782 - struct argv_array diff_files_args = ARGV_ARRAY_INIT;
782 + struct strvec diff_files_args = STRVEC_INIT;
783 struct rev_info rev;
784 int diff_files_result;
785 struct strbuf buf = STRBUF_INIT;
@@ -809,7 +809,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
809 }
810 strbuf_release(&buf);
811
812 - argv_array_pushl(&diff_files_args, "diff-files",
812 + strvec_pushl(&diff_files_args, "diff-files",
813 "--ignore-submodules=dirty", "--quiet", "--",
814 path, NULL);
815
@@ -849,23 +849,23 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
849 cpr.dir = path;
850 prepare_submodule_repo_env(&cpr.env_array);
851
852 - argv_array_push(&cpr.args, "--super-prefix");
853 - argv_array_pushf(&cpr.args, "%s/", displaypath);
854 - argv_array_pushl(&cpr.args, "submodule--helper", "status",
852 + strvec_push(&cpr.args, "--super-prefix");
853 + strvec_pushf(&cpr.args, "%s/", displaypath);
854 + strvec_pushl(&cpr.args, "submodule--helper", "status",
855 "--recursive", NULL);
856
857 if (flags & OPT_CACHED)
858 - argv_array_push(&cpr.args, "--cached");
858 + strvec_push(&cpr.args, "--cached");
859
860 if (flags & OPT_QUIET)
861 - argv_array_push(&cpr.args, "--quiet");
861 + strvec_push(&cpr.args, "--quiet");
862
863 if (run_command(&cpr))
864 die(_("failed to recurse into submodule '%s'"), path);
865 }
866
867 cleanup:
868 - argv_array_clear(&diff_files_args);
868 + strvec_clear(&diff_files_args);
869 free(displaypath);
870 }
871
@@ -995,7 +995,7 @@ static void sync_submodule(const char *path, const char *prefix,
995 prepare_submodule_repo_env(&cp.env_array);
996 cp.git_cmd = 1;
997 cp.dir = path;
998 - argv_array_pushl(&cp.args, "submodule--helper",
998 + strvec_pushl(&cp.args, "submodule--helper",
999 "print-default-remote", NULL);
1000
1001 strbuf_reset(&sb);
@@ -1021,13 +1021,13 @@ static void sync_submodule(const char *path, const char *prefix,
1021 cpr.dir = path;
1022 prepare_submodule_repo_env(&cpr.env_array);
1023
1024 - argv_array_push(&cpr.args, "--super-prefix");
1025 - argv_array_pushf(&cpr.args, "%s/", displaypath);
1026 - argv_array_pushl(&cpr.args, "submodule--helper", "sync",
1024 + strvec_push(&cpr.args, "--super-prefix");
1025 + strvec_pushf(&cpr.args, "%s/", displaypath);
1026 + strvec_pushl(&cpr.args, "submodule--helper", "sync",
1027 "--recursive", NULL);
1028
1029 if (flags & OPT_QUIET)
1030 - argv_array_push(&cpr.args, "--quiet");
1030 + strvec_push(&cpr.args, "--quiet");
1031
1032 if (run_command(&cpr))
1033 die(_("failed to recurse into submodule '%s'"),
@@ -1127,7 +1127,7 @@ static void deinit_submodule(const char *path, const char *prefix,
1127 if (!(flags & OPT_FORCE)) {
1128 struct child_process cp_rm = CHILD_PROCESS_INIT;
1129 cp_rm.git_cmd = 1;
1130 - argv_array_pushl(&cp_rm.args, "rm", "-qn",
1130 + strvec_pushl(&cp_rm.args, "rm", "-qn",
1131 path, NULL);
1132
1133 if (run_command(&cp_rm))
@@ -1156,8 +1156,8 @@ static void deinit_submodule(const char *path, const char *prefix,
1156 displaypath);
1157
1158 cp_config.git_cmd = 1;
1159 - argv_array_pushl(&cp_config.args, "config", "--get-regexp", NULL);
1160 - argv_array_pushf(&cp_config.args, "submodule.%s\\.", sub->name);
1159 + strvec_pushl(&cp_config.args, "config", "--get-regexp", NULL);
1160 + strvec_pushf(&cp_config.args, "submodule.%s\\.", sub->name);
1161
1162 /* remove the .git/config entries (unless the user already did it) */
1163 if (!capture_command(&cp_config, &sb_config, 0) && sb_config.len) {
@@ -1239,32 +1239,32 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
1239 {
1240 struct child_process cp = CHILD_PROCESS_INIT;
1241
1242 - argv_array_push(&cp.args, "clone");
1243 - argv_array_push(&cp.args, "--no-checkout");
1242 + strvec_push(&cp.args, "clone");
1243 + strvec_push(&cp.args, "--no-checkout");
1244 if (quiet)
1245 - argv_array_push(&cp.args, "--quiet");
1245 + strvec_push(&cp.args, "--quiet");
1246 if (progress)
1247 - argv_array_push(&cp.args, "--progress");
1247 + strvec_push(&cp.args, "--progress");
1248 if (depth && *depth)
1249 - argv_array_pushl(&cp.args, "--depth", depth, NULL);
1249 + strvec_pushl(&cp.args, "--depth", depth, NULL);
1250 if (reference->nr) {
1251 struct string_list_item *item;
1252 for_each_string_list_item(item, reference)
1253 - argv_array_pushl(&cp.args, "--reference",
1253 + strvec_pushl(&cp.args, "--reference",
1254 item->string, NULL);
1255 }
1256 if (dissociate)
1257 - argv_array_push(&cp.args, "--dissociate");
1257 + strvec_push(&cp.args, "--dissociate");
1258 if (gitdir && *gitdir)
1259 - argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
1259 + strvec_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
1260 if (single_branch >= 0)
1261 - argv_array_push(&cp.args, single_branch ?
1261 + strvec_push(&cp.args, single_branch ?
1262 "--single-branch" :
1263 "--no-single-branch");
1264
1265 - argv_array_push(&cp.args, "--");
1266 - argv_array_push(&cp.args, url);
1267 - argv_array_push(&cp.args, path);
1265 + strvec_push(&cp.args, "--");
1266 + strvec_push(&cp.args, url);
1267 + strvec_push(&cp.args, path);
1268
1269 cp.git_cmd = 1;
1270 prepare_submodule_repo_env(&cp.env_array);
@@ -1717,32 +1717,32 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
1717 child->no_stdin = 1;
1718 child->stdout_to_stderr = 1;
1719 child->err = -1;
1720 - argv_array_push(&child->args, "submodule--helper");
1721 - argv_array_push(&child->args, "clone");
1720 + strvec_push(&child->args, "submodule--helper");
1721 + strvec_push(&child->args, "clone");
1722 if (suc->progress)
1723 - argv_array_push(&child->args, "--progress");
1723 + strvec_push(&child->args, "--progress");
1724 if (suc->quiet)
1725 - argv_array_push(&child->args, "--quiet");
1725 + strvec_push(&child->args, "--quiet");
1726 if (suc->prefix)
1727 - argv_array_pushl(&child->args, "--prefix", suc->prefix, NULL);
1727 + strvec_pushl(&child->args, "--prefix", suc->prefix, NULL);
1728 if (suc->recommend_shallow && sub->recommend_shallow == 1)
1729 - argv_array_push(&child->args, "--depth=1");
1729 + strvec_push(&child->args, "--depth=1");
1730 if (suc->require_init)
1731 - argv_array_push(&child->args, "--require-init");
1732 - argv_array_pushl(&child->args, "--path", sub->path, NULL);
1733 - argv_array_pushl(&child->args, "--name", sub->name, NULL);
1734 - argv_array_pushl(&child->args, "--url", url, NULL);
1731 + strvec_push(&child->args, "--require-init");
1732 + strvec_pushl(&child->args, "--path", sub->path, NULL);
1733 + strvec_pushl(&child->args, "--name", sub->name, NULL);
1734 + strvec_pushl(&child->args, "--url", url, NULL);
1735 if (suc->references.nr) {
1736 struct string_list_item *item;
1737 for_each_string_list_item(item, &suc->references)
1738 - argv_array_pushl(&child->args, "--reference", item->string, NULL);
1738 + strvec_pushl(&child->args, "--reference", item->string, NULL);
1739 }
1740 if (suc->dissociate)
1741 - argv_array_push(&child->args, "--dissociate");
1741 + strvec_push(&child->args, "--dissociate");
1742 if (suc->depth)
1743 - argv_array_push(&child->args, suc->depth);
1743 + strvec_push(&child->args, suc->depth);
1744 if (suc->single_branch >= 0)
1745 - argv_array_push(&child->args, suc->single_branch ?
1745 + strvec_push(&child->args, suc->single_branch ?
1746 "--single-branch" :
1747 "--no-single-branch");
1748
builtin/upload-archive.c
+3 -3
@@ -19,7 +19,7 @@ static const char deadchild[] =
19
20 int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
21 {
22 - struct argv_array sent_argv = ARGV_ARRAY_INIT;
22 + struct strvec sent_argv = STRVEC_INIT;
23 const char *arg_cmd = "argument ";
24
25 if (argc != 2 || !strcmp(argv[1], "-h"))
@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
31 init_archivers();
32
33 /* put received options in sent_argv[] */
34 - argv_array_push(&sent_argv, "git-upload-archive");
34 + strvec_push(&sent_argv, "git-upload-archive");
35 for (;;) {
36 char *buf = packet_read_line(0, NULL);
37 if (!buf)
@@ -41,7 +41,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
41
42 if (!starts_with(buf, arg_cmd))
43 die("'argument' token or flush expected");
44 - argv_array_push(&sent_argv, buf + strlen(arg_cmd));
44 + strvec_push(&sent_argv, buf + strlen(arg_cmd));
45 }
46
47 /* parse all options sent by the client */
builtin/worktree.c
+21 -21
@@ -316,7 +316,7 @@ static int add_worktree(const char *path, const char *refname,
316 struct strbuf sb = STRBUF_INIT, realpath = STRBUF_INIT;
317 const char *name;
318 struct child_process cp = CHILD_PROCESS_INIT;
319 - struct argv_array child_env = ARGV_ARRAY_INIT;
319 + struct strvec child_env = STRVEC_INIT;
320 unsigned int counter = 0;
321 int len, ret;
322 struct strbuf symref = STRBUF_INIT;
@@ -408,18 +408,18 @@ static int add_worktree(const char *path, const char *refname,
408 strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
409 write_file(sb.buf, "../..");
410
411 - argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
412 - argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
411 + strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
412 + strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
413 cp.git_cmd = 1;
414
415 if (!is_branch)
416 - argv_array_pushl(&cp.args, "update-ref", "HEAD",
416 + strvec_pushl(&cp.args, "update-ref", "HEAD",
417 oid_to_hex(&commit->object.oid), NULL);
418 else {
419 - argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
419 + strvec_pushl(&cp.args, "symbolic-ref", "HEAD",
420 symref.buf, NULL);
421 if (opts->quiet)
422 - argv_array_push(&cp.args, "--quiet");
422 + strvec_push(&cp.args, "--quiet");
423 }
424
425 cp.env = child_env.argv;
@@ -429,10 +429,10 @@ static int add_worktree(const char *path, const char *refname,
429
430 if (opts->checkout) {
431 cp.argv = NULL;
432 - argv_array_clear(&cp.args);
433 - argv_array_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
432 + strvec_clear(&cp.args);
433 + strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
434 if (opts->quiet)
435 - argv_array_push(&cp.args, "--quiet");
435 + strvec_push(&cp.args, "--quiet");
436 cp.env = child_env.argv;
437 ret = run_command(&cp);
438 if (ret)
@@ -465,7 +465,7 @@ done:
465 cp.env = env;
466 cp.argv = NULL;
467 cp.trace2_hook_name = "post-checkout";
468 - argv_array_pushl(&cp.args, absolute_path(hook),
468 + strvec_pushl(&cp.args, absolute_path(hook),
469 oid_to_hex(&null_oid),
470 oid_to_hex(&commit->object.oid),
471 "1", NULL);
@@ -473,7 +473,7 @@ done:
473 }
474 }
475
476 - argv_array_clear(&child_env);
476 + strvec_clear(&child_env);
477 strbuf_release(&sb);
478 strbuf_release(&symref);
479 strbuf_release(&sb_repo);
@@ -619,15 +619,15 @@ static int add(int ac, const char **av, const char *prefix)
619 if (new_branch) {
620 struct child_process cp = CHILD_PROCESS_INIT;
621 cp.git_cmd = 1;
622 - argv_array_push(&cp.args, "branch");
622 + strvec_push(&cp.args, "branch");
623 if (new_branch_force)
624 - argv_array_push(&cp.args, "--force");
624 + strvec_push(&cp.args, "--force");
625 if (opts.quiet)
626 - argv_array_push(&cp.args, "--quiet");
627 - argv_array_push(&cp.args, new_branch);
628 - argv_array_push(&cp.args, branch);
626 + strvec_push(&cp.args, "--quiet");
627 + strvec_push(&cp.args, new_branch);
628 + strvec_push(&cp.args, branch);
629 if (opt_track)
630 - argv_array_push(&cp.args, opt_track);
630 + strvec_push(&cp.args, opt_track);
631 if (run_command(&cp))
632 return -1;
633 branch = new_branch;
@@ -924,7 +924,7 @@ static int move_worktree(int ac, const char **av, const char *prefix)
924 static void check_clean_worktree(struct worktree *wt,
925 const char *original_path)
926 {
927 - struct argv_array child_env = ARGV_ARRAY_INIT;
927 + struct strvec child_env = STRVEC_INIT;
928 struct child_process cp;
929 char buf[1];
930 int ret;
@@ -935,12 +935,12 @@ static void check_clean_worktree(struct worktree *wt,
935 */
936 validate_no_submodules(wt);
937
938 - argv_array_pushf(&child_env, "%s=%s/.git",
938 + strvec_pushf(&child_env, "%s=%s/.git",
939 GIT_DIR_ENVIRONMENT, wt->path);
940 - argv_array_pushf(&child_env, "%s=%s",
940 + strvec_pushf(&child_env, "%s=%s",
941 GIT_WORK_TREE_ENVIRONMENT, wt->path);
942 memset(&cp, 0, sizeof(cp));
943 - argv_array_pushl(&cp.args, "status",
943 + strvec_pushl(&cp.args, "status",
944 "--porcelain", "--ignore-submodules=none",
945 NULL);
946 cp.env = child_env.argv;