files->items.items[i].string);
parse_pathspec(&ps_selected,
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
- PATHSPEC_LITERAL_PATH, "", args.argv);
+ PATHSPEC_LITERAL_PATH, "", args.v);
res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
strvec_clear(&args);
clear_pathspec(&ps_selected);
if (files->selected[i])
strvec_push(&args,
files->items.items[i].string);
- res = run_command_v_opt(args.argv, 0);
+ res = run_command_v_opt(args.v, 0);
strvec_clear(&args);
}
get_oid("HEAD", &oid) ?
empty_tree_oid_hex() : s->revision);
}
- color_arg_index = args.argc;
+ color_arg_index = args.nr;
/* Use `--no-color` explicitly, just in case `diff.color = always`. */
strvec_pushl(&args, "--no-color", "-p", "--", NULL);
for (i = 0; i < ps->nr; i++)
strvec_push(&args, ps->items[i].original);
setup_child_process(s, &cp, NULL);
- cp.argv = args.argv;
+ cp.argv = args.v;
res = capture_command(&cp, plain, 0);
if (res) {
strvec_clear(&args);
const char *diff_filter = s->s.interactive_diff_filter;
setup_child_process(s, &colored_cp, NULL);
- xsnprintf((char *)args.argv[color_arg_index], 8, "--color");
- colored_cp.argv = args.argv;
+ xsnprintf((char *)args.v[color_arg_index], 8, "--color");
+ colored_cp.argv = args.v;
colored = &s->colored;
res = capture_command(&colored_cp, colored, 0);
strvec_clear(&args);
if (read_paths)
read_bisect_paths(&rev_argv);
- setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL);
+ setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL);
/* XXX leak rev_argv, as "revs" may still be pointing to it */
}
/* pass original pathspec, to be re-parsed */
strvec_push(&argv, pathspec->items[i].original);
- status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+ status = run_command_v_opt(argv.v, RUN_GIT_CMD);
strvec_clear(&argv);
return status;
}
strbuf_release(&sb);
free(series_dir_buf);
- ret = split_mail_conv(stgit_patch_to_mail, state, patches.argv, keep_cr);
+ ret = split_mail_conv(stgit_patch_to_mail, state, patches.v, keep_cr);
strvec_clear(&patches);
return ret;
}
write_state_text(state, "scissors", str);
- sq_quote_argv(&sb, state->git_apply_opts.argv);
+ sq_quote_argv(&sb, state->git_apply_opts.v);
write_state_text(state, "apply-opt", sb.buf);
if (state->rebasing)
BUG("init_apply_state() failed");
strvec_push(&apply_opts, "apply");
- strvec_pushv(&apply_opts, state->git_apply_opts.argv);
+ strvec_pushv(&apply_opts, state->git_apply_opts.v);
- opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
+ opts_left = apply_parse_options(apply_opts.nr, apply_opts.v,
&apply_state, &force_apply, &options,
NULL);
strvec_push(&apply_paths, am_path(state, "patch"));
- res = apply_all_patches(&apply_state, apply_paths.argc, apply_paths.argv, options);
+ res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.v, options);
strvec_clear(&apply_paths);
strvec_clear(&apply_opts);
cp.git_cmd = 1;
strvec_push(&cp.args, "apply");
- strvec_pushv(&cp.args, state->git_apply_opts.argv);
+ strvec_pushv(&cp.args, state->git_apply_opts.v);
strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
strvec_push(&cp.args, am_path(state, "patch"));
strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
}
- if (state.interactive && !paths.argc)
+ if (state.interactive && !paths.nr)
die(_("interactive mode requires patches on the command line"));
- am_setup(&state, patch_format, paths.argv, keep_cr);
+ am_setup(&state, patch_format, paths.v, keep_cr);
strvec_clear(&paths);
}
strvec_push(&args, argv[i]);
}
- return cmd_blame(args.argc, args.argv, prefix);
+ return cmd_blame(args.nr, args.v, prefix);
}
struct strvec argv = STRVEC_INIT;
strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
error(_("could not check out original"
" HEAD '%s'. Try 'git bisect"
" reset <commit>'."), branch.buf);
strvec_pushl(&argv, "checkout", start_head.buf,
"--", NULL);
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
res = error(_("checking out '%s' failed."
" Try 'git bisect start "
"<valid-branch>'."),
*/
core_apply_sparse_checkout = 1;
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
error(_("failed to initialize sparse-checkout"));
result = 1;
}
"--single-branch" :
"--no-single-branch");
- err = run_command_v_opt(args.argv, RUN_GIT_CMD);
+ err = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
}
struct strvec env = STRVEC_INIT;
strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
- if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
+ if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
fprintf(stderr,
_("Please supply the message using either -m or -F option.\n"));
exit(1);
NULL);
repo_init_revisions(the_repository, &revs, NULL);
- if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
+ if (setup_revisions(args.nr, args.v, &revs, NULL) > 1)
BUG("setup_revisions could not handle all args?");
if (prepare_revision_walk(&revs))
strvec_pushv(&args, argv);
else
strvec_push(&args, "HEAD");
- return cmd_name_rev(args.argc, args.argv, prefix);
+ return cmd_name_rev(args.nr, args.v, prefix);
}
hashmap_init(&names, commit_name_neq, NULL, 0);
repo_init_revisions(the_repository, &revs, prefix);
strvec_pushv(&args, diff_index_args);
- if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
+ if (setup_revisions(args.nr, args.v, &revs, NULL) != 1)
BUG("malformed internal diff-index command line");
result = run_diff_index(&revs, 0);
strvec_push(&args, "diff");
for (i = 0; i < argc; i++)
strvec_push(&args, argv[i]);
- ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
+ ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
exit(ret);
}
if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
must_list_refs = 1;
- if (ref_prefixes.argc)
+ if (ref_prefixes.nr)
strvec_push(&ref_prefixes, "refs/tags/");
}
add_options_to_argv(&argv);
if (max_children != 1 && list->nr != 1) {
- struct parallel_fetch_state state = { argv.argv, list, 0, 0 };
+ struct parallel_fetch_state state = { argv.v, list, 0, 0 };
strvec_push(&argv, "--end-of-options");
result = run_processes_parallel_tr2(max_children,
strvec_push(&argv, name);
if (verbosity >= 0)
printf(_("Fetching %s\n"), name);
- if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+ if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
error(_("Could not fetch %s"), name);
result = 1;
}
if (done++)
return;
- if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD))
- die(FAILED_RUN, pack_refs_cmd.argv[0]);
+ if (pack_refs && run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD))
+ die(FAILED_RUN, pack_refs_cmd.v[0]);
- if (prune_reflogs && run_command_v_opt(reflog.argv, RUN_GIT_CMD))
- die(FAILED_RUN, reflog.argv[0]);
+ if (prune_reflogs && run_command_v_opt(reflog.v, RUN_GIT_CMD))
+ die(FAILED_RUN, reflog.v[0]);
}
int cmd_gc(int argc, const char **argv, const char *prefix)
if (!repository_format_precious_objects) {
close_object_store(the_repository->objects);
- if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
- die(FAILED_RUN, repack.argv[0]);
+ if (run_command_v_opt(repack.v, RUN_GIT_CMD))
+ die(FAILED_RUN, repack.v[0]);
if (prune_expire) {
strvec_push(&prune, prune_expire);
if (has_promisor_remote())
strvec_push(&prune,
"--exclude-promisor-objects");
- if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
- die(FAILED_RUN, prune.argv[0]);
+ if (run_command_v_opt(prune.v, RUN_GIT_CMD))
+ die(FAILED_RUN, prune.v[0]);
}
}
if (prune_worktrees_expire) {
strvec_push(&prune_worktrees, prune_worktrees_expire);
- if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD))
- die(FAILED_RUN, prune_worktrees.argv[0]);
+ if (run_command_v_opt(prune_worktrees.v, RUN_GIT_CMD))
+ die(FAILED_RUN, prune_worktrees.v[0]);
}
- if (run_command_v_opt(rerere.argv, RUN_GIT_CMD))
- die(FAILED_RUN, rerere.argv[0]);
+ if (run_command_v_opt(rerere.v, RUN_GIT_CMD))
+ die(FAILED_RUN, rerere.v[0]);
report_garbage = report_pack_garbage;
reprepare_packed_git(the_repository);
if (!use_internal_rev_list)
read_object_list_from_stdin();
else {
- get_object_list(rp.argc, rp.argv);
+ get_object_list(rp.nr, rp.v);
strvec_clear(&rp);
}
cleanup_preferred_base();
strvec_push(&args, "--no-show-forced-updates");
if (set_upstream)
strvec_push(&args, set_upstream);
- strvec_pushv(&args, opt_fetch.argv);
+ strvec_pushv(&args, opt_fetch.v);
if (repo) {
strvec_push(&args, repo);
strvec_pushv(&args, refspecs);
} else if (*refspecs)
BUG("refspecs without repo?");
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
return ret;
}
strvec_push(&args, opt_ff);
if (opt_verify_signatures)
strvec_push(&args, opt_verify_signatures);
- strvec_pushv(&args, opt_strategies.argv);
- strvec_pushv(&args, opt_strategy_opts.argv);
+ strvec_pushv(&args, opt_strategies.v);
+ strvec_pushv(&args, opt_strategy_opts.v);
if (opt_gpg_sign)
strvec_push(&args, opt_gpg_sign);
if (opt_autostash == 0)
strvec_push(&args, "--allow-unrelated-histories");
strvec_push(&args, "FETCH_HEAD");
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
return ret;
}
strvec_push(&args, "--interactive");
if (opt_diffstat)
strvec_push(&args, opt_diffstat);
- strvec_pushv(&args, opt_strategies.argv);
- strvec_pushv(&args, opt_strategy_opts.argv);
+ strvec_pushv(&args, opt_strategies.v);
+ strvec_pushv(&args, opt_strategy_opts.v);
if (opt_gpg_sign)
strvec_push(&args, opt_gpg_sign);
if (opt_autostash == 0)
else
strvec_push(&args, oid_to_hex(merge_head));
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
return ret;
}
oid_to_hex(&opts->restrict_revision->object.oid));
ret = sequencer_make_script(the_repository, &todo_list.buf,
- make_script_args.argc, make_script_args.argv,
+ make_script_args.nr, make_script_args.v,
flags);
if (ret)
return status;
}
- strvec_pushv(&am.args, opts->git_am_opts.argv);
+ strvec_pushv(&am.args, opts->git_am_opts.v);
strvec_push(&am.args, "--rebasing");
strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
strvec_push(&am.args, "--patch-format=mboxrd");
add_var(&script_snippet, "revisions", opts->revisions);
add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
- sq_quote_argv_pretty(&buf, opts->git_am_opts.argv);
+ sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
add_var(&script_snippet, "git_am_opt", buf.buf);
strbuf_release(&buf);
add_var(&script_snippet, "verbose",
allow_preemptive_ff = 0;
}
- for (i = 0; i < options.git_am_opts.argc; i++) {
- const char *option = options.git_am_opts.argv[i], *p;
+ for (i = 0; i < options.git_am_opts.nr; i++) {
+ const char *option = options.git_am_opts.v[i], *p;
if (!strcmp(option, "--committer-date-is-author-date") ||
!strcmp(option, "--ignore-date") ||
!strcmp(option, "--whitespace=fix") ||
if (isatty(2) && options.flags & REBASE_NO_QUIET)
strbuf_addstr(&options.git_format_patch_opt, " --progress");
- if (options.git_am_opts.argc || options.type == REBASE_APPLY) {
+ if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
/* all am options except -q are compatible only with --apply */
- for (i = options.git_am_opts.argc - 1; i >= 0; i--)
- if (strcmp(options.git_am_opts.argv[i], "-q"))
+ for (i = options.git_am_opts.nr - 1; i >= 0; i--)
+ if (strcmp(options.git_am_opts.v[i], "-q"))
break;
if (i >= 0) {
struct child_process child = CHILD_PROCESS_INIT;
child.argv = update_refresh;
- child.env = env->argv;
+ child.env = env->v;
child.dir = work_tree;
child.no_stdin = 1;
child.stdout_to_stderr = 1;
/* run_command() does not clean up completely; reinitialize */
child_process_init(&child);
child.argv = diff_files;
- child.env = env->argv;
+ child.env = env->v;
child.dir = work_tree;
child.no_stdin = 1;
child.stdout_to_stderr = 1;
child_process_init(&child);
child.argv = diff_index;
- child.env = env->argv;
+ child.env = env->v;
child.no_stdin = 1;
child.no_stdout = 1;
child.stdout_to_stderr = 0;
read_tree[3] = hash_to_hex(sha1);
child_process_init(&child);
child.argv = read_tree;
- child.env = env->argv;
+ child.env = env->v;
child.dir = work_tree;
child.no_stdin = 1;
child.no_stdout = 1;
const char *work_tree)
{
strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
- if (run_hook_le(env->argv, push_to_checkout_hook,
+ if (run_hook_le(env->v, push_to_checkout_hook,
hash_to_hex(hash), NULL))
return "push-to-checkout hook declined";
else
for (cmd = commands; cmd; cmd = cmd->next) {
if (cmd->error_string || cmd->did_not_exist)
continue;
- if (!proc.args.argc)
+ if (!proc.args.nr)
strvec_push(&proc.args, hook);
strvec_push(&proc.args, cmd->ref_name);
}
- if (!proc.args.argc)
+ if (!proc.args.nr)
return;
proc.no_stdin = 1;
for (i = 1; i < argc; i++)
strvec_push(&fetch_argv, argv[i]);
- if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
+ if (strcmp(fetch_argv.v[fetch_argv.nr-1], "default") == 0) {
git_config(get_remote_default, &default_defined);
if (!default_defined) {
strvec_pop(&fetch_argv);
}
}
- retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
+ retval = run_command_v_opt(fetch_argv.v, RUN_GIT_CMD);
strvec_clear(&fetch_argv);
return retval;
}
continue;
strvec_split(&args, buf.buf);
- if (args.argc && create_graft(args.argc, args.argv, force, 1))
+ if (args.nr && create_graft(args.nr, args.v, force, 1))
strbuf_addf(&err, "\n\t%s", buf.buf);
strvec_clear(&args);
}
* default_arg is now passed to parse_options(), so we need to
* mimic the real argv a bit better.
*/
- if (!default_args.argc)
+ if (!default_args.nr)
strvec_push(&default_args, "show-branch");
strvec_push(&default_args, value);
return 0;
git_config(git_show_branch_config, NULL);
/* If nothing is specified, try the default first */
- if (ac == 1 && default_args.argc) {
- ac = default_args.argc;
- av = default_args.argv;
+ if (ac == 1 && default_args.nr) {
+ ac = default_args.nr;
+ av = default_args.v;
}
ac = parse_options(ac, av, prefix, builtin_show_branch_options,
strvec_push(&revision_args, argv[i]);
}
- ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
+ ret = get_stash_info(&info, stash_args.nr, stash_args.v);
strvec_clear(&stash_args);
if (ret)
return -1;
* The config settings are applied only if there are not passed
* any options.
*/
- if (revision_args.argc == 1) {
+ if (revision_args.nr == 1) {
if (show_stat)
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT;
}
}
- argc = setup_revisions(revision_args.argc, revision_args.argv, &rev, NULL);
+ argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
if (argc > 1) {
free_stash_info(&info);
usage_with_options(git_stash_show_usage, options);
/* Assume 'stash push' */
strvec_push(&args, "push");
strvec_pushv(&args, argv);
- return !!push_stash(args.argc, args.argv, prefix, 1);
+ return !!push_stash(args.nr, args.v, prefix, 1);
}
repo_init_revisions(the_repository, &rev, NULL);
rev.abbrev = 0;
- diff_files_args.argc = setup_revisions(diff_files_args.argc,
- diff_files_args.argv,
- &rev, NULL);
+ diff_files_args.nr = setup_revisions(diff_files_args.nr,
+ diff_files_args.v,
+ &rev, NULL);
diff_files_result = run_diff_files(&rev, 0);
if (!diff_result_code(&rev.diffopt, diff_files_result)) {
char *buf = packet_read_line(0, NULL);
if (!buf)
break; /* got a flush */
- if (sent_argv.argc > MAX_ARGS)
+ if (sent_argv.nr > MAX_ARGS)
die("Too many options (>%d)", MAX_ARGS - 1);
if (!starts_with(buf, arg_cmd))
}
/* parse all options sent by the client */
- return write_archive(sent_argv.argc, sent_argv.argv, prefix,
+ return write_archive(sent_argv.nr, sent_argv.v, prefix,
the_repository, NULL, 1);
}
strvec_push(&cp.args, "--quiet");
}
- cp.env = child_env.argv;
+ cp.env = child_env.v;
ret = run_command(&cp);
if (ret)
goto done;
strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
if (opts->quiet)
strvec_push(&cp.args, "--quiet");
- cp.env = child_env.argv;
+ cp.env = child_env.v;
ret = run_command(&cp);
if (ret)
goto done;
strvec_pushl(&cp.args, "status",
"--porcelain", "--ignore-submodules=none",
NULL);
- cp.env = child_env.argv;
+ cp.env = child_env.v;
cp.git_cmd = 1;
cp.dir = wt->path;
cp.out = -1;
"pack-objects",
"--stdout", "--thin", "--delta-base-offset",
NULL);
- strvec_pushv(&pack_objects.args, pack_options->argv);
+ strvec_pushv(&pack_objects.args, pack_options->v);
pack_objects.in = -1;
pack_objects.out = bundle_fd;
pack_objects.git_cmd = 1;
strvec_push(&hook_env, "GIT_EDITOR=:");
va_start(args, name);
- ret = run_hook_ve(hook_env.argv,name, args);
+ ret = run_hook_ve(hook_env.v, name, args);
va_end(args);
strvec_clear(&hook_env);
{
int i;
- for (i = 0; i < server_capabilities_v2.argc; i++) {
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
(!*out || *out == '='))
return 1;
}
{
int i;
- for (i = 0; i < server_capabilities_v2.argc; i++) {
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
(*out == '=')) {
*v = out + 1;
return 1;
{
int i;
- for (i = 0; i < server_capabilities_v2.argc; i++) {
+ for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
- if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+ if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
(!*out || *(out++) == '=')) {
if (parse_feature_request(out, feature))
return 1;
if (!for_push)
packet_write_fmt(fd_out, "peel\n");
packet_write_fmt(fd_out, "symrefs\n");
- for (i = 0; ref_prefixes && i < ref_prefixes->argc; i++) {
+ for (i = 0; ref_prefixes && i < ref_prefixes->nr; i++) {
packet_write_fmt(fd_out, "ref-prefix %s\n",
- ref_prefixes->argv[i]);
+ ref_prefixes->v[i]);
}
packet_flush(fd_out);
strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
strvec_pushf(&cld.args, "--timeout=%u", timeout);
- strvec_pushv(&cld.env_array, env->argv);
+ strvec_pushv(&cld.env_array, env->v);
return run_service_command(&cld);
}
struct child_process cld = CHILD_PROCESS_INIT;
strvec_push(&cld.args, "upload-archive");
- strvec_pushv(&cld.env_array, env->argv);
+ strvec_pushv(&cld.env_array, env->v);
return run_service_command(&cld);
}
struct child_process cld = CHILD_PROCESS_INIT;
strvec_push(&cld.args, "receive-pack");
- strvec_pushv(&cld.env_array, env->argv);
+ strvec_pushv(&cld.env_array, env->v);
return run_service_command(&cld);
}
#endif
}
- cld.argv = cld_argv.argv;
+ cld.argv = cld_argv.v;
cld.in = incoming;
cld.out = dup(incoming);
diff_free_filespec_data(one);
diff_free_filespec_data(two);
- if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
+ if (run_command_v_opt_cd_env(argv.v, RUN_USING_SHELL, NULL, env.v))
die(_("external diff died, stopping at %s"), name);
remove_tempfile();
return NULL;
strvec_push(argv, value);
- return argv->argv[argv->argc - 1];
+ return argv->v[argv->nr - 1];
}
void setup_git_env(const char *git_dir)
{
strvec_push(out, "git");
strvec_pushv(out, argv);
- return out->argv;
+ return out->v;
}
int execv_git_cmd(const char **argv)
struct strvec nargv = STRVEC_INIT;
prepare_git_cmd(&nargv, argv);
- trace_argv_printf(nargv.argv, "trace: exec:");
+ trace_argv_printf(nargv.v, "trace: exec:");
/* execvp() can only ever return if it fails */
- sane_execvp("git", (char **)nargv.argv);
+ sane_execvp("git", (char **)nargv.v);
trace_printf("trace: exec failed: %s\n", strerror(errno));
strvec_push(&child.args, alias_string + 1);
strvec_pushv(&child.args, (*argv) + 1);
- trace2_cmd_alias(alias_command, child.args.argv);
+ trace2_cmd_alias(alias_command, child.args.v);
trace2_cmd_list_config();
trace2_cmd_list_env_vars();
trace2_cmd_name("_run_shell_alias_");
}
argc++;
- argv = args.argv;
+ argv = args.v;
}
builtin = get_builtin(cmd);
* The code in run_command() logs trace2 child_start/child_exit
* events, so we do not need to report exec/exec_result events here.
*/
- trace_argv_printf(cmd.args.argv, "trace: exec:");
+ trace_argv_printf(cmd.args.v, "trace: exec:");
/*
* If we fail because the command is not found, it is
for (i = 0; i < *argcp; i++)
strvec_push(&args, (*argv)[i]);
- trace_argv_printf(args.argv, "trace: exec:");
+ trace_argv_printf(args.v, "trace: exec:");
/*
* if we fail because the command is not found, it is
* OK to return. Otherwise, we just pass along the status code.
*/
- i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE |
+ i = run_command_v_opt_tr2(args.v, RUN_SILENT_EXEC_FAILURE |
RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias");
if (i >= 0 || errno != ENOENT)
exit(i);
parse_graph_colors_config(&custom_colors, string);
free(string);
/* graph_set_column_colors takes a max-index, not a count */
- graph_set_column_colors(custom_colors.argv,
- custom_colors.argc - 1);
+ graph_set_column_colors(custom_colors.v,
+ custom_colors.nr - 1);
}
}
strvec_pushf(&commit_argv, "^%s",
oid_to_hex(&ref->old_oid));
repo_init_revisions(the_repository, &revs, setup_git_directory());
- setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
+ setup_revisions(commit_argv.nr, commit_argv.v, &revs, NULL);
revs.edge_hint = 0; /* just in case */
/* Generate a list of objects that need to be pushed */
{
int i;
- if (!prefixes->argc)
+ if (!prefixes->nr)
return 1; /* no restriction */
- for (i = 0; i < prefixes->argc; i++) {
- const char *prefix = prefixes->argv[i];
+ for (i = 0; i < prefixes->nr; i++) {
+ const char *prefix = prefixes->v[i];
if (starts_with(refname, prefix))
return 1;
for (j = remotes; j; j = j->next)
strvec_push(&args, merge_argument(j->item));
- ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+ ret = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
discard_index(r->index);
if (in != stdin)
fclose(in);
- parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
+ parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.v);
strvec_clear(&parsed_file);
}
"--notes",
NULL);
if (other_arg)
- strvec_pushv(&cp.args, other_arg->argv);
+ strvec_pushv(&cp.args, other_arg->v);
strvec_push(&cp.args, range);
cp.out = -1;
cp.no_stdin = 1;
struct strbuf prefix = STRBUF_INIT;
strvec_pushv(&sorted, patterns);
- QSORT(sorted.argv, sorted.argc, qsort_strcmp);
+ QSORT(sorted.v, sorted.nr, qsort_strcmp);
- find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
+ find_longest_prefixes_1(out, &prefix, sorted.v, sorted.nr);
strvec_clear(&sorted);
strbuf_release(&prefix);
rpc.service_name = "git-upload-pack",
rpc.gzip_request = 1;
- err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result);
+ err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
if (rpc_result.len)
write_or_die(1, rpc_result.buf, rpc_result.len);
strbuf_release(&rpc_result);
memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-receive-pack",
- err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result);
+ err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
if (rpc_result.len)
write_or_die(1, rpc_result.buf, rpc_result.len);
strbuf_release(&rpc_result);
break;
} while (1);
- ret = push(specs.argc, specs.argv);
+ ret = push(specs.nr, specs.v);
printf("\n");
fflush(stdout);
strvec_push(&argv, "--");
repo_init_revisions(the_repository, &revs, NULL);
- setup_revisions(argv.argc, argv.argv, &revs, NULL);
+ setup_revisions(argv.nr, argv.v, &revs, NULL);
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
got_rev_arg = 1;
}
- if (prune_data.argc) {
+ if (prune_data.nr) {
/*
* If we need to introduce the magic "a lone ':' means no
* pathspec whatsoever", here is the place to do so.
* }
*/
parse_pathspec(&revs->prune_data, 0, 0,
- revs->prefix, prune_data.argv);
+ revs->prefix, prune_data.v);
}
strvec_clear(&prune_data);
}
strvec_pushv(out, argv);
- return out->argv;
+ return out->v;
}
#ifndef GIT_WINDOWS_NATIVE
* there are dir separator characters, we have exec attempt to invoke
* the command directly.
*/
- if (!has_dir_sep(out->argv[1])) {
- char *program = locate_in_PATH(out->argv[1]);
+ if (!has_dir_sep(out->v[1])) {
+ char *program = locate_in_PATH(out->v[1]);
if (program) {
- free((char *)out->argv[1]);
- out->argv[1] = program;
+ free((char *)out->v[1]);
+ out->v[1] = program;
} else {
strvec_clear(out);
errno = ENOENT;
char *str;
if (!cmd->argv)
- cmd->argv = cmd->args.argv;
+ cmd->argv = cmd->args.v;
if (!cmd->env)
- cmd->env = cmd->env_array.argv;
+ cmd->env = cmd->env_array.v;
/*
* In case of errors we must keep the promise to close FDs
* be used in the event exec failed with ENOEXEC at which point
* we will try to interpret the command using 'sh'.
*/
- execve(argv.argv[1], (char *const *) argv.argv + 1,
+ execve(argv.v[1], (char *const *) argv.v + 1,
(char *const *) childenv);
if (errno == ENOEXEC)
- execve(argv.argv[0], (char *const *) argv.argv,
+ execve(argv.v[0], (char *const *) argv.v,
(char *const *) childenv);
if (errno == ENOENT) {
strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
if (quiet)
strvec_push(&argv_gc_auto, "--quiet");
- status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+ status = run_command_v_opt(argv_gc_auto.v, RUN_GIT_CMD);
strvec_clear(&argv_gc_auto);
return status;
}
if (!is_null_oid(oid))
strvec_push(&argv, oid_to_hex(oid));
- ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+ ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
strvec_clear(&argv);
return ret;
strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
absolute_path(get_git_work_tree()));
status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
- child_env.argv);
+ child_env.v);
/* force re-reading of the cache */
if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
const char **value)
{
int i;
- for (i = 0; i < keys->argc; i++) {
+ for (i = 0; i < keys->nr; i++) {
const char *out;
- if (skip_prefix(keys->argv[i], capability, &out) &&
+ if (skip_prefix(keys->v[i], capability, &out) &&
(!*out || *out == '=')) {
if (value) {
if (*out == '=')
* If no command and no keys were given then the client
* wanted to terminate the connection.
*/
- if (!keys.argc)
+ if (!keys.nr)
return 1;
/*
void strvec_init(struct strvec *array)
{
- array->argv = empty_strvec;
- array->argc = 0;
+ array->v = empty_strvec;
+ array->nr = 0;
array->alloc = 0;
}
static void strvec_push_nodup(struct strvec *array, const char *value)
{
- if (array->argv == empty_strvec)
- array->argv = NULL;
+ if (array->v == empty_strvec)
+ array->v = NULL;
- ALLOC_GROW(array->argv, array->argc + 2, array->alloc);
- array->argv[array->argc++] = value;
- array->argv[array->argc] = NULL;
+ ALLOC_GROW(array->v, array->nr + 2, array->alloc);
+ array->v[array->nr++] = value;
+ array->v[array->nr] = NULL;
}
const char *strvec_push(struct strvec *array, const char *value)
{
strvec_push_nodup(array, xstrdup(value));
- return array->argv[array->argc - 1];
+ return array->v[array->nr - 1];
}
const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
va_end(ap);
strvec_push_nodup(array, strbuf_detach(&v, NULL));
- return array->argv[array->argc - 1];
+ return array->v[array->nr - 1];
}
void strvec_pushl(struct strvec *array, ...)
va_end(ap);
}
-void strvec_pushv(struct strvec *array, const char **argv)
+void strvec_pushv(struct strvec *array, const char **items)
{
- for (; *argv; argv++)
- strvec_push(array, *argv);
+ for (; *items; items++)
+ strvec_push(array, *items);
}
void strvec_pop(struct strvec *array)
{
- if (!array->argc)
+ if (!array->nr)
return;
- free((char *)array->argv[array->argc - 1]);
- array->argv[array->argc - 1] = NULL;
- array->argc--;
+ free((char *)array->v[array->nr - 1]);
+ array->v[array->nr - 1] = NULL;
+ array->nr--;
}
void strvec_split(struct strvec *array, const char *to_split)
void strvec_clear(struct strvec *array)
{
- if (array->argv != empty_strvec) {
+ if (array->v != empty_strvec) {
int i;
- for (i = 0; i < array->argc; i++)
- free((char *)array->argv[i]);
- free(array->argv);
+ for (i = 0; i < array->nr; i++)
+ free((char *)array->v[i]);
+ free(array->v);
}
strvec_init(array);
}
const char **strvec_detach(struct strvec *array)
{
- if (array->argv == empty_strvec)
+ if (array->v == empty_strvec)
return xcalloc(1, sizeof(const char *));
else {
- const char **ret = array->argv;
+ const char **ret = array->v;
strvec_init(array);
return ret;
}
#define STRVEC_H
/**
- * The argv-array API allows one to dynamically build and store
- * NULL-terminated lists. An argv-array maintains the invariant that the
- * `argv` member always points to a non-NULL array, and that the array is
- * always NULL-terminated at the element pointed to by `argv[argc]`. This
+ * The strvec API allows one to dynamically build and store
+ * NULL-terminated arrays of strings. A strvec maintains the invariant that the
+ * `items` member always points to a non-NULL array, and that the array is
+ * always NULL-terminated at the element pointed to by `items[nr]`. This
* makes the result suitable for passing to functions expecting to receive
* argv from main().
*
/**
* A single array. This should be initialized by assignment from
- * `STRVEC_INIT`, or by calling `strvec_init`. The `argv`
- * member contains the actual array; the `argc` member contains the
+ * `STRVEC_INIT`, or by calling `strvec_init`. The `items`
+ * member contains the actual array; the `nr` member contains the
* number of elements in the array, not including the terminating
* NULL.
*/
struct strvec {
- const char **argv;
- size_t argc;
- size_t alloc;
+ const char **v;
+ int nr;
+ int alloc;
};
#define STRVEC_INIT { empty_strvec, 0, 0 }
void strvec_clear(struct strvec *);
/**
- * Disconnect the `argv` member from the `strvec` struct and
+ * Disconnect the `items` member from the `strvec` struct and
* return it. The caller is responsible for freeing the memory used
* by the array, and by the strings it references. After detaching,
* the `strvec` is in a reinitialized state and can be pushed
strvec_push(&args, item->string);
}
- parse_pathspec(&ps, 0, 0, NULL, args.argv);
+ parse_pathspec(&ps, 0, 0, NULL, args.v);
ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
strvec_clear(&args);
const struct commit *commit;
repo_init_revisions(r, &rev, NULL);
- setup_revisions(argv->argc, argv->argv, &rev, NULL);
+ setup_revisions(argv->nr, argv->v, &rev, NULL);
if (prepare_revision_walk(&rev))
die(_("revision walk setup failed"));
struct string_list_item *name;
struct strvec argv = STRVEC_INIT;
- /* argv.argv[0] will be ignored by setup_revisions */
+ /* argv.v[0] will be ignored by setup_revisions */
strvec_push(&argv, "find_unpushed_submodules");
oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
strvec_push(&argv, "--not");
strbuf_addf(err, _("Fetching submodule %s%s\n"),
spf->prefix, ce->name);
strvec_init(&cp->args);
- strvec_pushv(&cp->args, spf->args.argv);
+ strvec_pushv(&cp->args, spf->args.v);
strvec_push(&cp->args, default_argv);
strvec_push(&cp->args, "--submodule-prefix");
cp->dir = task->repo->gitdir;
strvec_init(&cp->args);
- strvec_pushv(&cp->args, spf->args.argv);
+ strvec_pushv(&cp->args, spf->args.v);
strvec_push(&cp->args, "on-demand");
strvec_push(&cp->args, "--submodule-prefix");
strvec_push(&cp->args, submodule_prefix.buf);
die(_("index file corrupt"));
strvec_push(&spf.args, "fetch");
- for (i = 0; i < options->argc; i++)
- strvec_push(&spf.args, options->argv[i]);
+ for (i = 0; i < options->nr; i++)
+ strvec_push(&spf.args, options->v[i]);
strvec_push(&spf.args, "--recurse-submodules-default");
/* default value, "--submodule-prefix" and its value are added later */
else
strvec_pushl(&args, "test-tool", "run-command",
"quote-echo", NULL);
- arg_offset = args.argc;
+ arg_offset = args.nr;
if (argc > 0) {
trials = 1;
if (i < skip)
continue;
- cp.argv = args.argv;
+ cp.argv = args.v;
strbuf_reset(&out);
if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
return error("Failed to spawn child process");
for (j = 0, k = 0; j < arg_count; j++) {
- const char *arg = args.argv[j + arg_offset];
+ const char *arg = args.v[j + arg_offset];
if (strcmp(arg, out.buf + k))
ret = error("incorrectly quoted arg: '%s', "
fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
for (j = 0; j < arg_count; j++)
fprintf(stderr, "arg #%d: '%s'\n",
- (int)j, args.argv[j + arg_offset]);
+ (int)j, args.v[j + arg_offset]);
strbuf_release(&out);
strvec_clear(&args);
{
if (!t)
return NULL;
- return t->env.argv;
+ return t->env.v;
}
void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
strvec_pushf(&helper->env_array, "%s=%s",
GIT_DIR_ENVIRONMENT, get_git_dir());
- helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
+ helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */
code = start_command(helper);
if (code < 0 && errno == ENOENT)
struct object *o = data->want_obj.objects[i].item;
strvec_push(&av, oid_to_hex(&o->oid));
}
- deepen_by_rev_list(data, av.argc, av.argv);
+ deepen_by_rev_list(data, av.nr, av.v);
strvec_clear(&av);
ret = 1;
} else {