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
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
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
* 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
*/
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
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
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
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
{
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
}
1042
1043
free_submodules_oids(&submodules);
1044
- argv_array_clear(&argv);
1044
+ strvec_clear(&argv);
1045
1046
return needs_pushing->nr;
1047
}
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
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
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
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
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
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
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
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
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
}
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
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
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
}
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
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
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
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
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
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
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
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);