Skip to content

Commit d70a9eb

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b5eb741 commit d70a9eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+186
-186
lines changed

add-interactive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
944944
files->items.items[i].string);
945945
parse_pathspec(&ps_selected,
946946
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
947-
PATHSPEC_LITERAL_PATH, "", args.argv);
947+
PATHSPEC_LITERAL_PATH, "", args.v);
948948
res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
949949
strvec_clear(&args);
950950
clear_pathspec(&ps_selected);
@@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
986986
if (files->selected[i])
987987
strvec_push(&args,
988988
files->items.items[i].string);
989-
res = run_command_v_opt(args.argv, 0);
989+
res = run_command_v_opt(args.v, 0);
990990
strvec_clear(&args);
991991
}
992992

add-patch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,14 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
391391
get_oid("HEAD", &oid) ?
392392
empty_tree_oid_hex() : s->revision);
393393
}
394-
color_arg_index = args.argc;
394+
color_arg_index = args.nr;
395395
/* Use `--no-color` explicitly, just in case `diff.color = always`. */
396396
strvec_pushl(&args, "--no-color", "-p", "--", NULL);
397397
for (i = 0; i < ps->nr; i++)
398398
strvec_push(&args, ps->items[i].original);
399399

400400
setup_child_process(s, &cp, NULL);
401-
cp.argv = args.argv;
401+
cp.argv = args.v;
402402
res = capture_command(&cp, plain, 0);
403403
if (res) {
404404
strvec_clear(&args);
@@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
415415
const char *diff_filter = s->s.interactive_diff_filter;
416416

417417
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;
420420
colored = &s->colored;
421421
res = capture_command(&colored_cp, colored, 0);
422422
strvec_clear(&args);

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
649649
if (read_paths)
650650
read_bisect_paths(&rev_argv);
651651

652-
setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL);
652+
setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL);
653653
/* XXX leak rev_argv, as "revs" may still be pointing to it */
654654
}
655655

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
228228
/* pass original pathspec, to be re-parsed */
229229
strvec_push(&argv, pathspec->items[i].original);
230230

231-
status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
231+
status = run_command_v_opt(argv.v, RUN_GIT_CMD);
232232
strvec_clear(&argv);
233233
return status;
234234
}

builtin/am.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
812812
strbuf_release(&sb);
813813
free(series_dir_buf);
814814

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);
816816

817817
strvec_clear(&patches);
818818
return ret;
@@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
10021002
}
10031003
write_state_text(state, "scissors", str);
10041004

1005-
sq_quote_argv(&sb, state->git_apply_opts.argv);
1005+
sq_quote_argv(&sb, state->git_apply_opts.v);
10061006
write_state_text(state, "apply-opt", sb.buf);
10071007

10081008
if (state->rebasing)
@@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file)
14011401
BUG("init_apply_state() failed");
14021402

14031403
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);
14051405

1406-
opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
1406+
opts_left = apply_parse_options(apply_opts.nr, apply_opts.v,
14071407
&apply_state, &force_apply, &options,
14081408
NULL);
14091409

@@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
14281428

14291429
strvec_push(&apply_paths, am_path(state, "patch"));
14301430

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);
14321432

14331433
strvec_clear(&apply_paths);
14341434
strvec_clear(&apply_opts);
@@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
14551455

14561456
cp.git_cmd = 1;
14571457
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);
14591459
strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
14601460
strvec_push(&cp.args, am_path(state, "patch"));
14611461

@@ -2376,10 +2376,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
23762376
strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
23772377
}
23782378

2379-
if (state.interactive && !paths.argc)
2379+
if (state.interactive && !paths.nr)
23802380
die(_("interactive mode requires patches on the command line"));
23812381

2382-
am_setup(&state, patch_format, paths.argv, keep_cr);
2382+
am_setup(&state, patch_format, paths.v, keep_cr);
23832383

23842384
strvec_clear(&paths);
23852385
}

builtin/annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
1818
strvec_push(&args, argv[i]);
1919
}
2020

21-
return cmd_blame(args.argc, args.argv, prefix);
21+
return cmd_blame(args.nr, args.v, prefix);
2222
}

builtin/bisect--helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static int bisect_reset(const char *commit)
168168
struct strvec argv = STRVEC_INIT;
169169

170170
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)) {
172172
error(_("could not check out original"
173173
" HEAD '%s'. Try 'git bisect"
174174
" reset <commit>'."), branch.buf);
@@ -530,7 +530,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
530530

531531
strvec_pushl(&argv, "checkout", start_head.buf,
532532
"--", NULL);
533-
if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
533+
if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
534534
res = error(_("checking out '%s' failed."
535535
" Try 'git bisect start "
536536
"<valid-branch>'."),

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo)
752752
*/
753753
core_apply_sparse_checkout = 1;
754754

755-
if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
755+
if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
756756
error(_("failed to initialize sparse-checkout"));
757757
result = 1;
758758
}
@@ -844,7 +844,7 @@ static int checkout(int submodule_progress)
844844
"--single-branch" :
845845
"--no-single-branch");
846846

847-
err = run_command_v_opt(args.argv, RUN_GIT_CMD);
847+
err = run_command_v_opt(args.v, RUN_GIT_CMD);
848848
strvec_clear(&args);
849849
}
850850

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10081008
struct strvec env = STRVEC_INIT;
10091009

10101010
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)) {
10121012
fprintf(stderr,
10131013
_("Please supply the message using either -m or -F option.\n"));
10141014
exit(1);

builtin/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
509509
NULL);
510510

511511
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)
513513
BUG("setup_revisions could not handle all args?");
514514

515515
if (prepare_revision_walk(&revs))
@@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
613613
strvec_pushv(&args, argv);
614614
else
615615
strvec_push(&args, "HEAD");
616-
return cmd_name_rev(args.argc, args.argv, prefix);
616+
return cmd_name_rev(args.nr, args.v, prefix);
617617
}
618618

619619
hashmap_init(&names, commit_name_neq, NULL, 0);
@@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
659659

660660
repo_init_revisions(the_repository, &revs, prefix);
661661
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)
663663
BUG("malformed internal diff-index command line");
664664
result = run_diff_index(&revs, 0);
665665

0 commit comments

Comments
 (0)