strvec: rename struct fields
The "argc" and "argv" names made sense when the struct was argv_array, but now they're just confusing. Let's rename them to "nr" (which we use for counts elsewhere) and "v" (which is rather terse, but reads well when combined with typical variable names like "args.v"). Note that we have to update all of the callers immediately. Playing tricks with the preprocessor is hard here, because we wouldn't want to rewrite unrelated tokens. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 28, 2020 at 20:37 UTC
d70a9eb611a9d242c1d26847d223b8677609305b
52 files changed
+186
-186
add-interactive.c
+2
-2
@@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
944
files->items.items[i].string);
945
parse_pathspec(&ps_selected,
946
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
947
- PATHSPEC_LITERAL_PATH, "", args.argv);
947
+ PATHSPEC_LITERAL_PATH, "", args.v);
948
res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
949
strvec_clear(&args);
950
clear_pathspec(&ps_selected);
@@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
986
if (files->selected[i])
987
strvec_push(&args,
988
files->items.items[i].string);
989
- res = run_command_v_opt(args.argv, 0);
989
+ res = run_command_v_opt(args.v, 0);
990
strvec_clear(&args);
991
}
992
add-patch.c
+4
-4
@@ -391,14 +391,14 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
391
get_oid("HEAD", &oid) ?
392
empty_tree_oid_hex() : s->revision);
393
}
394
- color_arg_index = args.argc;
394
+ color_arg_index = args.nr;
395
/* Use `--no-color` explicitly, just in case `diff.color = always`. */
396
strvec_pushl(&args, "--no-color", "-p", "--", NULL);
397
for (i = 0; i < ps->nr; i++)
398
strvec_push(&args, ps->items[i].original);
399
400
setup_child_process(s, &cp, NULL);
401
- cp.argv = args.argv;
401
+ cp.argv = args.v;
402
res = capture_command(&cp, plain, 0);
403
if (res) {
404
strvec_clear(&args);
@@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
415
const char *diff_filter = s->s.interactive_diff_filter;
416
417
setup_child_process(s, &colored_cp, NULL);
418
- xsnprintf((char *)args.argv[color_arg_index], 8, "--color");
419
- colored_cp.argv = args.argv;
418
+ xsnprintf((char *)args.v[color_arg_index], 8, "--color");
419
+ colored_cp.argv = args.v;
420
colored = &s->colored;
421
res = capture_command(&colored_cp, colored, 0);
422
strvec_clear(&args);
bisect.c
+1
-1
@@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
649
if (read_paths)
650
read_bisect_paths(&rev_argv);
651
652
- setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL);
652
+ setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL);
653
/* XXX leak rev_argv, as "revs" may still be pointing to it */
654
}
655
builtin/add.c
+1
-1
@@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
228
/* pass original pathspec, to be re-parsed */
229
strvec_push(&argv, pathspec->items[i].original);
230
231
- status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
231
+ status = run_command_v_opt(argv.v, RUN_GIT_CMD);
232
strvec_clear(&argv);
233
return status;
234
}
builtin/am.c
+8
-8
@@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
812
strbuf_release(&sb);
813
free(series_dir_buf);
814
815
- ret = split_mail_conv(stgit_patch_to_mail, state, patches.argv, keep_cr);
815
+ ret = split_mail_conv(stgit_patch_to_mail, state, patches.v, keep_cr);
816
817
strvec_clear(&patches);
818
return ret;
@@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
1002
}
1003
write_state_text(state, "scissors", str);
1004
1005
- sq_quote_argv(&sb, state->git_apply_opts.argv);
1005
+ sq_quote_argv(&sb, state->git_apply_opts.v);
1006
write_state_text(state, "apply-opt", sb.buf);
1007
1008
if (state->rebasing)
@@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file)
1401
BUG("init_apply_state() failed");
1402
1403
strvec_push(&apply_opts, "apply");
1404
- strvec_pushv(&apply_opts, state->git_apply_opts.argv);
1404
+ strvec_pushv(&apply_opts, state->git_apply_opts.v);
1405
1406
- opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
1406
+ opts_left = apply_parse_options(apply_opts.nr, apply_opts.v,
1407
&apply_state, &force_apply, &options,
1408
NULL);
1409
@@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
1428
1429
strvec_push(&apply_paths, am_path(state, "patch"));
1430
1431
- res = apply_all_patches(&apply_state, apply_paths.argc, apply_paths.argv, options);
1431
+ res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.v, options);
1432
1433
strvec_clear(&apply_paths);
1434
strvec_clear(&apply_opts);
@@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
1455
1456
cp.git_cmd = 1;
1457
strvec_push(&cp.args, "apply");
1458
- strvec_pushv(&cp.args, state->git_apply_opts.argv);
1458
+ strvec_pushv(&cp.args, state->git_apply_opts.v);
1459
strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
1460
strvec_push(&cp.args, am_path(state, "patch"));
1461
@@ -2376,10 +2376,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2376
strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
2377
}
2378
2379
- if (state.interactive && !paths.argc)
2379
+ if (state.interactive && !paths.nr)
2380
die(_("interactive mode requires patches on the command line"));
2381
2382
- am_setup(&state, patch_format, paths.argv, keep_cr);
2382
+ am_setup(&state, patch_format, paths.v, keep_cr);
2383
2384
strvec_clear(&paths);
2385
}
builtin/annotate.c
+1
-1
@@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
18
strvec_push(&args, argv[i]);
19
}
20
21
- return cmd_blame(args.argc, args.argv, prefix);
21
+ return cmd_blame(args.nr, args.v, prefix);
22
}
builtin/bisect--helper.c
+2
-2
@@ -168,7 +168,7 @@ static int bisect_reset(const char *commit)
168
struct strvec argv = STRVEC_INIT;
169
170
strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
171
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
171
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
172
error(_("could not check out original"
173
" HEAD '%s'. Try 'git bisect"
174
" reset <commit>'."), branch.buf);
@@ -530,7 +530,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
530
531
strvec_pushl(&argv, "checkout", start_head.buf,
532
"--", NULL);
533
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
533
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
534
res = error(_("checking out '%s' failed."
535
" Try 'git bisect start "
536
"<valid-branch>'."),
builtin/clone.c
+2
-2
@@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo)
752
*/
753
core_apply_sparse_checkout = 1;
754
755
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
755
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
756
error(_("failed to initialize sparse-checkout"));
757
result = 1;
758
}
@@ -844,7 +844,7 @@ static int checkout(int submodule_progress)
844
"--single-branch" :
845
"--no-single-branch");
846
847
- err = run_command_v_opt(args.argv, RUN_GIT_CMD);
847
+ err = run_command_v_opt(args.v, RUN_GIT_CMD);
848
strvec_clear(&args);
849
}
850
builtin/commit.c
+1
-1
@@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1008
struct strvec env = STRVEC_INIT;
1009
1010
strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
1011
- if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
1011
+ if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
1012
fprintf(stderr,
1013
_("Please supply the message using either -m or -F option.\n"));
1014
exit(1);
builtin/describe.c
+3
-3
@@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
509
NULL);
510
511
repo_init_revisions(the_repository, &revs, NULL);
512
- if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
512
+ if (setup_revisions(args.nr, args.v, &revs, NULL) > 1)
513
BUG("setup_revisions could not handle all args?");
514
515
if (prepare_revision_walk(&revs))
@@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
613
strvec_pushv(&args, argv);
614
else
615
strvec_push(&args, "HEAD");
616
- return cmd_name_rev(args.argc, args.argv, prefix);
616
+ return cmd_name_rev(args.nr, args.v, prefix);
617
}
618
619
hashmap_init(&names, commit_name_neq, NULL, 0);
@@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
659
660
repo_init_revisions(the_repository, &revs, prefix);
661
strvec_pushv(&args, diff_index_args);
662
- if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
662
+ if (setup_revisions(args.nr, args.v, &revs, NULL) != 1)
663
BUG("malformed internal diff-index command line");
664
result = run_diff_index(&revs, 0);
665
builtin/difftool.c
+1
-1
@@ -683,7 +683,7 @@ static int run_file_diff(int prompt, const char *prefix,
683
strvec_push(&args, "diff");
684
for (i = 0; i < argc; i++)
685
strvec_push(&args, argv[i]);
686
- ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
686
+ ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
687
exit(ret);
688
}
689
builtin/fetch.c
+3
-3
@@ -1354,7 +1354,7 @@ static int do_fetch(struct transport *transport,
1354
1355
if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
1356
must_list_refs = 1;
1357
- if (ref_prefixes.argc)
1357
+ if (ref_prefixes.nr)
1358
strvec_push(&ref_prefixes, "refs/tags/");
1359
}
1360
@@ -1605,7 +1605,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
1605
add_options_to_argv(&argv);
1606
1607
if (max_children != 1 && list->nr != 1) {
1608
- struct parallel_fetch_state state = { argv.argv, list, 0, 0 };
1608
+ struct parallel_fetch_state state = { argv.v, list, 0, 0 };
1609
1610
strvec_push(&argv, "--end-of-options");
1611
result = run_processes_parallel_tr2(max_children,
@@ -1623,7 +1623,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
1623
strvec_push(&argv, name);
1624
if (verbosity >= 0)
1625
printf(_("Fetching %s\n"), name);
1626
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
1626
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
1627
error(_("Could not fetch %s"), name);
1628
result = 1;
1629
}
builtin/gc.c
+12
-12
@@ -514,11 +514,11 @@ static void gc_before_repack(void)
514
if (done++)
515
return;
516
517
- if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD))
518
- die(FAILED_RUN, pack_refs_cmd.argv[0]);
517
+ if (pack_refs && run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD))
518
+ die(FAILED_RUN, pack_refs_cmd.v[0]);
519
520
- if (prune_reflogs && run_command_v_opt(reflog.argv, RUN_GIT_CMD))
521
- die(FAILED_RUN, reflog.argv[0]);
520
+ if (prune_reflogs && run_command_v_opt(reflog.v, RUN_GIT_CMD))
521
+ die(FAILED_RUN, reflog.v[0]);
522
}
523
524
int cmd_gc(int argc, const char **argv, const char *prefix)
@@ -653,8 +653,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
653
654
if (!repository_format_precious_objects) {
655
close_object_store(the_repository->objects);
656
- if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
657
- die(FAILED_RUN, repack.argv[0]);
656
+ if (run_command_v_opt(repack.v, RUN_GIT_CMD))
657
+ die(FAILED_RUN, repack.v[0]);
658
659
if (prune_expire) {
660
strvec_push(&prune, prune_expire);
@@ -663,19 +663,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
663
if (has_promisor_remote())
664
strvec_push(&prune,
665
"--exclude-promisor-objects");
666
- if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
667
- die(FAILED_RUN, prune.argv[0]);
666
+ if (run_command_v_opt(prune.v, RUN_GIT_CMD))
667
+ die(FAILED_RUN, prune.v[0]);
668
}
669
}
670
671
if (prune_worktrees_expire) {
672
strvec_push(&prune_worktrees, prune_worktrees_expire);
673
- if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD))
674
- die(FAILED_RUN, prune_worktrees.argv[0]);
673
+ if (run_command_v_opt(prune_worktrees.v, RUN_GIT_CMD))
674
+ die(FAILED_RUN, prune_worktrees.v[0]);
675
}
676
677
- if (run_command_v_opt(rerere.argv, RUN_GIT_CMD))
678
- die(FAILED_RUN, rerere.argv[0]);
677
+ if (run_command_v_opt(rerere.v, RUN_GIT_CMD))
678
+ die(FAILED_RUN, rerere.v[0]);
679
680
report_garbage = report_pack_garbage;
681
reprepare_packed_git(the_repository);
builtin/pack-objects.c
+1
-1
@@ -3704,7 +3704,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3704
if (!use_internal_rev_list)
3705
read_object_list_from_stdin();
3706
else {
3707
- get_object_list(rp.argc, rp.argv);
3707
+ get_object_list(rp.nr, rp.v);
3708
strvec_clear(&rp);
3709
}
3710
cleanup_preferred_base();
builtin/pull.c
+8
-8
@@ -584,14 +584,14 @@ static int run_fetch(const char *repo, const char **refspecs)
584
strvec_push(&args, "--no-show-forced-updates");
585
if (set_upstream)
586
strvec_push(&args, set_upstream);
587
- strvec_pushv(&args, opt_fetch.argv);
587
+ strvec_pushv(&args, opt_fetch.v);
588
589
if (repo) {
590
strvec_push(&args, repo);
591
strvec_pushv(&args, refspecs);
592
} else if (*refspecs)
593
BUG("refspecs without repo?");
594
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
594
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
595
strvec_clear(&args);
596
return ret;
597
}
@@ -691,8 +691,8 @@ static int run_merge(void)
691
strvec_push(&args, opt_ff);
692
if (opt_verify_signatures)
693
strvec_push(&args, opt_verify_signatures);
694
- strvec_pushv(&args, opt_strategies.argv);
695
- strvec_pushv(&args, opt_strategy_opts.argv);
694
+ strvec_pushv(&args, opt_strategies.v);
695
+ strvec_pushv(&args, opt_strategy_opts.v);
696
if (opt_gpg_sign)
697
strvec_push(&args, opt_gpg_sign);
698
if (opt_autostash == 0)
@@ -703,7 +703,7 @@ static int run_merge(void)
703
strvec_push(&args, "--allow-unrelated-histories");
704
705
strvec_push(&args, "FETCH_HEAD");
706
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
706
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
707
strvec_clear(&args);
708
return ret;
709
}
@@ -882,8 +882,8 @@ static int run_rebase(const struct object_id *curr_head,
882
strvec_push(&args, "--interactive");
883
if (opt_diffstat)
884
strvec_push(&args, opt_diffstat);
885
- strvec_pushv(&args, opt_strategies.argv);
886
- strvec_pushv(&args, opt_strategy_opts.argv);
885
+ strvec_pushv(&args, opt_strategies.v);
886
+ strvec_pushv(&args, opt_strategy_opts.v);
887
if (opt_gpg_sign)
888
strvec_push(&args, opt_gpg_sign);
889
if (opt_autostash == 0)
@@ -902,7 +902,7 @@ static int run_rebase(const struct object_id *curr_head,
902
else
903
strvec_push(&args, oid_to_hex(merge_head));
904
905
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
905
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
906
strvec_clear(&args);
907
return ret;
908
}
builtin/rebase.c
+8
-8
@@ -351,7 +351,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
351
oid_to_hex(&opts->restrict_revision->object.oid));
352
353
ret = sequencer_make_script(the_repository, &todo_list.buf,
354
- make_script_args.argc, make_script_args.argv,
354
+ make_script_args.nr, make_script_args.v,
355
flags);
356
357
if (ret)
@@ -900,7 +900,7 @@ static int run_am(struct rebase_options *opts)
900
return status;
901
}
902
903
- strvec_pushv(&am.args, opts->git_am_opts.argv);
903
+ strvec_pushv(&am.args, opts->git_am_opts.v);
904
strvec_push(&am.args, "--rebasing");
905
strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
906
strvec_push(&am.args, "--patch-format=mboxrd");
@@ -969,7 +969,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
969
add_var(&script_snippet, "revisions", opts->revisions);
970
add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
971
oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
972
- sq_quote_argv_pretty(&buf, opts->git_am_opts.argv);
972
+ sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
973
add_var(&script_snippet, "git_am_opt", buf.buf);
974
strbuf_release(&buf);
975
add_var(&script_snippet, "verbose",
@@ -1625,8 +1625,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1625
allow_preemptive_ff = 0;
1626
}
1627
1628
- for (i = 0; i < options.git_am_opts.argc; i++) {
1629
- const char *option = options.git_am_opts.argv[i], *p;
1628
+ for (i = 0; i < options.git_am_opts.nr; i++) {
1629
+ const char *option = options.git_am_opts.v[i], *p;
1630
if (!strcmp(option, "--committer-date-is-author-date") ||
1631
!strcmp(option, "--ignore-date") ||
1632
!strcmp(option, "--whitespace=fix") ||
@@ -1721,10 +1721,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1721
if (isatty(2) && options.flags & REBASE_NO_QUIET)
1722
strbuf_addstr(&options.git_format_patch_opt, " --progress");
1723
1724
- if (options.git_am_opts.argc || options.type == REBASE_APPLY) {
1724
+ if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
1725
/* all am options except -q are compatible only with --apply */
1726
- for (i = options.git_am_opts.argc - 1; i >= 0; i--)
1727
- if (strcmp(options.git_am_opts.argv[i], "-q"))
1726
+ for (i = options.git_am_opts.nr - 1; i >= 0; i--)
1727
+ if (strcmp(options.git_am_opts.v[i], "-q"))
1728
break;
1729
1730
if (i >= 0) {
builtin/receive-pack.c
+7
-7
@@ -950,7 +950,7 @@ static const char *push_to_deploy(unsigned char *sha1,
950
struct child_process child = CHILD_PROCESS_INIT;
951
952
child.argv = update_refresh;
953
- child.env = env->argv;
953
+ child.env = env->v;
954
child.dir = work_tree;
955
child.no_stdin = 1;
956
child.stdout_to_stderr = 1;
@@ -961,7 +961,7 @@ static const char *push_to_deploy(unsigned char *sha1,
961
/* run_command() does not clean up completely; reinitialize */
962
child_process_init(&child);
963
child.argv = diff_files;
964
- child.env = env->argv;
964
+ child.env = env->v;
965
child.dir = work_tree;
966
child.no_stdin = 1;
967
child.stdout_to_stderr = 1;
@@ -974,7 +974,7 @@ static const char *push_to_deploy(unsigned char *sha1,
974
975
child_process_init(&child);
976
child.argv = diff_index;
977
- child.env = env->argv;
977
+ child.env = env->v;
978
child.no_stdin = 1;
979
child.no_stdout = 1;
980
child.stdout_to_stderr = 0;
@@ -985,7 +985,7 @@ static const char *push_to_deploy(unsigned char *sha1,
985
read_tree[3] = hash_to_hex(sha1);
986
child_process_init(&child);
987
child.argv = read_tree;
988
- child.env = env->argv;
988
+ child.env = env->v;
989
child.dir = work_tree;
990
child.no_stdin = 1;
991
child.no_stdout = 1;
@@ -1004,7 +1004,7 @@ static const char *push_to_checkout(unsigned char *hash,
1004
const char *work_tree)
1005
{
1006
strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1007
- if (run_hook_le(env->argv, push_to_checkout_hook,
1007
+ if (run_hook_le(env->v, push_to_checkout_hook,
1008
hash_to_hex(hash), NULL))
1009
return "push-to-checkout hook declined";
1010
else
@@ -1205,11 +1205,11 @@ static void run_update_post_hook(struct command *commands)
1205
for (cmd = commands; cmd; cmd = cmd->next) {
1206
if (cmd->error_string || cmd->did_not_exist)
1207
continue;
1208
- if (!proc.args.argc)
1208
+ if (!proc.args.nr)
1209
strvec_push(&proc.args, hook);
1210
strvec_push(&proc.args, cmd->ref_name);
1211
}
1212
- if (!proc.args.argc)
1212
+ if (!proc.args.nr)
1213
return;
1214
1215
proc.no_stdin = 1;
builtin/remote.c
+2
-2
@@ -1470,7 +1470,7 @@ static int update(int argc, const char **argv)
1470
for (i = 1; i < argc; i++)
1471
strvec_push(&fetch_argv, argv[i]);
1472
1473
- if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
1473
+ if (strcmp(fetch_argv.v[fetch_argv.nr-1], "default") == 0) {
1474
git_config(get_remote_default, &default_defined);
1475
if (!default_defined) {
1476
strvec_pop(&fetch_argv);
@@ -1478,7 +1478,7 @@ static int update(int argc, const char **argv)
1478
}
1479
}
1480
1481
- retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
1481
+ retval = run_command_v_opt(fetch_argv.v, RUN_GIT_CMD);
1482
strvec_clear(&fetch_argv);
1483
return retval;
1484
}
builtin/replace.c
+1
-1
@@ -513,7 +513,7 @@ static int convert_graft_file(int force)
513
continue;
514
515
strvec_split(&args, buf.buf);
516
- if (args.argc && create_graft(args.argc, args.argv, force, 1))
516
+ if (args.nr && create_graft(args.nr, args.v, force, 1))
517
strbuf_addf(&err, "\n\t%s", buf.buf);
518
strvec_clear(&args);
519
}
builtin/show-branch.c
+4
-4
@@ -561,7 +561,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
561
* default_arg is now passed to parse_options(), so we need to
562
* mimic the real argv a bit better.
563
*/
564
- if (!default_args.argc)
564
+ if (!default_args.nr)
565
strvec_push(&default_args, "show-branch");
566
strvec_push(&default_args, value);
567
return 0;
@@ -684,9 +684,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
684
git_config(git_show_branch_config, NULL);
685
686
/* If nothing is specified, try the default first */
687
- if (ac == 1 && default_args.argc) {
688
- ac = default_args.argc;
689
- av = default_args.argv;
687
+ if (ac == 1 && default_args.nr) {
688
+ ac = default_args.nr;
689
+ av = default_args.v;
690
}
691
692
ac = parse_options(ac, av, prefix, builtin_show_branch_options,
builtin/stash.c
+4
-4
@@ -745,7 +745,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
745
strvec_push(&revision_args, argv[i]);
746
}
747
748
- ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
748
+ ret = get_stash_info(&info, stash_args.nr, stash_args.v);
749
strvec_clear(&stash_args);
750
if (ret)
751
return -1;
@@ -754,7 +754,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
754
* The config settings are applied only if there are not passed
755
* any options.
756
*/
757
- if (revision_args.argc == 1) {
757
+ if (revision_args.nr == 1) {
758
if (show_stat)
759
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT;
760
@@ -767,7 +767,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
767
}
768
}
769
770
- argc = setup_revisions(revision_args.argc, revision_args.argv, &rev, NULL);
770
+ argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
771
if (argc > 1) {
772
free_stash_info(&info);
773
usage_with_options(git_stash_show_usage, options);
@@ -1611,5 +1611,5 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
1611
/* Assume 'stash push' */
1612
strvec_push(&args, "push");
1613
strvec_pushv(&args, argv);
1614
- return !!push_stash(args.argc, args.argv, prefix, 1);
1614
+ return !!push_stash(args.nr, args.v, prefix, 1);
1615
}
builtin/submodule--helper.c
+3
-3
@@ -817,9 +817,9 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
817
818
repo_init_revisions(the_repository, &rev, NULL);
819
rev.abbrev = 0;
820
- diff_files_args.argc = setup_revisions(diff_files_args.argc,
821
- diff_files_args.argv,
822
- &rev, NULL);
820
+ diff_files_args.nr = setup_revisions(diff_files_args.nr,
821
+ diff_files_args.v,
822
+ &rev, NULL);
823
diff_files_result = run_diff_files(&rev, 0);
824
825
if (!diff_result_code(&rev.diffopt, diff_files_result)) {
builtin/upload-archive.c
+2
-2
@@ -36,7 +36,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
36
char *buf = packet_read_line(0, NULL);
37
if (!buf)
38
break; /* got a flush */
39
- if (sent_argv.argc > MAX_ARGS)
39
+ if (sent_argv.nr > MAX_ARGS)
40
die("Too many options (>%d)", MAX_ARGS - 1);
41
42
if (!starts_with(buf, arg_cmd))
@@ -45,7 +45,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
45
}
46
47
/* parse all options sent by the client */
48
- return write_archive(sent_argv.argc, sent_argv.argv, prefix,
48
+ return write_archive(sent_argv.nr, sent_argv.v, prefix,
49
the_repository, NULL, 1);
50
}
51
builtin/worktree.c
+3
-3
@@ -422,7 +422,7 @@ static int add_worktree(const char *path, const char *refname,
422
strvec_push(&cp.args, "--quiet");
423
}
424
425
- cp.env = child_env.argv;
425
+ cp.env = child_env.v;
426
ret = run_command(&cp);
427
if (ret)
428
goto done;
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,
433
strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
434
if (opts->quiet)
435
strvec_push(&cp.args, "--quiet");
436
- cp.env = child_env.argv;
436
+ cp.env = child_env.v;
437
ret = run_command(&cp);
438
if (ret)
439
goto done;
@@ -943,7 +943,7 @@ static void check_clean_worktree(struct worktree *wt,
943
strvec_pushl(&cp.args, "status",
944
"--porcelain", "--ignore-submodules=none",
945
NULL);
946
- cp.env = child_env.argv;
946
+ cp.env = child_env.v;
947
cp.git_cmd = 1;
948
cp.dir = wt->path;
949
cp.out = -1;
bundle.c
+1
-1
@@ -278,7 +278,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *
278
"pack-objects",
279
"--stdout", "--thin", "--delta-base-offset",
280
NULL);
281
- strvec_pushv(&pack_objects.args, pack_options->argv);
281
+ strvec_pushv(&pack_objects.args, pack_options->v);
282
pack_objects.in = -1;
283
pack_objects.out = bundle_fd;
284
pack_objects.git_cmd = 1;
commit.c
+1
-1
@@ -1643,7 +1643,7 @@ int run_commit_hook(int editor_is_used, const char *index_file,
1643
strvec_push(&hook_env, "GIT_EDITOR=:");
1644
1645
va_start(args, name);
1646
- ret = run_hook_ve(hook_env.argv,name, args);
1646
+ ret = run_hook_ve(hook_env.v, name, args);
1647
va_end(args);
1648
strvec_clear(&hook_env);
1649
connect.c
+8
-8
@@ -70,9 +70,9 @@ int server_supports_v2(const char *c, int die_on_error)
70
{
71
int i;
72
73
- for (i = 0; i < server_capabilities_v2.argc; i++) {
73
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
74
const char *out;
75
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
75
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
76
(!*out || *out == '='))
77
return 1;
78
}
@@ -87,9 +87,9 @@ int server_feature_v2(const char *c, const char **v)
87
{
88
int i;
89
90
- for (i = 0; i < server_capabilities_v2.argc; i++) {
90
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
91
const char *out;
92
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
92
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
93
(*out == '=')) {
94
*v = out + 1;
95
return 1;
@@ -103,9 +103,9 @@ int server_supports_feature(const char *c, const char *feature,
103
{
104
int i;
105
106
- for (i = 0; i < server_capabilities_v2.argc; i++) {
106
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
107
const char *out;
108
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
108
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
109
(!*out || *(out++) == '=')) {
110
if (parse_feature_request(out, feature))
111
return 1;
@@ -488,9 +488,9 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
488
if (!for_push)
489
packet_write_fmt(fd_out, "peel\n");
490
packet_write_fmt(fd_out, "symrefs\n");
491
- for (i = 0; ref_prefixes && i < ref_prefixes->argc; i++) {
491
+ for (i = 0; ref_prefixes && i < ref_prefixes->nr; i++) {
492
packet_write_fmt(fd_out, "ref-prefix %s\n",
493
- ref_prefixes->argv[i]);
493
+ ref_prefixes->v[i]);
494
}
495
packet_flush(fd_out);
496
daemon.c
+4
-4
@@ -482,7 +482,7 @@ static int upload_pack(const struct strvec *env)
482
strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
483
strvec_pushf(&cld.args, "--timeout=%u", timeout);
484
485
- strvec_pushv(&cld.env_array, env->argv);
485
+ strvec_pushv(&cld.env_array, env->v);
486
487
return run_service_command(&cld);
488
}
@@ -492,7 +492,7 @@ static int upload_archive(const struct strvec *env)
492
struct child_process cld = CHILD_PROCESS_INIT;
493
strvec_push(&cld.args, "upload-archive");
494
495
- strvec_pushv(&cld.env_array, env->argv);
495
+ strvec_pushv(&cld.env_array, env->v);
496
497
return run_service_command(&cld);
498
}
@@ -502,7 +502,7 @@ static int receive_pack(const struct strvec *env)
502
struct child_process cld = CHILD_PROCESS_INIT;
503
strvec_push(&cld.args, "receive-pack");
504
505
- strvec_pushv(&cld.env_array, env->argv);
505
+ strvec_pushv(&cld.env_array, env->v);
506
507
return run_service_command(&cld);
508
}
@@ -927,7 +927,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
927
#endif
928
}
929
930
- cld.argv = cld_argv.argv;
930
+ cld.argv = cld_argv.v;
931
cld.in = incoming;
932
cld.out = dup(incoming);
933
diff.c
+1
-1
@@ -4239,7 +4239,7 @@ static void run_external_diff(const char *pgm,
4239
4240
diff_free_filespec_data(one);
4241
diff_free_filespec_data(two);
4242
- if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
4242
+ if (run_command_v_opt_cd_env(argv.v, RUN_USING_SHELL, NULL, env.v))
4243
die(_("external diff died, stopping at %s"), name);
4244
4245
remove_tempfile();
environment.c
+1
-1
@@ -164,7 +164,7 @@ static const char *getenv_safe(struct strvec *argv, const char *name)
164
return NULL;
165
166
strvec_push(argv, value);
167
- return argv->argv[argv->argc - 1];
167
+ return argv->v[argv->nr - 1];
168
}
169
170
void setup_git_env(const char *git_dir)
exec-cmd.c
+3
-3
@@ -324,7 +324,7 @@ const char **prepare_git_cmd(struct strvec *out, const char **argv)
324
{
325
strvec_push(out, "git");
326
strvec_pushv(out, argv);
327
- return out->argv;
327
+ return out->v;
328
}
329
330
int execv_git_cmd(const char **argv)
@@ -332,10 +332,10 @@ int execv_git_cmd(const char **argv)
332
struct strvec nargv = STRVEC_INIT;
333
334
prepare_git_cmd(&nargv, argv);
335
- trace_argv_printf(nargv.argv, "trace: exec:");
335
+ trace_argv_printf(nargv.v, "trace: exec:");
336
337
/* execvp() can only ever return if it fails */
338
- sane_execvp("git", (char **)nargv.argv);
338
+ sane_execvp("git", (char **)nargv.v);
339
340
trace_printf("trace: exec failed: %s\n", strerror(errno));
341
git.c
+5
-5
@@ -352,7 +352,7 @@ static int handle_alias(int *argcp, const char ***argv)
352
strvec_push(&child.args, alias_string + 1);
353
strvec_pushv(&child.args, (*argv) + 1);
354
355
- trace2_cmd_alias(alias_command, child.args.argv);
355
+ trace2_cmd_alias(alias_command, child.args.v);
356
trace2_cmd_list_config();
357
trace2_cmd_list_env_vars();
358
trace2_cmd_name("_run_shell_alias_");
@@ -667,7 +667,7 @@ static void handle_builtin(int argc, const char **argv)
667
}
668
669
argc++;
670
- argv = args.argv;
670
+ argv = args.v;
671
}
672
673
builtin = get_builtin(cmd);
@@ -701,7 +701,7 @@ static void execv_dashed_external(const char **argv)
701
* The code in run_command() logs trace2 child_start/child_exit
702
* events, so we do not need to report exec/exec_result events here.
703
*/
704
- trace_argv_printf(cmd.args.argv, "trace: exec:");
704
+ trace_argv_printf(cmd.args.v, "trace: exec:");
705
706
/*
707
* If we fail because the command is not found, it is
@@ -762,13 +762,13 @@ static int run_argv(int *argcp, const char ***argv)
762
for (i = 0; i < *argcp; i++)
763
strvec_push(&args, (*argv)[i]);
764
765
- trace_argv_printf(args.argv, "trace: exec:");
765
+ trace_argv_printf(args.v, "trace: exec:");
766
767
/*
768
* if we fail because the command is not found, it is
769
* OK to return. Otherwise, we just pass along the status code.
770
*/
771
- i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE |
771
+ i = run_command_v_opt_tr2(args.v, RUN_SILENT_EXEC_FAILURE |
772
RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias");
773
if (i >= 0 || errno != ENOENT)
774
exit(i);
graph.c
+2
-2
@@ -355,8 +355,8 @@ struct git_graph *graph_init(struct rev_info *opt)
355
parse_graph_colors_config(&custom_colors, string);
356
free(string);
357
/* graph_set_column_colors takes a max-index, not a count */
358
- graph_set_column_colors(custom_colors.argv,
359
- custom_colors.argc - 1);
358
+ graph_set_column_colors(custom_colors.v,
359
+ custom_colors.nr - 1);
360
}
361
}
362
http-push.c
+1
-1
@@ -1931,7 +1931,7 @@ int cmd_main(int argc, const char **argv)
1931
strvec_pushf(&commit_argv, "^%s",
1932
oid_to_hex(&ref->old_oid));
1933
repo_init_revisions(the_repository, &revs, setup_git_directory());
1934
- setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
1934
+ setup_revisions(commit_argv.nr, commit_argv.v, &revs, NULL);
1935
revs.edge_hint = 0; /* just in case */
1936
1937
/* Generate a list of objects that need to be pushed */
ls-refs.c
+3
-3
@@ -15,11 +15,11 @@ static int ref_match(const struct strvec *prefixes, const char *refname)
15
{
16
int i;
17
18
- if (!prefixes->argc)
18
+ if (!prefixes->nr)
19
return 1; /* no restriction */
20
21
- for (i = 0; i < prefixes->argc; i++) {
22
- const char *prefix = prefixes->argv[i];
21
+ for (i = 0; i < prefixes->nr; i++) {
22
+ const char *prefix = prefixes->v[i];
23
24
if (starts_with(refname, prefix))
25
return 1;
merge.c
+1
-1
@@ -33,7 +33,7 @@ int try_merge_command(struct repository *r,
33
for (j = remotes; j; j = j->next)
34
strvec_push(&args, merge_argument(j->item));
35
36
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
36
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
37
strvec_clear(&args);
38
39
discard_index(r->index);
pathspec.c
+1
-1
@@ -652,7 +652,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
652
if (in != stdin)
653
fclose(in);
654
655
- parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
655
+ parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.v);
656
strvec_clear(&parsed_file);
657
}
658
range-diff.c
+1
-1
@@ -67,7 +67,7 @@ static int read_patches(const char *range, struct string_list *list,
67
"--notes",
68
NULL);
69
if (other_arg)
70
- strvec_pushv(&cp.args, other_arg->argv);
70
+ strvec_pushv(&cp.args, other_arg->v);
71
strvec_push(&cp.args, range);
72
cp.out = -1;
73
cp.no_stdin = 1;
ref-filter.c
+2
-2
@@ -1918,9 +1918,9 @@ static void find_longest_prefixes(struct string_list *out,
1918
struct strbuf prefix = STRBUF_INIT;
1919
1920
strvec_pushv(&sorted, patterns);
1921
- QSORT(sorted.argv, sorted.argc, qsort_strcmp);
1921
+ QSORT(sorted.v, sorted.nr, qsort_strcmp);
1922
1923
- find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
1923
+ find_longest_prefixes_1(out, &prefix, sorted.v, sorted.nr);
1924
1925
strvec_clear(&sorted);
1926
strbuf_release(&prefix);
remote-curl.c
+3
-3
@@ -1190,7 +1190,7 @@ static int fetch_git(struct discovery *heads,
1190
rpc.service_name = "git-upload-pack",
1191
rpc.gzip_request = 1;
1192
1193
- err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result);
1193
+ err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
1194
if (rpc_result.len)
1195
write_or_die(1, rpc_result.buf, rpc_result.len);
1196
strbuf_release(&rpc_result);
@@ -1325,7 +1325,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1325
memset(&rpc, 0, sizeof(rpc));
1326
rpc.service_name = "git-receive-pack",
1327
1328
- err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result);
1328
+ err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
1329
if (rpc_result.len)
1330
write_or_die(1, rpc_result.buf, rpc_result.len);
1331
strbuf_release(&rpc_result);
@@ -1366,7 +1366,7 @@ static void parse_push(struct strbuf *buf)
1366
break;
1367
} while (1);
1368
1369
- ret = push(specs.argc, specs.argv);
1369
+ ret = push(specs.nr, specs.v);
1370
printf("\n");
1371
fflush(stdout);
1372
remote.c
+1
-1
@@ -1919,7 +1919,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
1919
strvec_push(&argv, "--");
1920
1921
repo_init_revisions(the_repository, &revs, NULL);
1922
- setup_revisions(argv.argc, argv.argv, &revs, NULL);
1922
+ setup_revisions(argv.nr, argv.v, &revs, NULL);
1923
if (prepare_revision_walk(&revs))
1924
die(_("revision walk setup failed"));
1925
revision.c
+2
-2
@@ -2767,7 +2767,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2767
got_rev_arg = 1;
2768
}
2769
2770
- if (prune_data.argc) {
2770
+ if (prune_data.nr) {
2771
/*
2772
* If we need to introduce the magic "a lone ':' means no
2773
* pathspec whatsoever", here is the place to do so.
@@ -2783,7 +2783,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2783
* }
2784
*/
2785
parse_pathspec(&revs->prune_data, 0, 0,
2786
- revs->prefix, prune_data.argv);
2786
+ revs->prefix, prune_data.v);
2787
}
2788
strvec_clear(&prune_data);
2789
run-command.c
+10
-10
@@ -287,7 +287,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
287
}
288
289
strvec_pushv(out, argv);
290
- return out->argv;
290
+ return out->v;
291
}
292
293
#ifndef GIT_WINDOWS_NATIVE
@@ -426,11 +426,11 @@ static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
426
* there are dir separator characters, we have exec attempt to invoke
427
* the command directly.
428
*/
429
- if (!has_dir_sep(out->argv[1])) {
430
- char *program = locate_in_PATH(out->argv[1]);
429
+ if (!has_dir_sep(out->v[1])) {
430
+ char *program = locate_in_PATH(out->v[1]);
431
if (program) {
432
- free((char *)out->argv[1]);
433
- out->argv[1] = program;
432
+ free((char *)out->v[1]);
433
+ out->v[1] = program;
434
} else {
435
strvec_clear(out);
436
errno = ENOENT;
@@ -672,9 +672,9 @@ int start_command(struct child_process *cmd)
672
char *str;
673
674
if (!cmd->argv)
675
- cmd->argv = cmd->args.argv;
675
+ cmd->argv = cmd->args.v;
676
if (!cmd->env)
677
- cmd->env = cmd->env_array.argv;
677
+ cmd->env = cmd->env_array.v;
678
679
/*
680
* In case of errors we must keep the promise to close FDs
@@ -846,10 +846,10 @@ fail_pipe:
846
* be used in the event exec failed with ENOEXEC at which point
847
* we will try to interpret the command using 'sh'.
848
*/
849
- execve(argv.argv[1], (char *const *) argv.argv + 1,
849
+ execve(argv.v[1], (char *const *) argv.v + 1,
850
(char *const *) childenv);
851
if (errno == ENOEXEC)
852
- execve(argv.argv[0], (char *const *) argv.argv,
852
+ execve(argv.v[0], (char *const *) argv.v,
853
(char *const *) childenv);
854
855
if (errno == ENOENT) {
@@ -1874,7 +1874,7 @@ int run_auto_gc(int quiet)
1874
strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
1875
if (quiet)
1876
strvec_push(&argv_gc_auto, "--quiet");
1877
- status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
1877
+ status = run_command_v_opt(argv_gc_auto.v, RUN_GIT_CMD);
1878
strvec_clear(&argv_gc_auto);
1879
return status;
1880
}
sequencer.c
+2
-2
@@ -2761,7 +2761,7 @@ static int reset_merge(const struct object_id *oid)
2761
if (!is_null_oid(oid))
2762
strvec_push(&argv, oid_to_hex(oid));
2763
2764
- ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
2764
+ ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
2765
strvec_clear(&argv);
2766
2767
return ret;
@@ -3135,7 +3135,7 @@ static int do_exec(struct repository *r, const char *command_line)
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);
3138
+ child_env.v);
3139
3140
/* force re-reading of the cache */
3141
if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
serve.c
+3
-3
@@ -146,9 +146,9 @@ int has_capability(const struct strvec *keys, const char *capability,
146
const char **value)
147
{
148
int i;
149
- for (i = 0; i < keys->argc; i++) {
149
+ for (i = 0; i < keys->nr; i++) {
150
const char *out;
151
- if (skip_prefix(keys->argv[i], capability, &out) &&
151
+ if (skip_prefix(keys->v[i], capability, &out) &&
152
(!*out || *out == '=')) {
153
if (value) {
154
if (*out == '=')
@@ -223,7 +223,7 @@ static int process_request(void)
223
* If no command and no keys were given then the client
224
* wanted to terminate the connection.
225
*/
226
- if (!keys.argc)
226
+ if (!keys.nr)
227
return 1;
228
229
/*
strvec.c
+22
-22
@@ -6,25 +6,25 @@ const char *empty_strvec[] = { NULL };
6
7
void strvec_init(struct strvec *array)
8
{
9
- array->argv = empty_strvec;
10
- array->argc = 0;
9
+ array->v = empty_strvec;
10
+ array->nr = 0;
11
array->alloc = 0;
12
}
13
14
static void strvec_push_nodup(struct strvec *array, const char *value)
15
{
16
- if (array->argv == empty_strvec)
17
- array->argv = NULL;
16
+ if (array->v == empty_strvec)
17
+ array->v = NULL;
18
19
- ALLOC_GROW(array->argv, array->argc + 2, array->alloc);
20
- array->argv[array->argc++] = value;
21
- array->argv[array->argc] = NULL;
19
+ ALLOC_GROW(array->v, array->nr + 2, array->alloc);
20
+ array->v[array->nr++] = value;
21
+ array->v[array->nr] = NULL;
22
}
23
24
const char *strvec_push(struct strvec *array, const char *value)
25
{
26
strvec_push_nodup(array, xstrdup(value));
27
- return array->argv[array->argc - 1];
27
+ return array->v[array->nr - 1];
28
}
29
30
const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
@@ -37,7 +37,7 @@ const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
37
va_end(ap);
38
39
strvec_push_nodup(array, strbuf_detach(&v, NULL));
40
- return array->argv[array->argc - 1];
40
+ return array->v[array->nr - 1];
41
}
42
43
void strvec_pushl(struct strvec *array, ...)
@@ -51,19 +51,19 @@ void strvec_pushl(struct strvec *array, ...)
51
va_end(ap);
52
}
53
54
-void strvec_pushv(struct strvec *array, const char **argv)
54
+void strvec_pushv(struct strvec *array, const char **items)
55
{
56
- for (; *argv; argv++)
57
- strvec_push(array, *argv);
56
+ for (; *items; items++)
57
+ strvec_push(array, *items);
58
}
59
60
void strvec_pop(struct strvec *array)
61
{
62
- if (!array->argc)
62
+ if (!array->nr)
63
return;
64
- free((char *)array->argv[array->argc - 1]);
65
- array->argv[array->argc - 1] = NULL;
66
- array->argc--;
64
+ free((char *)array->v[array->nr - 1]);
65
+ array->v[array->nr - 1] = NULL;
66
+ array->nr--;
67
}
68
69
void strvec_split(struct strvec *array, const char *to_split)
@@ -88,21 +88,21 @@ void strvec_split(struct strvec *array, const char *to_split)
88
89
void strvec_clear(struct strvec *array)
90
{
91
- if (array->argv != empty_strvec) {
91
+ if (array->v != empty_strvec) {
92
int i;
93
- for (i = 0; i < array->argc; i++)
94
- free((char *)array->argv[i]);
95
- free(array->argv);
93
+ for (i = 0; i < array->nr; i++)
94
+ free((char *)array->v[i]);
95
+ free(array->v);
96
}
97
strvec_init(array);
98
}
99
100
const char **strvec_detach(struct strvec *array)
101
{
102
- if (array->argv == empty_strvec)
102
+ if (array->v == empty_strvec)
103
return xcalloc(1, sizeof(const char *));
104
else {
105
- const char **ret = array->argv;
105
+ const char **ret = array->v;
106
strvec_init(array);
107
return ret;
108
}
strvec.h
+10
-10
@@ -2,10 +2,10 @@
2
#define STRVEC_H
3
4
/**
5
- * The argv-array API allows one to dynamically build and store
6
- * NULL-terminated lists. An argv-array maintains the invariant that the
7
- * `argv` member always points to a non-NULL array, and that the array is
8
- * always NULL-terminated at the element pointed to by `argv[argc]`. This
5
+ * The strvec API allows one to dynamically build and store
6
+ * NULL-terminated arrays of strings. A strvec maintains the invariant that the
7
+ * `items` member always points to a non-NULL array, and that the array is
8
+ * always NULL-terminated at the element pointed to by `items[nr]`. This
9
* makes the result suitable for passing to functions expecting to receive
10
* argv from main().
11
*
@@ -22,15 +22,15 @@ extern const char *empty_strvec[];
22
23
/**
24
* A single array. This should be initialized by assignment from
25
- * `STRVEC_INIT`, or by calling `strvec_init`. The `argv`
26
- * member contains the actual array; the `argc` member contains the
25
+ * `STRVEC_INIT`, or by calling `strvec_init`. The `items`
26
+ * member contains the actual array; the `nr` member contains the
27
* number of elements in the array, not including the terminating
28
* NULL.
29
*/
30
struct strvec {
31
- const char **argv;
32
- size_t argc;
33
- size_t alloc;
31
+ const char **v;
32
+ int nr;
33
+ int alloc;
34
};
35
36
#define STRVEC_INIT { empty_strvec, 0, 0 }
@@ -78,7 +78,7 @@ void strvec_split(struct strvec *, const char *);
78
void strvec_clear(struct strvec *);
79
80
/**
81
- * Disconnect the `argv` member from the `strvec` struct and
81
+ * Disconnect the `items` member from the `strvec` struct and
82
* return it. The caller is responsible for freeing the memory used
83
* by the array, and by the strings it references. After detaching,
84
* the `strvec` is in a reinitialized state and can be pushed
submodule.c
+7
-7
@@ -269,7 +269,7 @@ int is_submodule_active(struct repository *repo, const char *path)
269
strvec_push(&args, item->string);
270
}
271
272
- parse_pathspec(&ps, 0, 0, NULL, args.argv);
272
+ parse_pathspec(&ps, 0, 0, NULL, args.v);
273
ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
274
275
strvec_clear(&args);
@@ -842,7 +842,7 @@ static void collect_changed_submodules(struct repository *r,
842
const struct commit *commit;
843
844
repo_init_revisions(r, &rev, NULL);
845
- setup_revisions(argv->argc, argv->argv, &rev, NULL);
845
+ setup_revisions(argv->nr, argv->v, &rev, NULL);
846
if (prepare_revision_walk(&rev))
847
die(_("revision walk setup failed"));
848
@@ -1014,7 +1014,7 @@ int find_unpushed_submodules(struct repository *r,
1014
struct string_list_item *name;
1015
struct strvec argv = STRVEC_INIT;
1016
1017
- /* argv.argv[0] will be ignored by setup_revisions */
1017
+ /* argv.v[0] will be ignored by setup_revisions */
1018
strvec_push(&argv, "find_unpushed_submodules");
1019
oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
1020
strvec_push(&argv, "--not");
@@ -1453,7 +1453,7 @@ static int get_next_submodule(struct child_process *cp,
1453
strbuf_addf(err, _("Fetching submodule %s%s\n"),
1454
spf->prefix, ce->name);
1455
strvec_init(&cp->args);
1456
- strvec_pushv(&cp->args, spf->args.argv);
1456
+ strvec_pushv(&cp->args, spf->args.v);
1457
strvec_push(&cp->args, default_argv);
1458
strvec_push(&cp->args, "--submodule-prefix");
1459
@@ -1501,7 +1501,7 @@ static int get_next_submodule(struct child_process *cp,
1501
cp->dir = task->repo->gitdir;
1502
1503
strvec_init(&cp->args);
1504
- strvec_pushv(&cp->args, spf->args.argv);
1504
+ strvec_pushv(&cp->args, spf->args.v);
1505
strvec_push(&cp->args, "on-demand");
1506
strvec_push(&cp->args, "--submodule-prefix");
1507
strvec_push(&cp->args, submodule_prefix.buf);
@@ -1619,8 +1619,8 @@ int fetch_populated_submodules(struct repository *r,
1619
die(_("index file corrupt"));
1620
1621
strvec_push(&spf.args, "fetch");
1622
- for (i = 0; i < options->argc; i++)
1623
- strvec_push(&spf.args, options->argv[i]);
1622
+ for (i = 0; i < options->nr; i++)
1623
+ strvec_push(&spf.args, options->v[i]);
1624
strvec_push(&spf.args, "--recurse-submodules-default");
1625
/* default value, "--submodule-prefix" and its value are added later */
1626
t/helper/test-run-command.c
+4
-4
@@ -248,7 +248,7 @@ static int quote_stress_test(int argc, const char **argv)
248
else
249
strvec_pushl(&args, "test-tool", "run-command",
250
"quote-echo", NULL);
251
- arg_offset = args.argc;
251
+ arg_offset = args.nr;
252
253
if (argc > 0) {
254
trials = 1;
@@ -275,13 +275,13 @@ static int quote_stress_test(int argc, const char **argv)
275
if (i < skip)
276
continue;
277
278
- cp.argv = args.argv;
278
+ cp.argv = args.v;
279
strbuf_reset(&out);
280
if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
281
return error("Failed to spawn child process");
282
283
for (j = 0, k = 0; j < arg_count; j++) {
284
- const char *arg = args.argv[j + arg_offset];
284
+ const char *arg = args.v[j + arg_offset];
285
286
if (strcmp(arg, out.buf + k))
287
ret = error("incorrectly quoted arg: '%s', "
@@ -298,7 +298,7 @@ static int quote_stress_test(int argc, const char **argv)
298
fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
299
for (j = 0; j < arg_count; j++)
300
fprintf(stderr, "arg #%d: '%s'\n",
301
- (int)j, args.argv[j + arg_offset]);
301
+ (int)j, args.v[j + arg_offset]);
302
303
strbuf_release(&out);
304
strvec_clear(&args);
tmp-objdir.c
+1
-1
@@ -283,7 +283,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
283
{
284
if (!t)
285
return NULL;
286
- return t->env.argv;
286
+ return t->env.v;
287
}
288
289
void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
transport-helper.c
+1
-1
@@ -138,7 +138,7 @@ static struct child_process *get_helper(struct transport *transport)
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>" */
141
+ helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */
142
143
code = start_command(helper);
144
if (code < 0 && errno == ENOENT)
upload-pack.c
+1
-1
@@ -897,7 +897,7 @@ static int send_shallow_list(struct upload_pack_data *data)
897
struct object *o = data->want_obj.objects[i].item;
898
strvec_push(&av, oid_to_hex(&o->oid));
899
}
900
- deepen_by_rev_list(data, av.argc, av.argv);
900
+ deepen_by_rev_list(data, av.nr, av.v);
901
strvec_clear(&av);
902
ret = 1;
903
} else {