@matheusbsbs / matheus-bagliano / commits / c972bf4cf5
Fork 0

strvec: convert remaining 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 remaining files, as the resulting diff is reasonably sized. 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; ' 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:25 UTC c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f
33 files changed +385 -385
merge.c
+8 -8
@@ -19,22 +19,22 @@ int try_merge_command(struct repository *r,
19 const char **xopts, struct commit_list *common,
20 const char *head_arg, struct commit_list *remotes)
21 {
22 - struct argv_array args = ARGV_ARRAY_INIT;
22 + struct strvec args = STRVEC_INIT;
23 int i, ret;
24 struct commit_list *j;
25
26 - argv_array_pushf(&args, "merge-%s", strategy);
26 + strvec_pushf(&args, "merge-%s", strategy);
27 for (i = 0; i < xopts_nr; i++)
28 - argv_array_pushf(&args, "--%s", xopts[i]);
28 + strvec_pushf(&args, "--%s", xopts[i]);
29 for (j = common; j; j = j->next)
30 - argv_array_push(&args, merge_argument(j->item));
31 - argv_array_push(&args, "--");
32 - argv_array_push(&args, head_arg);
30 + strvec_push(&args, merge_argument(j->item));
31 + strvec_push(&args, "--");
32 + strvec_push(&args, head_arg);
33 for (j = remotes; j; j = j->next)
34 - argv_array_push(&args, merge_argument(j->item));
34 + strvec_push(&args, merge_argument(j->item));
35
36 ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
37 - argv_array_clear(&args);
37 + strvec_clear(&args);
38
39 discard_index(r->index);
40 if (repo_read_index(r) < 0)
midx.c
+6 -6
@@ -1408,21 +1408,21 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1408 repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
1409 repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
1410
1411 - argv_array_push(&cmd.args, "pack-objects");
1411 + strvec_push(&cmd.args, "pack-objects");
1412
1413 strbuf_addstr(&base_name, object_dir);
1414 strbuf_addstr(&base_name, "/pack/pack");
1415 - argv_array_push(&cmd.args, base_name.buf);
1415 + strvec_push(&cmd.args, base_name.buf);
1416
1417 if (delta_base_offset)
1418 - argv_array_push(&cmd.args, "--delta-base-offset");
1418 + strvec_push(&cmd.args, "--delta-base-offset");
1419 if (use_delta_islands)
1420 - argv_array_push(&cmd.args, "--delta-islands");
1420 + strvec_push(&cmd.args, "--delta-islands");
1421
1422 if (flags & MIDX_PROGRESS)
1423 - argv_array_push(&cmd.args, "--progress");
1423 + strvec_push(&cmd.args, "--progress");
1424 else
1425 - argv_array_push(&cmd.args, "-q");
1425 + strvec_push(&cmd.args, "-q");
1426
1427 strbuf_release(&base_name);
1428
pager.c
+4 -4
@@ -68,7 +68,7 @@ const char *git_pager(int stdout_is_tty)
68 return pager;
69 }
70
71 -static void setup_pager_env(struct argv_array *env)
71 +static void setup_pager_env(struct strvec *env)
72 {
73 const char **argv;
74 int i;
@@ -88,7 +88,7 @@ static void setup_pager_env(struct argv_array *env)
88 *cp = '\0';
89 if (!getenv(argv[i])) {
90 *cp = '=';
91 - argv_array_push(env, argv[i]);
91 + strvec_push(env, argv[i]);
92 }
93 }
94 free(pager_env);
@@ -97,7 +97,7 @@ static void setup_pager_env(struct argv_array *env)
97
98 void prepare_pager_args(struct child_process *pager_process, const char *pager)
99 {
100 - argv_array_push(&pager_process->args, pager);
100 + strvec_push(&pager_process->args, pager);
101 pager_process->use_shell = 1;
102 setup_pager_env(&pager_process->env_array);
103 pager_process->trace2_child_class = "pager";
@@ -126,7 +126,7 @@ void setup_pager(void)
126 /* spawn the pager */
127 prepare_pager_args(&pager_process, pager);
128 pager_process.in = -1;
129 - argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
129 + strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
130 if (start_command(&pager_process))
131 return;
132
parse-options-cb.c
+3 -3
@@ -275,19 +275,19 @@ int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
275
276 /**
277 * For an option opt, recreate the command-line option, appending it to
278 - * opt->value which must be a argv_array. This is useful when we need to pass
278 + * opt->value which must be a strvec. This is useful when we need to pass
279 * the command-line option, which can be specified multiple times, to another
280 * command.
281 */
282 int parse_opt_passthru_argv(const struct option *opt, const char *arg, int unset)
283 {
284 static struct strbuf sb = STRBUF_INIT;
285 - struct argv_array *opt_value = opt->value;
285 + struct strvec *opt_value = opt->value;
286
287 if (recreate_opt(&sb, opt, arg, unset) < 0)
288 return -1;
289
290 - argv_array_push(opt_value, sb.buf);
290 + strvec_push(opt_value, sb.buf);
291
292 return 0;
293 }
pathspec.c
+3 -3
@@ -624,7 +624,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
624 unsigned flags, const char *prefix,
625 const char *file, int nul_term_line)
626 {
627 - struct argv_array parsed_file = ARGV_ARRAY_INIT;
627 + struct strvec parsed_file = STRVEC_INIT;
628 strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul :
629 strbuf_getline;
630 struct strbuf buf = STRBUF_INIT;
@@ -643,7 +643,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
643 die(_("line is badly quoted: %s"), buf.buf);
644 strbuf_swap(&buf, &unquoted);
645 }
646 - argv_array_push(&parsed_file, buf.buf);
646 + strvec_push(&parsed_file, buf.buf);
647 strbuf_reset(&buf);
648 }
649
@@ -653,7 +653,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
653 fclose(in);
654
655 parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
656 - argv_array_clear(&parsed_file);
656 + strvec_clear(&parsed_file);
657 }
658
659 void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
quote.c
+2 -2
@@ -172,7 +172,7 @@ char *sq_dequote(char *arg)
172
173 static int sq_dequote_to_argv_internal(char *arg,
174 const char ***argv, int *nr, int *alloc,
175 - struct argv_array *array)
175 + struct strvec *array)
176 {
177 char *next = arg;
178
@@ -187,7 +187,7 @@ static int sq_dequote_to_argv_internal(char *arg,
187 (*argv)[(*nr)++] = dequoted;
188 }
189 if (array)
190 - argv_array_push(array, dequoted);
190 + strvec_push(array, dequoted);
191 } while (next);
192
193 return 0;
range-diff.c
+5 -5
@@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
41 * as struct object_id (will need to be free()d).
42 */
43 static int read_patches(const char *range, struct string_list *list,
44 - const struct argv_array *other_arg)
44 + const struct strvec *other_arg)
45 {
46 struct child_process cp = CHILD_PROCESS_INIT;
47 struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -51,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
51 int offset, len;
52 size_t size;
53
54 - argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
54 + strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
55 "--reverse", "--date-order", "--decorate=no",
56 "--no-prefix",
57 /*
@@ -67,8 +67,8 @@ static int read_patches(const char *range, struct string_list *list,
67 "--notes",
68 NULL);
69 if (other_arg)
70 - argv_array_pushv(&cp.args, other_arg->argv);
71 - argv_array_push(&cp.args, range);
70 + strvec_pushv(&cp.args, other_arg->argv);
71 + strvec_push(&cp.args, range);
72 cp.out = -1;
73 cp.no_stdin = 1;
74 cp.git_cmd = 1;
@@ -523,7 +523,7 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
523 int show_range_diff(const char *range1, const char *range2,
524 int creation_factor, int dual_color,
525 const struct diff_options *diffopt,
526 - const struct argv_array *other_arg)
526 + const struct strvec *other_arg)
527 {
528 int res = 0;
529
range-diff.h
+1 -1
@@ -14,6 +14,6 @@
14 int show_range_diff(const char *range1, const char *range2,
15 int creation_factor, int dual_color,
16 const struct diff_options *diffopt,
17 - const struct argv_array *other_arg);
17 + const struct strvec *other_arg);
18
19 #endif
ref-filter.c
+3 -3
@@ -1914,15 +1914,15 @@ static void find_longest_prefixes_1(struct string_list *out,
1914 static void find_longest_prefixes(struct string_list *out,
1915 const char **patterns)
1916 {
1917 - struct argv_array sorted = ARGV_ARRAY_INIT;
1917 + struct strvec sorted = STRVEC_INIT;
1918 struct strbuf prefix = STRBUF_INIT;
1919
1920 - argv_array_pushv(&sorted, patterns);
1920 + strvec_pushv(&sorted, patterns);
1921 QSORT(sorted.argv, sorted.argc, qsort_strcmp);
1922
1923 find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
1924
1925 - argv_array_clear(&sorted);
1925 + strvec_clear(&sorted);
1926 strbuf_release(&prefix);
1927 }
1928
refs.c
+3 -3
@@ -553,13 +553,13 @@ int refname_match(const char *abbrev_name, const char *full_name)
553 * Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
554 * the results to 'prefixes'
555 */
556 -void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
556 +void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
557 {
558 const char **p;
559 int len = strlen(prefix);
560
561 for (p = ref_rev_parse_rules; *p; p++)
562 - argv_array_pushf(prefixes, *p, len, prefix);
562 + strvec_pushf(prefixes, *p, len, prefix);
563 }
564
565 char *repo_default_branch_name(struct repository *r)
@@ -2037,7 +2037,7 @@ static int run_transaction_hook(struct ref_transaction *transaction,
2037 return ret;
2038 }
2039
2040 - argv_array_pushl(&proc.args, hook, state, NULL);
2040 + strvec_pushl(&proc.args, hook, state, NULL);
2041 proc.in = -1;
2042 proc.stdout_to_stderr = 1;
2043 proc.trace2_hook_name = "reference-transaction";
refspec.c
+2 -2
@@ -202,7 +202,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
202 }
203
204 void refspec_ref_prefixes(const struct refspec *rs,
205 - struct argv_array *ref_prefixes)
205 + struct strvec *ref_prefixes)
206 {
207 int i;
208 for (i = 0; i < rs->nr; i++) {
@@ -221,7 +221,7 @@ void refspec_ref_prefixes(const struct refspec *rs,
221 if (prefix) {
222 if (item->pattern) {
223 const char *glob = strchr(prefix, '*');
224 - argv_array_pushf(ref_prefixes, "%.*s",
224 + strvec_pushf(ref_prefixes, "%.*s",
225 (int)(glob - prefix),
226 prefix);
227 } else {
remote-curl.c
+43 -43
@@ -1141,41 +1141,41 @@ static int fetch_git(struct discovery *heads,
1141 struct rpc_state rpc;
1142 struct strbuf preamble = STRBUF_INIT;
1143 int i, err;
1144 - struct argv_array args = ARGV_ARRAY_INIT;
1144 + struct strvec args = STRVEC_INIT;
1145 struct strbuf rpc_result = STRBUF_INIT;
1146
1147 - argv_array_pushl(&args, "fetch-pack", "--stateless-rpc",
1147 + strvec_pushl(&args, "fetch-pack", "--stateless-rpc",
1148 "--stdin", "--lock-pack", NULL);
1149 if (options.followtags)
1150 - argv_array_push(&args, "--include-tag");
1150 + strvec_push(&args, "--include-tag");
1151 if (options.thin)
1152 - argv_array_push(&args, "--thin");
1152 + strvec_push(&args, "--thin");
1153 if (options.verbosity >= 3)
1154 - argv_array_pushl(&args, "-v", "-v", NULL);
1154 + strvec_pushl(&args, "-v", "-v", NULL);
1155 if (options.check_self_contained_and_connected)
1156 - argv_array_push(&args, "--check-self-contained-and-connected");
1156 + strvec_push(&args, "--check-self-contained-and-connected");
1157 if (options.cloning)
1158 - argv_array_push(&args, "--cloning");
1158 + strvec_push(&args, "--cloning");
1159 if (options.update_shallow)
1160 - argv_array_push(&args, "--update-shallow");
1160 + strvec_push(&args, "--update-shallow");
1161 if (!options.progress)
1162 - argv_array_push(&args, "--no-progress");
1162 + strvec_push(&args, "--no-progress");
1163 if (options.depth)
1164 - argv_array_pushf(&args, "--depth=%lu", options.depth);
1164 + strvec_pushf(&args, "--depth=%lu", options.depth);
1165 if (options.deepen_since)
1166 - argv_array_pushf(&args, "--shallow-since=%s", options.deepen_since);
1166 + strvec_pushf(&args, "--shallow-since=%s", options.deepen_since);
1167 for (i = 0; i < options.deepen_not.nr; i++)
1168 - argv_array_pushf(&args, "--shallow-exclude=%s",
1168 + strvec_pushf(&args, "--shallow-exclude=%s",
1169 options.deepen_not.items[i].string);
1170 if (options.deepen_relative && options.depth)
1171 - argv_array_push(&args, "--deepen-relative");
1171 + strvec_push(&args, "--deepen-relative");
1172 if (options.from_promisor)
1173 - argv_array_push(&args, "--from-promisor");
1173 + strvec_push(&args, "--from-promisor");
1174 if (options.no_dependents)
1175 - argv_array_push(&args, "--no-dependents");
1175 + strvec_push(&args, "--no-dependents");
1176 if (options.filter)
1177 - argv_array_pushf(&args, "--filter=%s", options.filter);
1178 - argv_array_push(&args, url.buf);
1177 + strvec_pushf(&args, "--filter=%s", options.filter);
1178 + strvec_push(&args, url.buf);
1179
1180 for (i = 0; i < nr_heads; i++) {
1181 struct ref *ref = to_fetch[i];
@@ -1195,7 +1195,7 @@ static int fetch_git(struct discovery *heads,
1195 write_or_die(1, rpc_result.buf, rpc_result.len);
1196 strbuf_release(&rpc_result);
1197 strbuf_release(&preamble);
1198 - argv_array_clear(&args);
1198 + strvec_clear(&args);
1199 return err;
1200 }
1201
@@ -1267,15 +1267,15 @@ static int push_dav(int nr_spec, const char **specs)
1267 size_t i;
1268
1269 child.git_cmd = 1;
1270 - argv_array_push(&child.args, "http-push");
1271 - argv_array_push(&child.args, "--helper-status");
1270 + strvec_push(&child.args, "http-push");
1271 + strvec_push(&child.args, "--helper-status");
1272 if (options.dry_run)
1273 - argv_array_push(&child.args, "--dry-run");
1273 + strvec_push(&child.args, "--dry-run");
1274 if (options.verbosity > 1)
1275 - argv_array_push(&child.args, "--verbose");
1276 - argv_array_push(&child.args, url.buf);
1275 + strvec_push(&child.args, "--verbose");
1276 + strvec_push(&child.args, url.buf);
1277 for (i = 0; i < nr_spec; i++)
1278 - argv_array_push(&child.args, specs[i]);
1278 + strvec_push(&child.args, specs[i]);
1279
1280 if (run_command(&child))
1281 die(_("git-http-push failed"));
@@ -1286,38 +1286,38 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1286 {
1287 struct rpc_state rpc;
1288 int i, err;
1289 - struct argv_array args;
1289 + struct strvec args;
1290 struct string_list_item *cas_option;
1291 struct strbuf preamble = STRBUF_INIT;
1292 struct strbuf rpc_result = STRBUF_INIT;
1293
1294 - argv_array_init(&args);
1295 - argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
1294 + strvec_init(&args);
1295 + strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
1296 NULL);
1297
1298 if (options.thin)
1299 - argv_array_push(&args, "--thin");
1299 + strvec_push(&args, "--thin");
1300 if (options.dry_run)
1301 - argv_array_push(&args, "--dry-run");
1301 + strvec_push(&args, "--dry-run");
1302 if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS)
1303 - argv_array_push(&args, "--signed=yes");
1303 + strvec_push(&args, "--signed=yes");
1304 else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED)
1305 - argv_array_push(&args, "--signed=if-asked");
1305 + strvec_push(&args, "--signed=if-asked");
1306 if (options.atomic)
1307 - argv_array_push(&args, "--atomic");
1307 + strvec_push(&args, "--atomic");
1308 if (options.verbosity == 0)
1309 - argv_array_push(&args, "--quiet");
1309 + strvec_push(&args, "--quiet");
1310 else if (options.verbosity > 1)
1311 - argv_array_push(&args, "--verbose");
1311 + strvec_push(&args, "--verbose");
1312 for (i = 0; i < options.push_options.nr; i++)
1313 - argv_array_pushf(&args, "--push-option=%s",
1313 + strvec_pushf(&args, "--push-option=%s",
1314 options.push_options.items[i].string);
1315 - argv_array_push(&args, options.progress ? "--progress" : "--no-progress");
1315 + strvec_push(&args, options.progress ? "--progress" : "--no-progress");
1316 for_each_string_list_item(cas_option, &cas_options)
1317 - argv_array_push(&args, cas_option->string);
1318 - argv_array_push(&args, url.buf);
1317 + strvec_push(&args, cas_option->string);
1318 + strvec_push(&args, url.buf);
1319
1320 - argv_array_push(&args, "--stdin");
1320 + strvec_push(&args, "--stdin");
1321 for (i = 0; i < nr_spec; i++)
1322 packet_buf_write(&preamble, "%s\n", specs[i]);
1323 packet_buf_flush(&preamble);
@@ -1330,7 +1330,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1330 write_or_die(1, rpc_result.buf, rpc_result.len);
1331 strbuf_release(&rpc_result);
1332 strbuf_release(&preamble);
1333 - argv_array_clear(&args);
1333 + strvec_clear(&args);
1334 return err;
1335 }
1336
@@ -1349,13 +1349,13 @@ static int push(int nr_spec, const char **specs)
1349
1350 static void parse_push(struct strbuf *buf)
1351 {
1352 - struct argv_array specs = ARGV_ARRAY_INIT;
1352 + struct strvec specs = STRVEC_INIT;
1353 int ret;
1354
1355 do {
1356 const char *arg;
1357 if (skip_prefix(buf->buf, "push ", &arg))
1358 - argv_array_push(&specs, arg);
1358 + strvec_push(&specs, arg);
1359 else
1360 die(_("http transport does not support %s"), buf->buf);
1361
@@ -1374,7 +1374,7 @@ static void parse_push(struct strbuf *buf)
1374 exit(128); /* error already reported */
1375
1376 free_specs:
1377 - argv_array_clear(&specs);
1377 + strvec_clear(&specs);
1378 }
1379
1380 static int stateless_connect(const char *service_name)
remote-testsvn.c
+4 -4
@@ -198,10 +198,10 @@ static int cmd_import(const char *line)
198 die_errno("Couldn't open svn dump file %s.", url);
199 } else {
200 svndump_proc.out = -1;
201 - argv_array_push(&svndump_proc.args, command);
202 - argv_array_push(&svndump_proc.args, "dump");
203 - argv_array_push(&svndump_proc.args, url);
204 - argv_array_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
201 + strvec_push(&svndump_proc.args, command);
202 + strvec_push(&svndump_proc.args, "dump");
203 + strvec_push(&svndump_proc.args, url);
204 + strvec_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
205
206 code = start_command(&svndump_proc);
207 if (code)
remote.c
+6 -6
@@ -1885,7 +1885,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
1885 struct object_id oid;
1886 struct commit *ours, *theirs;
1887 struct rev_info revs;
1888 - struct argv_array argv = ARGV_ARRAY_INIT;
1888 + struct strvec argv = STRVEC_INIT;
1889
1890 /* Cannot stat if what we used to build on no longer exists */
1891 if (read_ref(base, &oid))
@@ -1911,12 +1911,12 @@ static int stat_branch_pair(const char *branch_name, const char *base,
1911 BUG("stat_branch_pair: invalid abf '%d'", abf);
1912
1913 /* Run "rev-list --left-right ours...theirs" internally... */
1914 - argv_array_push(&argv, ""); /* ignored */
1915 - argv_array_push(&argv, "--left-right");
1916 - argv_array_pushf(&argv, "%s...%s",
1914 + strvec_push(&argv, ""); /* ignored */
1915 + strvec_push(&argv, "--left-right");
1916 + strvec_pushf(&argv, "%s...%s",
1917 oid_to_hex(&ours->object.oid),
1918 oid_to_hex(&theirs->object.oid));
1919 - argv_array_push(&argv, "--");
1919 + strvec_push(&argv, "--");
1920
1921 repo_init_revisions(the_repository, &revs, NULL);
1922 setup_revisions(argv.argc, argv.argv, &revs, NULL);
@@ -1938,7 +1938,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
1938 clear_commit_marks(ours, ALL_REV_FLAGS);
1939 clear_commit_marks(theirs, ALL_REV_FLAGS);
1940
1941 - argv_array_clear(&argv);
1941 + strvec_clear(&argv);
1942 return 1;
1943 }
1944
revision.c
+7 -7
@@ -2073,14 +2073,14 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
2073 }
2074
2075 static void read_pathspec_from_stdin(struct strbuf *sb,
2076 - struct argv_array *prune)
2076 + struct strvec *prune)
2077 {
2078 while (strbuf_getline(sb, stdin) != EOF)
2079 - argv_array_push(prune, sb->buf);
2079 + strvec_push(prune, sb->buf);
2080 }
2081
2082 static void read_revisions_from_stdin(struct rev_info *revs,
2083 - struct argv_array *prune)
2083 + struct strvec *prune)
2084 {
2085 struct strbuf sb;
2086 int seen_dashdash = 0;
@@ -2675,7 +2675,7 @@ static void NORETURN diagnose_missing_default(const char *def)
2675 int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
2676 {
2677 int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
2678 - struct argv_array prune_data = ARGV_ARRAY_INIT;
2678 + struct strvec prune_data = STRVEC_INIT;
2679 const char *submodule = NULL;
2680 int seen_end_of_options = 0;
2681
@@ -2694,7 +2694,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2694 argv[i] = NULL;
2695 argc = i;
2696 if (argv[i + 1])
2697 - argv_array_pushv(&prune_data, argv + i + 1);
2697 + strvec_pushv(&prune_data, argv + i + 1);
2698 seen_dashdash = 1;
2699 break;
2700 }
@@ -2760,7 +2760,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2760 for (j = i; j < argc; j++)
2761 verify_filename(revs->prefix, argv[j], j == i);
2762
2763 - argv_array_pushv(&prune_data, argv + i);
2763 + strvec_pushv(&prune_data, argv + i);
2764 break;
2765 }
2766 else
@@ -2785,7 +2785,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2785 parse_pathspec(&revs->prune_data, 0, 0,
2786 revs->prefix, prune_data.argv);
2787 }
2788 - argv_array_clear(&prune_data);
2788 + strvec_clear(&prune_data);
2789
2790 if (revs->def == NULL)
2791 revs->def = opt ? opt->def : NULL;
run-command.c
+25 -25
@@ -11,14 +11,14 @@
11 void child_process_init(struct child_process *child)
12 {
13 memset(child, 0, sizeof(*child));
14 - argv_array_init(&child->args);
15 - argv_array_init(&child->env_array);
14 + strvec_init(&child->args);
15 + strvec_init(&child->env_array);
16 }
17
18 void child_process_clear(struct child_process *child)
19 {
20 - argv_array_clear(&child->args);
21 - argv_array_clear(&child->env_array);
20 + strvec_clear(&child->args);
21 + strvec_clear(&child->env_array);
22 }
23
24 struct child_to_clean {
@@ -263,30 +263,30 @@ int sane_execvp(const char *file, char * const argv[])
263 return -1;
264 }
265
266 -static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
266 +static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
267 {
268 if (!argv[0])
269 BUG("shell command is empty");
270
271 if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
272 #ifndef GIT_WINDOWS_NATIVE
273 - argv_array_push(out, SHELL_PATH);
273 + strvec_push(out, SHELL_PATH);
274 #else
275 - argv_array_push(out, "sh");
275 + strvec_push(out, "sh");
276 #endif
277 - argv_array_push(out, "-c");
277 + strvec_push(out, "-c");
278
279 /*
280 * If we have no extra arguments, we do not even need to
281 * bother with the "$@" magic.
282 */
283 if (!argv[1])
284 - argv_array_push(out, argv[0]);
284 + strvec_push(out, argv[0]);
285 else
286 - argv_array_pushf(out, "%s \"$@\"", argv[0]);
286 + strvec_pushf(out, "%s \"$@\"", argv[0]);
287 }
288
289 - argv_array_pushv(out, argv);
289 + strvec_pushv(out, argv);
290 return out->argv;
291 }
292
@@ -401,7 +401,7 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
401 set_error_routine(old_errfn);
402 }
403
404 -static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
404 +static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
405 {
406 if (!cmd->argv[0])
407 BUG("command is empty");
@@ -410,14 +410,14 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
410 * Add SHELL_PATH so in the event exec fails with ENOEXEC we can
411 * attempt to interpret the command with 'sh'.
412 */
413 - argv_array_push(out, SHELL_PATH);
413 + strvec_push(out, SHELL_PATH);
414
415 if (cmd->git_cmd) {
416 prepare_git_cmd(out, cmd->argv);
417 } else if (cmd->use_shell) {
418 prepare_shell_cmd(out, cmd->argv);
419 } else {
420 - argv_array_pushv(out, cmd->argv);
420 + strvec_pushv(out, cmd->argv);
421 }
422
423 /*
@@ -432,7 +432,7 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
432 free((char *)out->argv[1]);
433 out->argv[1] = program;
434 } else {
435 - argv_array_clear(out);
435 + strvec_clear(out);
436 errno = ENOENT;
437 return -1;
438 }
@@ -742,7 +742,7 @@ fail_pipe:
742 int notify_pipe[2];
743 int null_fd = -1;
744 char **childenv;
745 - struct argv_array argv = ARGV_ARRAY_INIT;
745 + struct strvec argv = STRVEC_INIT;
746 struct child_err cerr;
747 struct atfork_state as;
748
@@ -888,7 +888,7 @@ fail_pipe:
888
889 if (null_fd >= 0)
890 close(null_fd);
891 - argv_array_clear(&argv);
891 + strvec_clear(&argv);
892 free(childenv);
893 }
894 end_of_spawn:
@@ -897,7 +897,7 @@ end_of_spawn:
897 {
898 int fhin = 0, fhout = 1, fherr = 2;
899 const char **sargv = cmd->argv;
900 - struct argv_array nargv = ARGV_ARRAY_INIT;
900 + struct strvec nargv = STRVEC_INIT;
901
902 if (cmd->no_stdin)
903 fhin = open("/dev/null", O_RDWR);
@@ -935,7 +935,7 @@ end_of_spawn:
935 if (cmd->clean_on_exit && cmd->pid >= 0)
936 mark_child_for_cleanup(cmd->pid, cmd);
937
938 - argv_array_clear(&nargv);
938 + strvec_clear(&nargv);
939 cmd->argv = sargv;
940 if (fhin != 0)
941 close(fhin);
@@ -1352,9 +1352,9 @@ int run_hook_ve(const char *const *env, const char *name, va_list args)
1352 if (!p)
1353 return 0;
1354
1355 - argv_array_push(&hook.args, p);
1355 + strvec_push(&hook.args, p);
1356 while ((p = va_arg(args, const char *)))
1357 - argv_array_push(&hook.args, p);
1357 + strvec_push(&hook.args, p);
1358 hook.env = env;
1359 hook.no_stdin = 1;
1360 hook.stdout_to_stderr = 1;
@@ -1868,13 +1868,13 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
1868
1869 int run_auto_gc(int quiet)
1870 {
1871 - struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
1871 + struct strvec argv_gc_auto = STRVEC_INIT;
1872 int status;
1873
1874 - argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
1874 + strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
1875 if (quiet)
1876 - argv_array_push(&argv_gc_auto, "--quiet");
1876 + strvec_push(&argv_gc_auto, "--quiet");
1877 status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
1878 - argv_array_clear(&argv_gc_auto);
1878 + strvec_clear(&argv_gc_auto);
1879 return status;
1880 }
run-command.h
+5 -5
@@ -52,15 +52,15 @@ struct child_process {
52 * Note that the ownership of the memory pointed to by .argv stays with the
53 * caller, but it should survive until `finish_command` completes. If the
54 * .argv member is NULL, `start_command` will point it at the .args
55 - * `argv_array` (so you may use one or the other, but you must use exactly
55 + * `strvec` (so you may use one or the other, but you must use exactly
56 * one). The memory in .args will be cleaned up automatically during
57 * `finish_command` (or during `start_command` when it is unsuccessful).
58 *
59 */
60 const char **argv;
61
62 - struct argv_array args;
63 - struct argv_array env_array;
62 + struct strvec args;
63 + struct strvec env_array;
64 pid_t pid;
65
66 int trace2_child_id;
@@ -107,7 +107,7 @@ struct child_process {
107 * variable that will be removed from the child process's environment.
108 *
109 * If the .env member is NULL, `start_command` will point it at the
110 - * .env_array `argv_array` (so you may use one or the other, but not both).
110 + * .env_array `strvec` (so you may use one or the other, but not both).
111 * The memory in .env_array will be cleaned up automatically during
112 * `finish_command` (or during `start_command` when it is unsuccessful).
113 */
@@ -134,7 +134,7 @@ struct child_process {
134 void *clean_on_exit_handler_cbdata;
135 };
136
137 -#define CHILD_PROCESS_INIT { NULL, ARGV_ARRAY_INIT, ARGV_ARRAY_INIT }
137 +#define CHILD_PROCESS_INIT { NULL, STRVEC_INIT, STRVEC_INIT }
138
139 /**
140 * The functions: child_process_init, start_command, finish_command,
send-pack.c
+9 -9
@@ -68,20 +68,20 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
68 int i;
69 int rc;
70
71 - argv_array_push(&po.args, "pack-objects");
72 - argv_array_push(&po.args, "--all-progress-implied");
73 - argv_array_push(&po.args, "--revs");
74 - argv_array_push(&po.args, "--stdout");
71 + strvec_push(&po.args, "pack-objects");
72 + strvec_push(&po.args, "--all-progress-implied");
73 + strvec_push(&po.args, "--revs");
74 + strvec_push(&po.args, "--stdout");
75 if (args->use_thin_pack)
76 - argv_array_push(&po.args, "--thin");
76 + strvec_push(&po.args, "--thin");
77 if (args->use_ofs_delta)
78 - argv_array_push(&po.args, "--delta-base-offset");
78 + strvec_push(&po.args, "--delta-base-offset");
79 if (args->quiet || !args->progress)
80 - argv_array_push(&po.args, "-q");
80 + strvec_push(&po.args, "-q");
81 if (args->progress)
82 - argv_array_push(&po.args, "--progress");
82 + strvec_push(&po.args, "--progress");
83 if (is_repository_shallow(the_repository))
84 - argv_array_push(&po.args, "--shallow");
84 + strvec_push(&po.args, "--shallow");
85 po.in = -1;
86 po.out = args->stateless_rpc ? -1 : fd;
87 po.git_cmd = 1;
sequencer.c
+56 -56
@@ -830,10 +830,10 @@ finish:
830
831 /*
832 * Read a GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL AND GIT_AUTHOR_DATE from a
833 - * file with shell quoting into struct argv_array. Returns -1 on
833 + * file with shell quoting into struct strvec. Returns -1 on
834 * error, 0 otherwise.
835 */
836 -static int read_env_script(struct argv_array *env)
836 +static int read_env_script(struct strvec *env)
837 {
838 char *name, *email, *date;
839
@@ -841,9 +841,9 @@ static int read_env_script(struct argv_array *env)
841 &name, &email, &date, 0))
842 return -1;
843
844 - argv_array_pushf(env, "GIT_AUTHOR_NAME=%s", name);
845 - argv_array_pushf(env, "GIT_AUTHOR_EMAIL=%s", email);
846 - argv_array_pushf(env, "GIT_AUTHOR_DATE=%s", date);
844 + strvec_pushf(env, "GIT_AUTHOR_NAME=%s", name);
845 + strvec_pushf(env, "GIT_AUTHOR_EMAIL=%s", email);
846 + strvec_pushf(env, "GIT_AUTHOR_DATE=%s", date);
847 free(name);
848 free(email);
849 free(date);
@@ -929,34 +929,34 @@ static int run_git_commit(struct repository *r,
929 gpg_opt, gpg_opt);
930 }
931
932 - argv_array_push(&cmd.args, "commit");
932 + strvec_push(&cmd.args, "commit");
933
934 if (!(flags & VERIFY_MSG))
935 - argv_array_push(&cmd.args, "-n");
935 + strvec_push(&cmd.args, "-n");
936 if ((flags & AMEND_MSG))
937 - argv_array_push(&cmd.args, "--amend");
937 + strvec_push(&cmd.args, "--amend");
938 if (opts->gpg_sign)
939 - argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
939 + strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
940 else
941 - argv_array_push(&cmd.args, "--no-gpg-sign");
941 + strvec_push(&cmd.args, "--no-gpg-sign");
942 if (defmsg)
943 - argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
943 + strvec_pushl(&cmd.args, "-F", defmsg, NULL);
944 else if (!(flags & EDIT_MSG))
945 - argv_array_pushl(&cmd.args, "-C", "HEAD", NULL);
945 + strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
946 if ((flags & CLEANUP_MSG))
947 - argv_array_push(&cmd.args, "--cleanup=strip");
947 + strvec_push(&cmd.args, "--cleanup=strip");
948 if ((flags & EDIT_MSG))
949 - argv_array_push(&cmd.args, "-e");
949 + strvec_push(&cmd.args, "-e");
950 else if (!(flags & CLEANUP_MSG) &&
951 !opts->signoff && !opts->record_origin &&
952 !opts->explicit_cleanup)
953 - argv_array_push(&cmd.args, "--cleanup=verbatim");
953 + strvec_push(&cmd.args, "--cleanup=verbatim");
954
955 if ((flags & ALLOW_EMPTY))
956 - argv_array_push(&cmd.args, "--allow-empty");
956 + strvec_push(&cmd.args, "--allow-empty");
957
958 if (!(flags & EDIT_MSG))
959 - argv_array_push(&cmd.args, "--allow-empty-message");
959 + strvec_push(&cmd.args, "--allow-empty-message");
960
961 if (is_rebase_i(opts) && !(flags & EDIT_MSG))
962 return run_command_silent_on_success(&cmd);
@@ -2754,15 +2754,15 @@ static int rollback_is_safe(void)
2754 static int reset_merge(const struct object_id *oid)
2755 {
2756 int ret;
2757 - struct argv_array argv = ARGV_ARRAY_INIT;
2757 + struct strvec argv = STRVEC_INIT;
2758
2759 - argv_array_pushl(&argv, "reset", "--merge", NULL);
2759 + strvec_pushl(&argv, "reset", "--merge", NULL);
2760
2761 if (!is_null_oid(oid))
2762 - argv_array_push(&argv, oid_to_hex(oid));
2762 + strvec_push(&argv, oid_to_hex(oid));
2763
2764 ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
2765 - argv_array_clear(&argv);
2765 + strvec_clear(&argv);
2766
2767 return ret;
2768 }
@@ -3125,14 +3125,14 @@ static int error_failed_squash(struct repository *r,
3125
3126 static int do_exec(struct repository *r, const char *command_line)
3127 {
3128 - struct argv_array child_env = ARGV_ARRAY_INIT;
3128 + struct strvec child_env = STRVEC_INIT;
3129 const char *child_argv[] = { NULL, NULL };
3130 int dirty, status;
3131
3132 fprintf(stderr, _("Executing: %s\n"), command_line);
3133 child_argv[0] = command_line;
3134 - argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
3135 - argv_array_pushf(&child_env, "GIT_WORK_TREE=%s",
3134 + strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
3135 + strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
3136 absolute_path(get_git_work_tree()));
3137 status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
3138 child_env.argv);
@@ -3165,7 +3165,7 @@ static int do_exec(struct repository *r, const char *command_line)
3165 status = 1;
3166 }
3167
3168 - argv_array_clear(&child_env);
3168 + strvec_clear(&child_env);
3169
3170 return status;
3171 }
@@ -3544,28 +3544,28 @@ static int do_merge(struct repository *r,
3544 }
3545
3546 cmd.git_cmd = 1;
3547 - argv_array_push(&cmd.args, "merge");
3548 - argv_array_push(&cmd.args, "-s");
3547 + strvec_push(&cmd.args, "merge");
3548 + strvec_push(&cmd.args, "-s");
3549 if (!strategy)
3550 - argv_array_push(&cmd.args, "octopus");
3550 + strvec_push(&cmd.args, "octopus");
3551 else {
3552 - argv_array_push(&cmd.args, strategy);
3552 + strvec_push(&cmd.args, strategy);
3553 for (k = 0; k < opts->xopts_nr; k++)
3554 - argv_array_pushf(&cmd.args,
3554 + strvec_pushf(&cmd.args,
3555 "-X%s", opts->xopts[k]);
3556 }
3557 - argv_array_push(&cmd.args, "--no-edit");
3558 - argv_array_push(&cmd.args, "--no-ff");
3559 - argv_array_push(&cmd.args, "--no-log");
3560 - argv_array_push(&cmd.args, "--no-stat");
3561 - argv_array_push(&cmd.args, "-F");
3562 - argv_array_push(&cmd.args, git_path_merge_msg(r));
3557 + strvec_push(&cmd.args, "--no-edit");
3558 + strvec_push(&cmd.args, "--no-ff");
3559 + strvec_push(&cmd.args, "--no-log");
3560 + strvec_push(&cmd.args, "--no-stat");
3561 + strvec_push(&cmd.args, "-F");
3562 + strvec_push(&cmd.args, git_path_merge_msg(r));
3563 if (opts->gpg_sign)
3564 - argv_array_push(&cmd.args, opts->gpg_sign);
3564 + strvec_push(&cmd.args, opts->gpg_sign);
3565
3566 /* Add the tips to be merged */
3567 for (j = to_merge; j; j = j->next)
3568 - argv_array_push(&cmd.args,
3568 + strvec_push(&cmd.args,
3569 oid_to_hex(&j->item->object.oid));
3570
3571 strbuf_release(&ref_name);
@@ -3694,7 +3694,7 @@ void create_autostash(struct repository *r, const char *path,
3694 struct child_process stash = CHILD_PROCESS_INIT;
3695 struct object_id oid;
3696
3697 - argv_array_pushl(&stash.args,
3697 + strvec_pushl(&stash.args,
3698 "stash", "create", "autostash", NULL);
3699 stash.git_cmd = 1;
3700 stash.no_stdin = 1;
@@ -3734,9 +3734,9 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
3734 child.git_cmd = 1;
3735 child.no_stdout = 1;
3736 child.no_stderr = 1;
3737 - argv_array_push(&child.args, "stash");
3738 - argv_array_push(&child.args, "apply");
3739 - argv_array_push(&child.args, stash_oid);
3737 + strvec_push(&child.args, "stash");
3738 + strvec_push(&child.args, "apply");
3739 + strvec_push(&child.args, stash_oid);
3740 ret = run_command(&child);
3741 }
3742
@@ -3746,12 +3746,12 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
3746 struct child_process store = CHILD_PROCESS_INIT;
3747
3748 store.git_cmd = 1;
3749 - argv_array_push(&store.args, "stash");
3750 - argv_array_push(&store.args, "store");
3751 - argv_array_push(&store.args, "-m");
3752 - argv_array_push(&store.args, "autostash");
3753 - argv_array_push(&store.args, "-q");
3754 - argv_array_push(&store.args, stash_oid);
3749 + strvec_push(&store.args, "stash");
3750 + strvec_push(&store.args, "store");
3751 + strvec_push(&store.args, "-m");
3752 + strvec_push(&store.args, "autostash");
3753 + strvec_push(&store.args, "-q");
3754 + strvec_push(&store.args, stash_oid);
3755 if (run_command(&store))
3756 ret = error(_("cannot store %s"), stash_oid);
3757 else
@@ -3831,9 +3831,9 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
3831
3832 cmd.git_cmd = 1;
3833
3834 - argv_array_push(&cmd.args, "checkout");
3835 - argv_array_push(&cmd.args, commit);
3836 - argv_array_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
3834 + strvec_push(&cmd.args, "checkout");
3835 + strvec_push(&cmd.args, commit);
3836 + strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
3837
3838 if (opts->verbose)
3839 ret = run_command(&cmd);
@@ -4157,9 +4157,9 @@ cleanup_head_ref:
4157
4158 child.in = open(rebase_path_rewritten_list(), O_RDONLY);
4159 child.git_cmd = 1;
4160 - argv_array_push(&child.args, "notes");
4161 - argv_array_push(&child.args, "copy");
4162 - argv_array_push(&child.args, "--for-rewrite=rebase");
4160 + strvec_push(&child.args, "notes");
4161 + strvec_push(&child.args, "copy");
4162 + strvec_push(&child.args, "--for-rewrite=rebase");
4163 /* we don't care if this copying failed */
4164 run_command(&child);
4165
@@ -4170,8 +4170,8 @@ cleanup_head_ref:
4170 O_RDONLY);
4171 hook.stdout_to_stderr = 1;
4172 hook.trace2_hook_name = "post-rewrite";
4173 - argv_array_push(&hook.args, post_rewrite_hook);
4174 - argv_array_push(&hook.args, "rebase");
4173 + strvec_push(&hook.args, post_rewrite_hook);
4174 + strvec_push(&hook.args, "rebase");
4175 /* we don't care if this hook failed */
4176 run_command(&hook);
4177 }
serve.c
+6 -6
@@ -56,7 +56,7 @@ struct protocol_capability {
56 * This field should be NULL for capabilities which are not commands.
57 */
58 int (*command)(struct repository *r,
59 - struct argv_array *keys,
59 + struct strvec *keys,
60 struct packet_reader *request);
61 };
62
@@ -142,7 +142,7 @@ static int is_command(const char *key, struct protocol_capability **command)
142 return 0;
143 }
144
145 -int has_capability(const struct argv_array *keys, const char *capability,
145 +int has_capability(const struct strvec *keys, const char *capability,
146 const char **value)
147 {
148 int i;
@@ -162,7 +162,7 @@ int has_capability(const struct argv_array *keys, const char *capability,
162 return 0;
163 }
164
165 -static void check_algorithm(struct repository *r, struct argv_array *keys)
165 +static void check_algorithm(struct repository *r, struct strvec *keys)
166 {
167 int client = GIT_HASH_SHA1, server = hash_algo_by_ptr(r->hash_algo);
168 const char *algo_name;
@@ -187,7 +187,7 @@ static int process_request(void)
187 {
188 enum request_state state = PROCESS_REQUEST_KEYS;
189 struct packet_reader reader;
190 - struct argv_array keys = ARGV_ARRAY_INIT;
190 + struct strvec keys = STRVEC_INIT;
191 struct protocol_capability *command = NULL;
192
193 packet_reader_init(&reader, 0, NULL, 0,
@@ -211,7 +211,7 @@ static int process_request(void)
211 /* collect request; a sequence of keys and values */
212 if (is_command(reader.line, &command) ||
213 is_valid_capability(reader.line))
214 - argv_array_push(&keys, reader.line);
214 + strvec_push(&keys, reader.line);
215 else
216 die("unknown capability '%s'", reader.line);
217
@@ -254,7 +254,7 @@ static int process_request(void)
254
255 command->command(the_repository, &keys, &reader);
256
257 - argv_array_clear(&keys);
257 + strvec_clear(&keys);
258 return 0;
259 }
260
sha1-file.c
+7 -7
@@ -763,18 +763,18 @@ static void fill_alternate_refs_command(struct child_process *cmd,
763 if (!git_config_get_value("core.alternateRefsCommand", &value)) {
764 cmd->use_shell = 1;
765
766 - argv_array_push(&cmd->args, value);
767 - argv_array_push(&cmd->args, repo_path);
766 + strvec_push(&cmd->args, value);
767 + strvec_push(&cmd->args, repo_path);
768 } else {
769 cmd->git_cmd = 1;
770
771 - argv_array_pushf(&cmd->args, "--git-dir=%s", repo_path);
772 - argv_array_push(&cmd->args, "for-each-ref");
773 - argv_array_push(&cmd->args, "--format=%(objectname)");
771 + strvec_pushf(&cmd->args, "--git-dir=%s", repo_path);
772 + strvec_push(&cmd->args, "for-each-ref");
773 + strvec_push(&cmd->args, "--format=%(objectname)");
774
775 if (!git_config_get_value("core.alternateRefsPrefixes", &value)) {
776 - argv_array_push(&cmd->args, "--");
777 - argv_array_split(&cmd->args, value);
776 + strvec_push(&cmd->args, "--");
777 + strvec_split(&cmd->args, value);
778 }
779 }
780
sub-process.c
+1 -1
@@ -84,7 +84,7 @@ int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, co
84 process = &entry->process;
85
86 child_process_init(process);
87 - argv_array_push(&process->args, cmd);
87 + strvec_push(&process->args, cmd);
88 process->use_shell = 1;
89 process->in = -1;
90 process->out = -1;
submodule.c
+89 -89
@@ -262,17 +262,17 @@ int is_submodule_active(struct repository *repo, const char *path)
262 sl = repo_config_get_value_multi(repo, "submodule.active");
263 if (sl) {
264 struct pathspec ps;
265 - struct argv_array args = ARGV_ARRAY_INIT;
265 + struct strvec args = STRVEC_INIT;
266 const struct string_list_item *item;
267
268 for_each_string_list_item(item, sl) {
269 - argv_array_push(&args, item->string);
269 + strvec_push(&args, item->string);
270 }
271
272 parse_pathspec(&ps, 0, 0, NULL, args.argv);
273 ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
274
275 - argv_array_clear(&args);
275 + strvec_clear(&args);
276 clear_pathspec(&ps);
277 return ret;
278 }
@@ -481,27 +481,27 @@ static void print_submodule_summary(struct repository *r, struct rev_info *rev,
481 strbuf_release(&sb);
482 }
483
484 -static void prepare_submodule_repo_env_no_git_dir(struct argv_array *out)
484 +static void prepare_submodule_repo_env_no_git_dir(struct strvec *out)
485 {
486 const char * const *var;
487
488 for (var = local_repo_env; *var; var++) {
489 if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
490 - argv_array_push(out, *var);
490 + strvec_push(out, *var);
491 }
492 }
493
494 -void prepare_submodule_repo_env(struct argv_array *out)
494 +void prepare_submodule_repo_env(struct strvec *out)
495 {
496 prepare_submodule_repo_env_no_git_dir(out);
497 - argv_array_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
497 + strvec_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
498 DEFAULT_GIT_DIR_ENVIRONMENT);
499 }
500
501 -static void prepare_submodule_repo_env_in_gitdir(struct argv_array *out)
501 +static void prepare_submodule_repo_env_in_gitdir(struct strvec *out)
502 {
503 prepare_submodule_repo_env_no_git_dir(out);
504 - argv_array_pushf(out, "%s=.", GIT_DIR_ENVIRONMENT);
504 + strvec_pushf(out, "%s=.", GIT_DIR_ENVIRONMENT);
505 }
506
507 /*
@@ -681,22 +681,22 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
681 cp.no_stdin = 1;
682
683 /* TODO: other options may need to be passed here. */
684 - argv_array_pushl(&cp.args, "diff", "--submodule=diff", NULL);
685 - argv_array_pushf(&cp.args, "--color=%s", want_color(o->use_color) ?
684 + strvec_pushl(&cp.args, "diff", "--submodule=diff", NULL);
685 + strvec_pushf(&cp.args, "--color=%s", want_color(o->use_color) ?
686 "always" : "never");
687
688 if (o->flags.reverse_diff) {
689 - argv_array_pushf(&cp.args, "--src-prefix=%s%s/",
689 + strvec_pushf(&cp.args, "--src-prefix=%s%s/",
690 o->b_prefix, path);
691 - argv_array_pushf(&cp.args, "--dst-prefix=%s%s/",
691 + strvec_pushf(&cp.args, "--dst-prefix=%s%s/",
692 o->a_prefix, path);
693 } else {
694 - argv_array_pushf(&cp.args, "--src-prefix=%s%s/",
694 + strvec_pushf(&cp.args, "--src-prefix=%s%s/",
695 o->a_prefix, path);
696 - argv_array_pushf(&cp.args, "--dst-prefix=%s%s/",
696 + strvec_pushf(&cp.args, "--dst-prefix=%s%s/",
697 o->b_prefix, path);
698 }
699 - argv_array_push(&cp.args, oid_to_hex(old_oid));
699 + strvec_push(&cp.args, oid_to_hex(old_oid));
700 /*
701 * If the submodule has modified content, we will diff against the
702 * work tree, under the assumption that the user has asked for the
@@ -704,7 +704,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
704 * haven't yet been committed to the submodule yet.
705 */
706 if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED))
707 - argv_array_push(&cp.args, oid_to_hex(new_oid));
707 + strvec_push(&cp.args, oid_to_hex(new_oid));
708
709 prepare_submodule_repo_env(&cp.env_array);
710 if (start_command(&cp))
@@ -836,7 +836,7 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
836 */
837 static void collect_changed_submodules(struct repository *r,
838 struct string_list *changed,
839 - struct argv_array *argv)
839 + struct strvec *argv)
840 {
841 struct rev_info rev;
842 const struct commit *commit;
@@ -879,8 +879,8 @@ static int has_remote(const char *refname, const struct object_id *oid,
879
880 static int append_oid_to_argv(const struct object_id *oid, void *data)
881 {
882 - struct argv_array *argv = data;
883 - argv_array_push(argv, oid_to_hex(oid));
882 + struct strvec *argv = data;
883 + strvec_push(argv, oid_to_hex(oid));
884 return 0;
885 }
886
@@ -941,9 +941,9 @@ static int submodule_has_commits(struct repository *r,
941 struct child_process cp = CHILD_PROCESS_INIT;
942 struct strbuf out = STRBUF_INIT;
943
944 - argv_array_pushl(&cp.args, "rev-list", "-n", "1", NULL);
944 + strvec_pushl(&cp.args, "rev-list", "-n", "1", NULL);
945 oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
946 - argv_array_pushl(&cp.args, "--not", "--all", NULL);
946 + strvec_pushl(&cp.args, "--not", "--all", NULL);
947
948 prepare_submodule_repo_env(&cp.env_array);
949 cp.git_cmd = 1;
@@ -982,9 +982,9 @@ static int submodule_needs_pushing(struct repository *r,
982 struct strbuf buf = STRBUF_INIT;
983 int needs_pushing = 0;
984
985 - argv_array_push(&cp.args, "rev-list");
985 + strvec_push(&cp.args, "rev-list");
986 oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
987 - argv_array_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
987 + strvec_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
988
989 prepare_submodule_repo_env(&cp.env_array);
990 cp.git_cmd = 1;
@@ -1012,13 +1012,13 @@ int find_unpushed_submodules(struct repository *r,
1012 {
1013 struct string_list submodules = STRING_LIST_INIT_DUP;
1014 struct string_list_item *name;
1015 - struct argv_array argv = ARGV_ARRAY_INIT;
1015 + struct strvec argv = STRVEC_INIT;
1016
1017 /* argv.argv[0] will be ignored by setup_revisions */
1018 - argv_array_push(&argv, "find_unpushed_submodules");
1018 + strvec_push(&argv, "find_unpushed_submodules");
1019 oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
1020 - argv_array_push(&argv, "--not");
1021 - argv_array_pushf(&argv, "--remotes=%s", remotes_name);
1020 + strvec_push(&argv, "--not");
1021 + strvec_pushf(&argv, "--remotes=%s", remotes_name);
1022
1023 collect_changed_submodules(r, &submodules, &argv);
1024
@@ -1041,7 +1041,7 @@ int find_unpushed_submodules(struct repository *r,
1041 }
1042
1043 free_submodules_oids(&submodules);
1044 - argv_array_clear(&argv);
1044 + strvec_clear(&argv);
1045
1046 return needs_pushing->nr;
1047 }
@@ -1054,22 +1054,22 @@ static int push_submodule(const char *path,
1054 {
1055 if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
1056 struct child_process cp = CHILD_PROCESS_INIT;
1057 - argv_array_push(&cp.args, "push");
1057 + strvec_push(&cp.args, "push");
1058 if (dry_run)
1059 - argv_array_push(&cp.args, "--dry-run");
1059 + strvec_push(&cp.args, "--dry-run");
1060
1061 if (push_options && push_options->nr) {
1062 const struct string_list_item *item;
1063 for_each_string_list_item(item, push_options)
1064 - argv_array_pushf(&cp.args, "--push-option=%s",
1064 + strvec_pushf(&cp.args, "--push-option=%s",
1065 item->string);
1066 }
1067
1068 if (remote->origin != REMOTE_UNCONFIGURED) {
1069 int i;
1070 - argv_array_push(&cp.args, remote->name);
1070 + strvec_push(&cp.args, remote->name);
1071 for (i = 0; i < rs->raw_nr; i++)
1072 - argv_array_push(&cp.args, rs->raw[i]);
1072 + strvec_push(&cp.args, rs->raw[i]);
1073 }
1074
1075 prepare_submodule_repo_env(&cp.env_array);
@@ -1095,13 +1095,13 @@ static void submodule_push_check(const char *path, const char *head,
1095 struct child_process cp = CHILD_PROCESS_INIT;
1096 int i;
1097
1098 - argv_array_push(&cp.args, "submodule--helper");
1099 - argv_array_push(&cp.args, "push-check");
1100 - argv_array_push(&cp.args, head);
1101 - argv_array_push(&cp.args, remote->name);
1098 + strvec_push(&cp.args, "submodule--helper");
1099 + strvec_push(&cp.args, "push-check");
1100 + strvec_push(&cp.args, head);
1101 + strvec_push(&cp.args, remote->name);
1102
1103 for (i = 0; i < rs->raw_nr; i++)
1104 - argv_array_push(&cp.args, rs->raw[i]);
1104 + strvec_push(&cp.args, rs->raw[i]);
1105
1106 prepare_submodule_repo_env(&cp.env_array);
1107 cp.git_cmd = 1;
@@ -1189,17 +1189,17 @@ void check_for_new_submodule_commits(struct object_id *oid)
1189 static void calculate_changed_submodule_paths(struct repository *r,
1190 struct string_list *changed_submodule_names)
1191 {
1192 - struct argv_array argv = ARGV_ARRAY_INIT;
1192 + struct strvec argv = STRVEC_INIT;
1193 struct string_list_item *name;
1194
1195 /* No need to check if there are no submodules configured */
1196 if (!submodule_from_path(r, NULL, NULL))
1197 return;
1198
1199 - argv_array_push(&argv, "--"); /* argv[0] program name */
1199 + strvec_push(&argv, "--"); /* argv[0] program name */
1200 oid_array_for_each_unique(&ref_tips_after_fetch,
1201 append_oid_to_argv, &argv);
1202 - argv_array_push(&argv, "--not");
1202 + strvec_push(&argv, "--not");
1203 oid_array_for_each_unique(&ref_tips_before_fetch,
1204 append_oid_to_argv, &argv);
1205
@@ -1231,7 +1231,7 @@ static void calculate_changed_submodule_paths(struct repository *r,
1231
1232 string_list_remove_empty_items(changed_submodule_names, 1);
1233
1234 - argv_array_clear(&argv);
1234 + strvec_clear(&argv);
1235 oid_array_clear(&ref_tips_before_fetch);
1236 oid_array_clear(&ref_tips_after_fetch);
1237 initialized_fetch_ref_tips = 0;
@@ -1242,24 +1242,24 @@ int submodule_touches_in_range(struct repository *r,
1242 struct object_id *incl_oid)
1243 {
1244 struct string_list subs = STRING_LIST_INIT_DUP;
1245 - struct argv_array args = ARGV_ARRAY_INIT;
1245 + struct strvec args = STRVEC_INIT;
1246 int ret;
1247
1248 /* No need to check if there are no submodules configured */
1249 if (!submodule_from_path(r, NULL, NULL))
1250 return 0;
1251
1252 - argv_array_push(&args, "--"); /* args[0] program name */
1253 - argv_array_push(&args, oid_to_hex(incl_oid));
1252 + strvec_push(&args, "--"); /* args[0] program name */
1253 + strvec_push(&args, oid_to_hex(incl_oid));
1254 if (!is_null_oid(excl_oid)) {
1255 - argv_array_push(&args, "--not");
1256 - argv_array_push(&args, oid_to_hex(excl_oid));
1255 + strvec_push(&args, "--not");
1256 + strvec_push(&args, oid_to_hex(excl_oid));
1257 }
1258
1259 collect_changed_submodules(r, &subs, &args);
1260 ret = subs.nr;
1261
1262 - argv_array_clear(&args);
1262 + strvec_clear(&args);
1263
1264 free_submodules_oids(&subs);
1265 return ret;
@@ -1267,7 +1267,7 @@ int submodule_touches_in_range(struct repository *r,
1267
1268 struct submodule_parallel_fetch {
1269 int count;
1270 - struct argv_array args;
1270 + struct strvec args;
1271 struct repository *r;
1272 const char *prefix;
1273 int command_line_option;
@@ -1283,7 +1283,7 @@ struct submodule_parallel_fetch {
1283
1284 struct strbuf submodules_with_errors;
1285 };
1286 -#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, \
1286 +#define SPF_INIT {0, STRVEC_INIT, NULL, NULL, 0, 0, 0, 0, \
1287 STRING_LIST_INIT_DUP, \
1288 NULL, 0, 0, STRBUF_INIT}
1289
@@ -1452,15 +1452,15 @@ static int get_next_submodule(struct child_process *cp,
1452 if (!spf->quiet)
1453 strbuf_addf(err, _("Fetching submodule %s%s\n"),
1454 spf->prefix, ce->name);
1455 - argv_array_init(&cp->args);
1456 - argv_array_pushv(&cp->args, spf->args.argv);
1457 - argv_array_push(&cp->args, default_argv);
1458 - argv_array_push(&cp->args, "--submodule-prefix");
1455 + strvec_init(&cp->args);
1456 + strvec_pushv(&cp->args, spf->args.argv);
1457 + strvec_push(&cp->args, default_argv);
1458 + strvec_push(&cp->args, "--submodule-prefix");
1459
1460 strbuf_addf(&submodule_prefix, "%s%s/",
1461 spf->prefix,
1462 task->sub->path);
1463 - argv_array_push(&cp->args, submodule_prefix.buf);
1463 + strvec_push(&cp->args, submodule_prefix.buf);
1464
1465 spf->count++;
1466 *task_cb = task;
@@ -1500,14 +1500,14 @@ static int get_next_submodule(struct child_process *cp,
1500 cp->git_cmd = 1;
1501 cp->dir = task->repo->gitdir;
1502
1503 - argv_array_init(&cp->args);
1504 - argv_array_pushv(&cp->args, spf->args.argv);
1505 - argv_array_push(&cp->args, "on-demand");
1506 - argv_array_push(&cp->args, "--submodule-prefix");
1507 - argv_array_push(&cp->args, submodule_prefix.buf);
1503 + strvec_init(&cp->args);
1504 + strvec_pushv(&cp->args, spf->args.argv);
1505 + strvec_push(&cp->args, "on-demand");
1506 + strvec_push(&cp->args, "--submodule-prefix");
1507 + strvec_push(&cp->args, submodule_prefix.buf);
1508
1509 /* NEEDSWORK: have get_default_remote from submodule--helper */
1510 - argv_array_push(&cp->args, "origin");
1510 + strvec_push(&cp->args, "origin");
1511 oid_array_for_each_unique(task->commits,
1512 append_oid_to_argv, &cp->args);
1513
@@ -1598,7 +1598,7 @@ out:
1598 }
1599
1600 int fetch_populated_submodules(struct repository *r,
1601 - const struct argv_array *options,
1601 + const struct strvec *options,
1602 const char *prefix, int command_line_option,
1603 int default_option,
1604 int quiet, int max_parallel_jobs)
@@ -1618,10 +1618,10 @@ int fetch_populated_submodules(struct repository *r,
1618 if (repo_read_index(r) < 0)
1619 die(_("index file corrupt"));
1620
1621 - argv_array_push(&spf.args, "fetch");
1621 + strvec_push(&spf.args, "fetch");
1622 for (i = 0; i < options->argc; i++)
1623 - argv_array_push(&spf.args, options->argv[i]);
1624 - argv_array_push(&spf.args, "--recurse-submodules-default");
1623 + strvec_push(&spf.args, options->argv[i]);
1624 + strvec_push(&spf.args, "--recurse-submodules-default");
1625 /* default value, "--submodule-prefix" and its value are added later */
1626
1627 calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
@@ -1638,7 +1638,7 @@ int fetch_populated_submodules(struct repository *r,
1638 spf.submodules_with_errors.buf);
1639
1640
1641 - argv_array_clear(&spf.args);
1641 + strvec_clear(&spf.args);
1642 out:
1643 free_submodules_oids(&spf.changed_submodule_names);
1644 return spf.result;
@@ -1666,9 +1666,9 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
1666 }
1667 strbuf_reset(&buf);
1668
1669 - argv_array_pushl(&cp.args, "status", "--porcelain=2", NULL);
1669 + strvec_pushl(&cp.args, "status", "--porcelain=2", NULL);
1670 if (ignore_untracked)
1671 - argv_array_push(&cp.args, "-uno");
1671 + strvec_push(&cp.args, "-uno");
1672
1673 prepare_submodule_repo_env(&cp.env_array);
1674 cp.git_cmd = 1;
@@ -1779,16 +1779,16 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
1779 if (!submodule_uses_gitfile(path))
1780 return 1;
1781
1782 - argv_array_pushl(&cp.args, "status", "--porcelain",
1782 + strvec_pushl(&cp.args, "status", "--porcelain",
1783 "--ignore-submodules=none", NULL);
1784
1785 if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
1786 - argv_array_push(&cp.args, "-uno");
1786 + strvec_push(&cp.args, "-uno");
1787 else
1788 - argv_array_push(&cp.args, "-uall");
1788 + strvec_push(&cp.args, "-uall");
1789
1790 if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
1791 - argv_array_push(&cp.args, "--ignored");
1791 + strvec_push(&cp.args, "--ignored");
1792
1793 prepare_submodule_repo_env(&cp.env_array);
1794 cp.git_cmd = 1;
@@ -1846,7 +1846,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
1846 prepare_submodule_repo_env(&cp.env_array);
1847
1848 cp.git_cmd = 1;
1849 - argv_array_pushl(&cp.args, "diff-index", "--quiet",
1849 + strvec_pushl(&cp.args, "diff-index", "--quiet",
1850 "--cached", "HEAD", NULL);
1851 cp.no_stdin = 1;
1852 cp.no_stdout = 1;
@@ -1866,11 +1866,11 @@ static void submodule_reset_index(const char *path)
1866 cp.no_stdin = 1;
1867 cp.dir = path;
1868
1869 - argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
1869 + strvec_pushf(&cp.args, "--super-prefix=%s%s/",
1870 get_super_prefix_or_empty(), path);
1871 - argv_array_pushl(&cp.args, "read-tree", "-u", "--reset", NULL);
1871 + strvec_pushl(&cp.args, "read-tree", "-u", "--reset", NULL);
1872
1873 - argv_array_push(&cp.args, empty_tree_oid_hex());
1873 + strvec_push(&cp.args, empty_tree_oid_hex());
1874
1875 if (run_command(&cp))
1876 die(_("could not reset submodule index"));
@@ -1947,24 +1947,24 @@ int submodule_move_head(const char *path,
1947 cp.no_stdin = 1;
1948 cp.dir = path;
1949
1950 - argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
1950 + strvec_pushf(&cp.args, "--super-prefix=%s%s/",
1951 get_super_prefix_or_empty(), path);
1952 - argv_array_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
1952 + strvec_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
1953
1954 if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN)
1955 - argv_array_push(&cp.args, "-n");
1955 + strvec_push(&cp.args, "-n");
1956 else
1957 - argv_array_push(&cp.args, "-u");
1957 + strvec_push(&cp.args, "-u");
1958
1959 if (flags & SUBMODULE_MOVE_HEAD_FORCE)
1960 - argv_array_push(&cp.args, "--reset");
1960 + strvec_push(&cp.args, "--reset");
1961 else
1962 - argv_array_push(&cp.args, "-m");
1962 + strvec_push(&cp.args, "-m");
1963
1964 if (!(flags & SUBMODULE_MOVE_HEAD_FORCE))
1965 - argv_array_push(&cp.args, old_head ? old_head : empty_tree_oid_hex());
1965 + strvec_push(&cp.args, old_head ? old_head : empty_tree_oid_hex());
1966
1967 - argv_array_push(&cp.args, new_head ? new_head : empty_tree_oid_hex());
1967 + strvec_push(&cp.args, new_head ? new_head : empty_tree_oid_hex());
1968
1969 if (run_command(&cp)) {
1970 ret = error(_("Submodule '%s' could not be updated."), path);
@@ -1980,7 +1980,7 @@ int submodule_move_head(const char *path,
1980 cp.dir = path;
1981
1982 prepare_submodule_repo_env(&cp.env_array);
1983 - argv_array_pushl(&cp.args, "update-ref", "HEAD",
1983 + strvec_pushl(&cp.args, "update-ref", "HEAD",
1984 "--no-deref", new_head, NULL);
1985
1986 if (run_command(&cp)) {
@@ -2157,7 +2157,7 @@ void absorb_git_dir_into_superproject(const char *path,
2157 cp.dir = path;
2158 cp.git_cmd = 1;
2159 cp.no_stdin = 1;
2160 - argv_array_pushl(&cp.args, "--super-prefix", sb.buf,
2160 + strvec_pushl(&cp.args, "--super-prefix", sb.buf,
2161 "submodule--helper",
2162 "absorb-git-dirs", NULL);
2163 prepare_submodule_repo_env(&cp.env_array);
@@ -2194,9 +2194,9 @@ int get_superproject_working_tree(struct strbuf *buf)
2194 strbuf_release(&one_up);
2195
2196 prepare_submodule_repo_env(&cp.env_array);
2197 - argv_array_pop(&cp.env_array);
2197 + strvec_pop(&cp.env_array);
2198
2199 - argv_array_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
2199 + strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
2200 "ls-files", "-z", "--stage", "--full-name", "--",
2201 subpath, NULL);
2202 strbuf_reset(&sb);
t/helper/test-run-command.c
+18 -18
@@ -31,7 +31,7 @@ static int parallel_next(struct child_process *cp,
31 if (number_callbacks >= 4)
32 return 0;
33
34 - argv_array_pushv(&cp->args, d->argv);
34 + strvec_pushv(&cp->args, d->argv);
35 strbuf_addstr(err, "preloaded output of a child\n");
36 number_callbacks++;
37 return 1;
@@ -72,19 +72,19 @@ static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
72 return 0;
73
74 test = suite->tests.items[suite->next++].string;
75 - argv_array_pushl(&cp->args, "sh", test, NULL);
75 + strvec_pushl(&cp->args, "sh", test, NULL);
76 if (suite->quiet)
77 - argv_array_push(&cp->args, "--quiet");
77 + strvec_push(&cp->args, "--quiet");
78 if (suite->immediate)
79 - argv_array_push(&cp->args, "-i");
79 + strvec_push(&cp->args, "-i");
80 if (suite->verbose)
81 - argv_array_push(&cp->args, "-v");
81 + strvec_push(&cp->args, "-v");
82 if (suite->verbose_log)
83 - argv_array_push(&cp->args, "-V");
83 + strvec_push(&cp->args, "-V");
84 if (suite->trace)
85 - argv_array_push(&cp->args, "-x");
85 + strvec_push(&cp->args, "-x");
86 if (suite->write_junit_xml)
87 - argv_array_push(&cp->args, "--write-junit-xml");
87 + strvec_push(&cp->args, "--write-junit-xml");
88
89 strbuf_addf(err, "Output of '%s':\n", test);
90 *task_cb = (void *)test;
@@ -220,7 +220,7 @@ static int quote_stress_test(int argc, const char **argv)
220 char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
221 int i, j, k, trials = 100, skip = 0, msys2 = 0;
222 struct strbuf out = STRBUF_INIT;
223 - struct argv_array args = ARGV_ARRAY_INIT;
223 + struct strvec args = STRVEC_INIT;
224 struct option options[] = {
225 OPT_INTEGER('n', "trials", &trials, "Number of trials"),
226 OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
@@ -241,12 +241,12 @@ static int quote_stress_test(int argc, const char **argv)
241 size_t arg_count, arg_offset;
242 int ret = 0;
243
244 - argv_array_clear(&args);
244 + strvec_clear(&args);
245 if (msys2)
246 - argv_array_pushl(&args, "sh", "-c",
246 + strvec_pushl(&args, "sh", "-c",
247 "printf %s\\\\0 \"$@\"", "skip", NULL);
248 else
249 - argv_array_pushl(&args, "test-tool", "run-command",
249 + strvec_pushl(&args, "test-tool", "run-command",
250 "quote-echo", NULL);
251 arg_offset = args.argc;
252
@@ -254,7 +254,7 @@ static int quote_stress_test(int argc, const char **argv)
254 trials = 1;
255 arg_count = argc;
256 for (j = 0; j < arg_count; j++)
257 - argv_array_push(&args, argv[j]);
257 + strvec_push(&args, argv[j]);
258 } else {
259 arg_count = 1 + (my_random() % 5);
260 for (j = 0; j < arg_count; j++) {
@@ -268,7 +268,7 @@ static int quote_stress_test(int argc, const char **argv)
268 ARRAY_SIZE(special)];
269 buf[arg_len] = '\0';
270
271 - argv_array_push(&args, buf);
271 + strvec_push(&args, buf);
272 }
273 }
274
@@ -301,7 +301,7 @@ static int quote_stress_test(int argc, const char **argv)
301 (int)j, args.argv[j + arg_offset]);
302
303 strbuf_release(&out);
304 - argv_array_clear(&args);
304 + strvec_clear(&args);
305
306 return ret;
307 }
@@ -311,7 +311,7 @@ static int quote_stress_test(int argc, const char **argv)
311 }
312
313 strbuf_release(&out);
314 - argv_array_clear(&args);
314 + strvec_clear(&args);
315
316 return 0;
317 }
@@ -338,7 +338,7 @@ static int inherit_handle(const char *argv0)
338 xsnprintf(path, sizeof(path), "out-XXXXXX");
339 tmp = xmkstemp(path);
340
341 - argv_array_pushl(&cp.args,
341 + strvec_pushl(&cp.args,
342 "test-tool", argv0, "inherited-handle-child", NULL);
343 cp.in = -1;
344 cp.no_stdout = cp.no_stderr = 1;
@@ -391,7 +391,7 @@ int cmd__run_command(int argc, const char **argv)
391 while (!strcmp(argv[1], "env")) {
392 if (!argv[2])
393 die("env specifier without a value");
394 - argv_array_push(&proc.env_array, argv[2]);
394 + strvec_push(&proc.env_array, argv[2]);
395 argv += 2;
396 argc -= 2;
397 }
tmp-objdir.c
+8 -8
@@ -10,7 +10,7 @@
10
11 struct tmp_objdir {
12 struct strbuf path;
13 - struct argv_array env;
13 + struct strvec env;
14 };
15
16 /*
@@ -24,7 +24,7 @@ static struct tmp_objdir *the_tmp_objdir;
24 static void tmp_objdir_free(struct tmp_objdir *t)
25 {
26 strbuf_release(&t->path);
27 - argv_array_clear(&t->env);
27 + strvec_clear(&t->env);
28 free(t);
29 }
30
@@ -79,7 +79,7 @@ static void remove_tmp_objdir_on_signal(int signo)
79 * separated by PATH_SEP (which is what separate values in
80 * GIT_ALTERNATE_OBJECT_DIRECTORIES).
81 */
82 -static void env_append(struct argv_array *env, const char *key, const char *val)
82 +static void env_append(struct strvec *env, const char *key, const char *val)
83 {
84 struct strbuf quoted = STRBUF_INIT;
85 const char *old;
@@ -97,16 +97,16 @@ static void env_append(struct argv_array *env, const char *key, const char *val)
97
98 old = getenv(key);
99 if (!old)
100 - argv_array_pushf(env, "%s=%s", key, val);
100 + strvec_pushf(env, "%s=%s", key, val);
101 else
102 - argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
102 + strvec_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
103
104 strbuf_release(&quoted);
105 }
106
107 -static void env_replace(struct argv_array *env, const char *key, const char *val)
107 +static void env_replace(struct strvec *env, const char *key, const char *val)
108 {
109 - argv_array_pushf(env, "%s=%s", key, val);
109 + strvec_pushf(env, "%s=%s", key, val);
110 }
111
112 static int setup_tmp_objdir(const char *root)
@@ -131,7 +131,7 @@ struct tmp_objdir *tmp_objdir_create(void)
131
132 t = xmalloc(sizeof(*t));
133 strbuf_init(&t->path, 0);
134 - argv_array_init(&t->env);
134 + strvec_init(&t->env);
135
136 strbuf_addf(&t->path, "%s/incoming-XXXXXX", get_object_directory());
137
transport-helper.c
+15 -15
@@ -128,14 +128,14 @@ static struct child_process *get_helper(struct transport *transport)
128 helper->in = -1;
129 helper->out = -1;
130 helper->err = 0;
131 - argv_array_pushf(&helper->args, "git-remote-%s", data->name);
132 - argv_array_push(&helper->args, transport->remote->name);
133 - argv_array_push(&helper->args, remove_ext_force(transport->url));
131 + strvec_pushf(&helper->args, "git-remote-%s", data->name);
132 + strvec_push(&helper->args, transport->remote->name);
133 + strvec_push(&helper->args, remove_ext_force(transport->url));
134 helper->git_cmd = 0;
135 helper->silent_exec_failure = 1;
136
137 if (have_git_dir())
138 - argv_array_pushf(&helper->env_array, "%s=%s",
138 + strvec_pushf(&helper->env_array, "%s=%s",
139 GIT_DIR_ENVIRONMENT, get_git_dir());
140
141 helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
@@ -439,13 +439,13 @@ static int get_importer(struct transport *transport, struct child_process *fasti
439 int cat_blob_fd, code;
440 child_process_init(fastimport);
441 fastimport->in = xdup(helper->out);
442 - argv_array_push(&fastimport->args, "fast-import");
443 - argv_array_push(&fastimport->args, "--allow-unsafe-features");
444 - argv_array_push(&fastimport->args, debug ? "--stats" : "--quiet");
442 + strvec_push(&fastimport->args, "fast-import");
443 + strvec_push(&fastimport->args, "--allow-unsafe-features");
444 + strvec_push(&fastimport->args, debug ? "--stats" : "--quiet");
445
446 if (data->bidi_import) {
447 cat_blob_fd = xdup(helper->in);
448 - argv_array_pushf(&fastimport->args, "--cat-blob-fd=%d", cat_blob_fd);
448 + strvec_pushf(&fastimport->args, "--cat-blob-fd=%d", cat_blob_fd);
449 }
450 fastimport->git_cmd = 1;
451
@@ -466,17 +466,17 @@ static int get_exporter(struct transport *transport,
466 /* we need to duplicate helper->in because we want to use it after
467 * fastexport is done with it. */
468 fastexport->out = dup(helper->in);
469 - argv_array_push(&fastexport->args, "fast-export");
470 - argv_array_push(&fastexport->args, "--use-done-feature");
471 - argv_array_push(&fastexport->args, data->signed_tags ?
469 + strvec_push(&fastexport->args, "fast-export");
470 + strvec_push(&fastexport->args, "--use-done-feature");
471 + strvec_push(&fastexport->args, data->signed_tags ?
472 "--signed-tags=verbatim" : "--signed-tags=warn-strip");
473 if (data->export_marks)
474 - argv_array_pushf(&fastexport->args, "--export-marks=%s.tmp", data->export_marks);
474 + strvec_pushf(&fastexport->args, "--export-marks=%s.tmp", data->export_marks);
475 if (data->import_marks)
476 - argv_array_pushf(&fastexport->args, "--import-marks=%s", data->import_marks);
476 + strvec_pushf(&fastexport->args, "--import-marks=%s", data->import_marks);
477
478 for (i = 0; i < revlist_args->nr; i++)
479 - argv_array_push(&fastexport->args, revlist_args->items[i].string);
479 + strvec_push(&fastexport->args, revlist_args->items[i].string);
480
481 fastexport->git_cmd = 1;
482 return start_command(fastexport);
@@ -1082,7 +1082,7 @@ static int has_attribute(const char *attrs, const char *attr)
1082 }
1083
1084 static struct ref *get_refs_list(struct transport *transport, int for_push,
1085 - const struct argv_array *ref_prefixes)
1085 + const struct strvec *ref_prefixes)
1086 {
1087 get_helper(transport);
1088
transport-internal.h
+1 -1
@@ -30,7 +30,7 @@ struct transport_vtable {
30 * in the ref's old_sha1 field; otherwise it should be all 0.
31 **/
32 struct ref *(*get_refs_list)(struct transport *transport, int for_push,
33 - const struct argv_array *ref_prefixes);
33 + const struct strvec *ref_prefixes);
34
35 /**
36 * Fetch the objects for the given refs. Note that this gets
transport.c
+6 -6
@@ -127,7 +127,7 @@ struct bundle_transport_data {
127
128 static struct ref *get_refs_from_bundle(struct transport *transport,
129 int for_push,
130 - const struct argv_array *ref_prefixes)
130 + const struct strvec *ref_prefixes)
131 {
132 struct bundle_transport_data *data = transport->data;
133 struct ref *result = NULL;
@@ -283,7 +283,7 @@ static void die_if_server_options(struct transport *transport)
283 * remote refs.
284 */
285 static struct ref *handshake(struct transport *transport, int for_push,
286 - const struct argv_array *ref_prefixes,
286 + const struct strvec *ref_prefixes,
287 int must_list_refs)
288 {
289 struct git_transport_data *data = transport->data;
@@ -327,7 +327,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
327 }
328
329 static struct ref *get_refs_via_connect(struct transport *transport, int for_push,
330 - const struct argv_array *ref_prefixes)
330 + const struct strvec *ref_prefixes)
331 {
332 return handshake(transport, for_push, ref_prefixes, 1);
333 }
@@ -1153,7 +1153,7 @@ int transport_push(struct repository *r,
1153 int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
1154 int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
1155 int push_ret, ret, err;
1156 - struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
1156 + struct strvec ref_prefixes = STRVEC_INIT;
1157
1158 if (check_push_refs(local_refs, rs) < 0)
1159 return -1;
@@ -1165,7 +1165,7 @@ int transport_push(struct repository *r,
1165 &ref_prefixes);
1166 trace2_region_leave("transport_push", "get_refs_list", r);
1167
1168 - argv_array_clear(&ref_prefixes);
1168 + strvec_clear(&ref_prefixes);
1169
1170 if (flags & TRANSPORT_PUSH_ALL)
1171 match_flags |= MATCH_REFS_ALL;
@@ -1281,7 +1281,7 @@ int transport_push(struct repository *r,
1281 }
1282
1283 const struct ref *transport_get_remote_refs(struct transport *transport,
1284 - const struct argv_array *ref_prefixes)
1284 + const struct strvec *ref_prefixes)
1285 {
1286 if (!transport->got_remote_refs) {
1287 transport->remote_refs =
transport.h
+1 -1
@@ -243,7 +243,7 @@ int transport_push(struct repository *repo,
243 * ref_prefixes.
244 */
245 const struct ref *transport_get_remote_refs(struct transport *transport,
246 - const struct argv_array *ref_prefixes);
246 + const struct strvec *ref_prefixes);
247
248 /*
249 * Fetch the hash algorithm used by a remote.
unpack-trees.c
+5 -5
@@ -106,7 +106,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
106 const char **msgs = opts->msgs;
107 const char *msg;
108
109 - argv_array_init(&opts->msgs_to_free);
109 + strvec_init(&opts->msgs_to_free);
110
111 if (!strcmp(cmd, "checkout"))
112 msg = advice_commit_before_merge
@@ -124,7 +124,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
124 "Please commit your changes or stash them before you %s.")
125 : _("Your local changes to the following files would be overwritten by %s:\n%%s");
126 msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] =
127 - argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
127 + strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
128
129 msgs[ERROR_NOT_UPTODATE_DIR] =
130 _("Updating the following directories would lose untracked files in them:\n%s");
@@ -145,7 +145,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
145 "Please move or remove them before you %s.")
146 : _("The following untracked working tree files would be removed by %s:\n%%s");
147 msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] =
148 - argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
148 + strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
149
150 if (!strcmp(cmd, "checkout"))
151 msg = advice_commit_before_merge
@@ -163,7 +163,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
163 "Please move or remove them before you %s.")
164 : _("The following untracked working tree files would be overwritten by %s:\n%%s");
165 msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] =
166 - argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
166 + strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
167
168 /*
169 * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we
@@ -189,7 +189,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
189
190 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts)
191 {
192 - argv_array_clear(&opts->msgs_to_free);
192 + strvec_clear(&opts->msgs_to_free);
193 memset(opts->msgs, 0, sizeof(opts->msgs));
194 }
195
unpack-trees.h
+1 -1
@@ -70,7 +70,7 @@ struct unpack_trees_options {
70 struct pathspec *pathspec;
71 merge_fn_t fn;
72 const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
73 - struct argv_array msgs_to_free;
73 + struct strvec msgs_to_free;
74 /*
75 * Store error messages in an array, each case
76 * corresponding to a error message type
upload-pack.c
+24 -24
@@ -269,45 +269,45 @@ static void create_pack_file(struct upload_pack_data *pack_data,
269 if (!pack_data->pack_objects_hook)
270 pack_objects.git_cmd = 1;
271 else {
272 - argv_array_push(&pack_objects.args, pack_data->pack_objects_hook);
273 - argv_array_push(&pack_objects.args, "git");
272 + strvec_push(&pack_objects.args, pack_data->pack_objects_hook);
273 + strvec_push(&pack_objects.args, "git");
274 pack_objects.use_shell = 1;
275 }
276
277 if (pack_data->shallow_nr) {
278 - argv_array_push(&pack_objects.args, "--shallow-file");
279 - argv_array_push(&pack_objects.args, "");
278 + strvec_push(&pack_objects.args, "--shallow-file");
279 + strvec_push(&pack_objects.args, "");
280 }
281 - argv_array_push(&pack_objects.args, "pack-objects");
282 - argv_array_push(&pack_objects.args, "--revs");
281 + strvec_push(&pack_objects.args, "pack-objects");
282 + strvec_push(&pack_objects.args, "--revs");
283 if (pack_data->use_thin_pack)
284 - argv_array_push(&pack_objects.args, "--thin");
284 + strvec_push(&pack_objects.args, "--thin");
285
286 - argv_array_push(&pack_objects.args, "--stdout");
286 + strvec_push(&pack_objects.args, "--stdout");
287 if (pack_data->shallow_nr)
288 - argv_array_push(&pack_objects.args, "--shallow");
288 + strvec_push(&pack_objects.args, "--shallow");
289 if (!pack_data->no_progress)
290 - argv_array_push(&pack_objects.args, "--progress");
290 + strvec_push(&pack_objects.args, "--progress");
291 if (pack_data->use_ofs_delta)
292 - argv_array_push(&pack_objects.args, "--delta-base-offset");
292 + strvec_push(&pack_objects.args, "--delta-base-offset");
293 if (pack_data->use_include_tag)
294 - argv_array_push(&pack_objects.args, "--include-tag");
294 + strvec_push(&pack_objects.args, "--include-tag");
295 if (pack_data->filter_options.choice) {
296 const char *spec =
297 expand_list_objects_filter_spec(&pack_data->filter_options);
298 if (pack_objects.use_shell) {
299 struct strbuf buf = STRBUF_INIT;
300 sq_quote_buf(&buf, spec);
301 - argv_array_pushf(&pack_objects.args, "--filter=%s", buf.buf);
301 + strvec_pushf(&pack_objects.args, "--filter=%s", buf.buf);
302 strbuf_release(&buf);
303 } else {
304 - argv_array_pushf(&pack_objects.args, "--filter=%s",
304 + strvec_pushf(&pack_objects.args, "--filter=%s",
305 spec);
306 }
307 }
308 if (uri_protocols) {
309 for (i = 0; i < uri_protocols->nr; i++)
310 - argv_array_pushf(&pack_objects.args, "--uri-protocol=%s",
310 + strvec_pushf(&pack_objects.args, "--uri-protocol=%s",
311 uri_protocols->items[i].string);
312 }
313
@@ -880,26 +880,26 @@ static int send_shallow_list(struct upload_pack_data *data)
880 deepen(data, data->depth);
881 ret = 1;
882 } else if (data->deepen_rev_list) {
883 - struct argv_array av = ARGV_ARRAY_INIT;
883 + struct strvec av = STRVEC_INIT;
884 int i;
885
886 - argv_array_push(&av, "rev-list");
886 + strvec_push(&av, "rev-list");
887 if (data->deepen_since)
888 - argv_array_pushf(&av, "--max-age=%"PRItime, data->deepen_since);
888 + strvec_pushf(&av, "--max-age=%"PRItime, data->deepen_since);
889 if (data->deepen_not.nr) {
890 - argv_array_push(&av, "--not");
890 + strvec_push(&av, "--not");
891 for (i = 0; i < data->deepen_not.nr; i++) {
892 struct string_list_item *s = data->deepen_not.items + i;
893 - argv_array_push(&av, s->string);
893 + strvec_push(&av, s->string);
894 }
895 - argv_array_push(&av, "--not");
895 + strvec_push(&av, "--not");
896 }
897 for (i = 0; i < data->want_obj.nr; i++) {
898 struct object *o = data->want_obj.objects[i].item;
899 - argv_array_push(&av, oid_to_hex(&o->oid));
899 + strvec_push(&av, oid_to_hex(&o->oid));
900 }
901 deepen_by_rev_list(data, av.argc, av.argv);
902 - argv_array_clear(&av);
902 + strvec_clear(&av);
903 ret = 1;
904 } else {
905 if (data->shallows.nr > 0) {
@@ -1521,7 +1521,7 @@ enum fetch_state {
1521 FETCH_DONE,
1522 };
1523
1524 -int upload_pack_v2(struct repository *r, struct argv_array *keys,
1524 +int upload_pack_v2(struct repository *r, struct strvec *keys,
1525 struct packet_reader *request)
1526 {
1527 enum fetch_state state = FETCH_PROCESS_ARGS;
wt-status.c
+8 -8
@@ -913,17 +913,17 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
913 struct strbuf summary = STRBUF_INIT;
914 char *summary_content;
915
916 - argv_array_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
916 + strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
917 s->index_file);
918
919 - argv_array_push(&sm_summary.args, "submodule");
920 - argv_array_push(&sm_summary.args, "summary");
921 - argv_array_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
922 - argv_array_push(&sm_summary.args, "--for-status");
923 - argv_array_push(&sm_summary.args, "--summary-limit");
924 - argv_array_pushf(&sm_summary.args, "%d", s->submodule_summary);
919 + strvec_push(&sm_summary.args, "submodule");
920 + strvec_push(&sm_summary.args, "summary");
921 + strvec_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
922 + strvec_push(&sm_summary.args, "--for-status");
923 + strvec_push(&sm_summary.args, "--summary-limit");
924 + strvec_pushf(&sm_summary.args, "%d", s->submodule_summary);
925 if (!uncommitted)
926 - argv_array_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
926 + strvec_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
927
928 sm_summary.git_cmd = 1;
929 sm_summary.no_stdin = 1;