strvec: convert remaining callers away from argv_array name

We eventually want to drop the argv_array name and just use strvec
consistently. There's no particular reason we have to do it all at once,
or care about interactions between converted and unconverted bits.
Because of our preprocessor compat layer, the names are interchangeable
to the compiler (so even a definition and declaration using different
names is OK).

This patch converts all of the remaining files, as the resulting diff is
reasonably sized.

The conversion was done purely mechanically with:

  git ls-files '*.c' '*.h' |
  xargs perl -i -pe '
    s/ARGV_ARRAY/STRVEC/g;
    s/argv_array/strvec/g;
  '

We'll deal with any indentation/style fallouts separately.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pull/825/merge
Jeff King 2 years ago committed by Junio C Hamano
parent ef8d7ac42a
commit c972bf4cf5
  1. 16
      merge.c
  2. 12
      midx.c
  3. 8
      pager.c
  4. 6
      parse-options-cb.c
  5. 6
      pathspec.c
  6. 4
      quote.c
  7. 10
      range-diff.c
  8. 2
      range-diff.h
  9. 6
      ref-filter.c
  10. 6
      refs.c
  11. 4
      refspec.c
  12. 86
      remote-curl.c
  13. 8
      remote-testsvn.c
  14. 12
      remote.c
  15. 14
      revision.c
  16. 50
      run-command.c
  17. 10
      run-command.h
  18. 18
      send-pack.c
  19. 112
      sequencer.c
  20. 12
      serve.c
  21. 14
      sha1-file.c
  22. 2
      sub-process.c
  23. 178
      submodule.c
  24. 36
      t/helper/test-run-command.c
  25. 16
      tmp-objdir.c
  26. 30
      transport-helper.c
  27. 2
      transport-internal.h
  28. 12
      transport.c
  29. 2
      transport.h
  30. 10
      unpack-trees.c
  31. 2
      unpack-trees.h
  32. 48
      upload-pack.c
  33. 16
      wt-status.c

@ -19,22 +19,22 @@ int try_merge_command(struct repository *r,
const char **xopts, struct commit_list *common,
const char *head_arg, struct commit_list *remotes)
{
struct argv_array args = ARGV_ARRAY_INIT;
struct strvec args = STRVEC_INIT;
int i, ret;
struct commit_list *j;
argv_array_pushf(&args, "merge-%s", strategy);
strvec_pushf(&args, "merge-%s", strategy);
for (i = 0; i < xopts_nr; i++)
argv_array_pushf(&args, "--%s", xopts[i]);
strvec_pushf(&args, "--%s", xopts[i]);
for (j = common; j; j = j->next)
argv_array_push(&args, merge_argument(j->item));
argv_array_push(&args, "--");
argv_array_push(&args, head_arg);
strvec_push(&args, merge_argument(j->item));
strvec_push(&args, "--");
strvec_push(&args, head_arg);
for (j = remotes; j; j = j->next)
argv_array_push(&args, merge_argument(j->item));
strvec_push(&args, merge_argument(j->item));
ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
argv_array_clear(&args);
strvec_clear(&args);
discard_index(r->index);
if (repo_read_index(r) < 0)

@ -1408,21 +1408,21 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
argv_array_push(&cmd.args, "pack-objects");
strvec_push(&cmd.args, "pack-objects");
strbuf_addstr(&base_name, object_dir);
strbuf_addstr(&base_name, "/pack/pack");
argv_array_push(&cmd.args, base_name.buf);
strvec_push(&cmd.args, base_name.buf);
if (delta_base_offset)
argv_array_push(&cmd.args, "--delta-base-offset");
strvec_push(&cmd.args, "--delta-base-offset");
if (use_delta_islands)
argv_array_push(&cmd.args, "--delta-islands");
strvec_push(&cmd.args, "--delta-islands");
if (flags & MIDX_PROGRESS)
argv_array_push(&cmd.args, "--progress");
strvec_push(&cmd.args, "--progress");
else
argv_array_push(&cmd.args, "-q");
strvec_push(&cmd.args, "-q");
strbuf_release(&base_name);

@ -68,7 +68,7 @@ const char *git_pager(int stdout_is_tty)
return pager;
}
static void setup_pager_env(struct argv_array *env)
static void setup_pager_env(struct strvec *env)
{
const char **argv;
int i;
@ -88,7 +88,7 @@ static void setup_pager_env(struct argv_array *env)
*cp = '\0';
if (!getenv(argv[i])) {
*cp = '=';
argv_array_push(env, argv[i]);
strvec_push(env, argv[i]);
}
}
free(pager_env);
@ -97,7 +97,7 @@ static void setup_pager_env(struct argv_array *env)
void prepare_pager_args(struct child_process *pager_process, const char *pager)
{
argv_array_push(&pager_process->args, pager);
strvec_push(&pager_process->args, pager);
pager_process->use_shell = 1;
setup_pager_env(&pager_process->env_array);
pager_process->trace2_child_class = "pager";
@ -126,7 +126,7 @@ void setup_pager(void)
/* spawn the pager */
prepare_pager_args(&pager_process, pager);
pager_process.in = -1;
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
if (start_command(&pager_process))
return;

@ -275,19 +275,19 @@ int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
/**
* For an option opt, recreate the command-line option, appending it to
* opt->value which must be a argv_array. This is useful when we need to pass
* opt->value which must be a strvec. This is useful when we need to pass
* the command-line option, which can be specified multiple times, to another
* command.
*/
int parse_opt_passthru_argv(const struct option *opt, const char *arg, int unset)
{
static struct strbuf sb = STRBUF_INIT;
struct argv_array *opt_value = opt->value;
struct strvec *opt_value = opt->value;
if (recreate_opt(&sb, opt, arg, unset) < 0)
return -1;
argv_array_push(opt_value, sb.buf);
strvec_push(opt_value, sb.buf);
return 0;
}

@ -624,7 +624,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
unsigned flags, const char *prefix,
const char *file, int nul_term_line)
{
struct argv_array parsed_file = ARGV_ARRAY_INIT;
struct strvec parsed_file = STRVEC_INIT;
strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul :
strbuf_getline;
struct strbuf buf = STRBUF_INIT;
@ -643,7 +643,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
die(_("line is badly quoted: %s"), buf.buf);
strbuf_swap(&buf, &unquoted);
}
argv_array_push(&parsed_file, buf.buf);
strvec_push(&parsed_file, buf.buf);
strbuf_reset(&buf);
}
@ -653,7 +653,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
fclose(in);
parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
argv_array_clear(&parsed_file);
strvec_clear(&parsed_file);
}
void copy_pathspec(struct pathspec *dst, const struct pathspec *src)

@ -172,7 +172,7 @@ char *sq_dequote(char *arg)
static int sq_dequote_to_argv_internal(char *arg,
const char ***argv, int *nr, int *alloc,
struct argv_array *array)
struct strvec *array)
{
char *next = arg;
@ -187,7 +187,7 @@ static int sq_dequote_to_argv_internal(char *arg,
(*argv)[(*nr)++] = dequoted;
}
if (array)
argv_array_push(array, dequoted);
strvec_push(array, dequoted);
} while (next);
return 0;

@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
* as struct object_id (will need to be free()d).
*/
static int read_patches(const char *range, struct string_list *list,
const struct argv_array *other_arg)
const struct strvec *other_arg)
{
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@ -51,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
int offset, len;
size_t size;
argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
"--reverse", "--date-order", "--decorate=no",
"--no-prefix",
/*
@ -67,8 +67,8 @@ static int read_patches(const char *range, struct string_list *list,
"--notes",
NULL);
if (other_arg)
argv_array_pushv(&cp.args, other_arg->argv);
argv_array_push(&cp.args, range);
strvec_pushv(&cp.args, other_arg->argv);
strvec_push(&cp.args, range);
cp.out = -1;
cp.no_stdin = 1;
cp.git_cmd = 1;
@ -523,7 +523,7 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
int show_range_diff(const char *range1, const char *range2,
int creation_factor, int dual_color,
const struct diff_options *diffopt,
const struct argv_array *other_arg)
const struct strvec *other_arg)
{
int res = 0;

@ -14,6 +14,6 @@
int show_range_diff(const char *range1, const char *range2,
int creation_factor, int dual_color,
const struct diff_options *diffopt,
const struct argv_array *other_arg);
const struct strvec *other_arg);
#endif

@ -1914,15 +1914,15 @@ static void find_longest_prefixes_1(struct string_list *out,
static void find_longest_prefixes(struct string_list *out,
const char **patterns)
{
struct argv_array sorted = ARGV_ARRAY_INIT;
struct strvec sorted = STRVEC_INIT;
struct strbuf prefix = STRBUF_INIT;
argv_array_pushv(&sorted, patterns);
strvec_pushv(&sorted, patterns);
QSORT(sorted.argv, sorted.argc, qsort_strcmp);
find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
argv_array_clear(&sorted);
strvec_clear(&sorted);
strbuf_release(&prefix);
}

@ -553,13 +553,13 @@ int refname_match(const char *abbrev_name, const char *full_name)
* Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
* the results to 'prefixes'
*/
void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
{
const char **p;
int len = strlen(prefix);
for (p = ref_rev_parse_rules; *p; p++)
argv_array_pushf(prefixes, *p, len, prefix);
strvec_pushf(prefixes, *p, len, prefix);
}
char *repo_default_branch_name(struct repository *r)
@ -2037,7 +2037,7 @@ static int run_transaction_hook(struct ref_transaction *transaction,
return ret;
}
argv_array_pushl(&proc.args, hook, state, NULL);
strvec_pushl(&proc.args, hook, state, NULL);
proc.in = -1;
proc.stdout_to_stderr = 1;
proc.trace2_hook_name = "reference-transaction";

@ -202,7 +202,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
}
void refspec_ref_prefixes(const struct refspec *rs,
struct argv_array *ref_prefixes)
struct strvec *ref_prefixes)
{
int i;
for (i = 0; i < rs->nr; i++) {
@ -221,7 +221,7 @@ void refspec_ref_prefixes(const struct refspec *rs,
if (prefix) {
if (item->pattern) {
const char *glob = strchr(prefix, '*');
argv_array_pushf(ref_prefixes, "%.*s",
strvec_pushf(ref_prefixes, "%.*s",
(int)(glob - prefix),
prefix);
} else {

@ -1141,41 +1141,41 @@ static int fetch_git(struct discovery *heads,
struct rpc_state rpc;
struct strbuf preamble = STRBUF_INIT;
int i, err;
struct argv_array args = ARGV_ARRAY_INIT;
struct strvec args = STRVEC_INIT;
struct strbuf rpc_result = STRBUF_INIT;
argv_array_pushl(&args, "fetch-pack", "--stateless-rpc",
strvec_pushl(&args, "fetch-pack", "--stateless-rpc",
"--stdin", "--lock-pack", NULL);
if (options.followtags)
argv_array_push(&args, "--include-tag");
strvec_push(&args, "--include-tag");
if (options.thin)
argv_array_push(&args, "--thin");
strvec_push(&args, "--thin");
if (options.verbosity >= 3)
argv_array_pushl(&args, "-v", "-v", NULL);
strvec_pushl(&args, "-v", "-v", NULL);
if (options.check_self_contained_and_connected)
argv_array_push(&args, "--check-self-contained-and-connected");
strvec_push(&args, "--check-self-contained-and-connected");
if (options.cloning)
argv_array_push(&args, "--cloning");
strvec_push(&args, "--cloning");
if (options.update_shallow)
argv_array_push(&args, "--update-shallow");
strvec_push(&args, "--update-shallow");
if (!options.progress)
argv_array_push(&args, "--no-progress");
strvec_push(&args, "--no-progress");
if (options.depth)
argv_array_pushf(&args, "--depth=%lu", options.depth);
strvec_pushf(&args, "--depth=%lu", options.depth);
if (options.deepen_since)
argv_array_pushf(&args, "--shallow-since=%s", options.deepen_since);
strvec_pushf(&args, "--shallow-since=%s", options.deepen_since);
for (i = 0; i < options.deepen_not.nr; i++)
argv_array_pushf(&args, "--shallow-exclude=%s",
strvec_pushf(&args, "--shallow-exclude=%s",
options.deepen_not.items[i].string);
if (options.deepen_relative && options.depth)
argv_array_push(&args, "--deepen-relative");
strvec_push(&args, "--deepen-relative");
if (options.from_promisor)
argv_array_push(&args, "--from-promisor");
strvec_push(&args, "--from-promisor");
if (options.no_dependents)
argv_array_push(&args, "--no-dependents");
strvec_push(&args, "--no-dependents");
if (options.filter)
argv_array_pushf(&args, "--filter=%s", options.filter);
argv_array_push(&args, url.buf);
strvec_pushf(&args, "--filter=%s", options.filter);
strvec_push(&args, url.buf);
for (i = 0; i < nr_heads; i++) {
struct ref *ref = to_fetch[i];
@ -1195,7 +1195,7 @@ static int fetch_git(struct discovery *heads,
write_or_die(1, rpc_result.buf, rpc_result.len);
strbuf_release(&rpc_result);
strbuf_release(&preamble);
argv_array_clear(&args);
strvec_clear(&args);
return err;
}
@ -1267,15 +1267,15 @@ static int push_dav(int nr_spec, const char **specs)
size_t i;
child.git_cmd = 1;
argv_array_push(&child.args, "http-push");
argv_array_push(&child.args, "--helper-status");
strvec_push(&child.args, "http-push");
strvec_push(&child.args, "--helper-status");
if (options.dry_run)
argv_array_push(&child.args, "--dry-run");
strvec_push(&child.args, "--dry-run");
if (options.verbosity > 1)
argv_array_push(&child.args, "--verbose");
argv_array_push(&child.args, url.buf);
strvec_push(&child.args, "--verbose");
strvec_push(&child.args, url.buf);
for (i = 0; i < nr_spec; i++)
argv_array_push(&child.args, specs[i]);
strvec_push(&child.args, specs[i]);
if (run_command(&child))
die(_("git-http-push failed"));
@ -1286,38 +1286,38 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
{
struct rpc_state rpc;
int i, err;
struct argv_array args;
struct strvec args;
struct string_list_item *cas_option;
struct strbuf preamble = STRBUF_INIT;
struct strbuf rpc_result = STRBUF_INIT;
argv_array_init(&args);
argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
strvec_init(&args);
strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
NULL);
if (options.thin)
argv_array_push(&args, "--thin");
strvec_push(&args, "--thin");
if (options.dry_run)
argv_array_push(&args, "--dry-run");
strvec_push(&args, "--dry-run");
if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS)
argv_array_push(&args, "--signed=yes");
strvec_push(&args, "--signed=yes");
else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED)
argv_array_push(&args, "--signed=if-asked");
strvec_push(&args, "--signed=if-asked");
if (options.atomic)
argv_array_push(&args, "--atomic");
strvec_push(&args, "--atomic");
if (options.verbosity == 0)
argv_array_push(&args, "--quiet");
strvec_push(&args, "--quiet");
else if (options.verbosity > 1)
argv_array_push(&args, "--verbose");
strvec_push(&args, "--verbose");
for (i = 0; i < options.push_options.nr; i++)
argv_array_pushf(&args, "--push-option=%s",
strvec_pushf(&args, "--push-option=%s",
options.push_options.items[i].string);
argv_array_push(&args, options.progress ? "--progress" : "--no-progress");
strvec_push(&args, options.progress ? "--progress" : "--no-progress");
for_each_string_list_item(cas_option, &cas_options)
argv_array_push(&args, cas_option->string);
argv_array_push(&args, url.buf);
strvec_push(&args, cas_option->string);
strvec_push(&args, url.buf);
argv_array_push(&args, "--stdin");
strvec_push(&args, "--stdin");
for (i = 0; i < nr_spec; i++)
packet_buf_write(&preamble, "%s\n", specs[i]);
packet_buf_flush(&preamble);
@ -1330,7 +1330,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
write_or_die(1, rpc_result.buf, rpc_result.len);
strbuf_release(&rpc_result);
strbuf_release(&preamble);
argv_array_clear(&args);
strvec_clear(&args);
return err;
}
@ -1349,13 +1349,13 @@ static int push(int nr_spec, const char **specs)
static void parse_push(struct strbuf *buf)
{
struct argv_array specs = ARGV_ARRAY_INIT;
struct strvec specs = STRVEC_INIT;
int ret;
do {
const char *arg;
if (skip_prefix(buf->buf, "push ", &arg))
argv_array_push(&specs, arg);
strvec_push(&specs, arg);
else
die(_("http transport does not support %s"), buf->buf);
@ -1374,7 +1374,7 @@ static void parse_push(struct strbuf *buf)
exit(128); /* error already reported */
free_specs:
argv_array_clear(&specs);
strvec_clear(&specs);
}
static int stateless_connect(const char *service_name)

@ -198,10 +198,10 @@ static int cmd_import(const char *line)
die_errno("Couldn't open svn dump file %s.", url);
} else {
svndump_proc.out = -1;
argv_array_push(&svndump_proc.args, command);
argv_array_push(&svndump_proc.args, "dump");
argv_array_push(&svndump_proc.args, url);
argv_array_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
strvec_push(&svndump_proc.args, command);
strvec_push(&svndump_proc.args, "dump");
strvec_push(&svndump_proc.args, url);
strvec_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
code = start_command(&svndump_proc);
if (code)

@ -1885,7 +1885,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
struct object_id oid;
struct commit *ours, *theirs;
struct rev_info revs;
struct argv_array argv = ARGV_ARRAY_INIT;
struct strvec argv = STRVEC_INIT;
/* Cannot stat if what we used to build on no longer exists */
if (read_ref(base, &oid))
@ -1911,12 +1911,12 @@ static int stat_branch_pair(const char *branch_name, const char *base,
BUG("stat_branch_pair: invalid abf '%d'", abf);
/* Run "rev-list --left-right ours...theirs" internally... */
argv_array_push(&argv, ""); /* ignored */
argv_array_push(&argv, "--left-right");
argv_array_pushf(&argv, "%s...%s",
strvec_push(&argv, ""); /* ignored */
strvec_push(&argv, "--left-right");
strvec_pushf(&argv, "%s...%s",
oid_to_hex(&ours->object.oid),
oid_to_hex(&theirs->object.oid));
argv_array_push(&argv, "--");
strvec_push(&argv, "--");
repo_init_revisions(the_repository, &revs, NULL);
setup_revisions(argv.argc, argv.argv, &revs, NULL);
@ -1938,7 +1938,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
clear_commit_marks(ours, ALL_REV_FLAGS);
clear_commit_marks(theirs, ALL_REV_FLAGS);
argv_array_clear(&argv);
strvec_clear(&argv);
return 1;
}

@ -2073,14 +2073,14 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
}
static void read_pathspec_from_stdin(struct strbuf *sb,
struct argv_array *prune)
struct strvec *prune)
{
while (strbuf_getline(sb, stdin) != EOF)
argv_array_push(prune, sb->buf);
strvec_push(prune, sb->buf);
}
static void read_revisions_from_stdin(struct rev_info *revs,
struct argv_array *prune)
struct strvec *prune)
{
struct strbuf sb;
int seen_dashdash = 0;
@ -2675,7 +2675,7 @@ static void NORETURN diagnose_missing_default(const char *def)
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
{
int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
struct argv_array prune_data = ARGV_ARRAY_INIT;
struct strvec prune_data = STRVEC_INIT;
const char *submodule = NULL;
int seen_end_of_options = 0;
@ -2694,7 +2694,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
argv[i] = NULL;
argc = i;
if (argv[i + 1])
argv_array_pushv(&prune_data, argv + i + 1);
strvec_pushv(&prune_data, argv + i + 1);
seen_dashdash = 1;
break;
}
@ -2760,7 +2760,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
for (j = i; j < argc; j++)
verify_filename(revs->prefix, argv[j], j == i);
argv_array_pushv(&prune_data, argv + i);
strvec_pushv(&prune_data, argv + i);
break;
}
else
@ -2785,7 +2785,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
parse_pathspec(&revs->prune_data, 0, 0,
revs->prefix, prune_data.argv);
}
argv_array_clear(&prune_data);
strvec_clear(&prune_data);
if (revs->def == NULL)
revs->def = opt ? opt->def : NULL;

@ -11,14 +11,14 @@
void child_process_init(struct child_process *child)
{
memset(child, 0, sizeof(*child));
argv_array_init(&child->args);
argv_array_init(&child->env_array);
strvec_init(&child->args);
strvec_init(&child->env_array);
}
void child_process_clear(struct child_process *child)
{
argv_array_clear(&child->args);
argv_array_clear(&child->env_array);
strvec_clear(&child->args);
strvec_clear(&child->env_array);
}
struct child_to_clean {
@ -263,30 +263,30 @@ int sane_execvp(const char *file, char * const argv[])
return -1;
}
static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
{
if (!argv[0])
BUG("shell command is empty");
if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
#ifndef GIT_WINDOWS_NATIVE
argv_array_push(out, SHELL_PATH);
strvec_push(out, SHELL_PATH);
#else
argv_array_push(out, "sh");
strvec_push(out, "sh");
#endif
argv_array_push(out, "-c");
strvec_push(out, "-c");
/*
* If we have no extra arguments, we do not even need to
* bother with the "$@" magic.
*/
if (!argv[1])
argv_array_push(out, argv[0]);
strvec_push(out, argv[0]);
else
argv_array_pushf(out, "%s \"$@\"", argv[0]);
strvec_pushf(out, "%s \"$@\"", argv[0]);
}
argv_array_pushv(out, argv);
strvec_pushv(out, argv);
return out->argv;
}
@ -401,7 +401,7 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
set_error_routine(old_errfn);
}
static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
{
if (!cmd->argv[0])
BUG("command is empty");
@ -410,14 +410,14 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
* Add SHELL_PATH so in the event exec fails with ENOEXEC we can
* attempt to interpret the command with 'sh'.
*/
argv_array_push(out, SHELL_PATH);
strvec_push(out, SHELL_PATH);
if (cmd->git_cmd) {
prepare_git_cmd(out, cmd->argv);
} else if (cmd->use_shell) {
prepare_shell_cmd(out, cmd->argv);
} else {
argv_array_pushv(out, cmd->argv);
strvec_pushv(out, cmd->argv);
}
/*
@ -432,7 +432,7 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
free((char *)out->argv[1]);
out->argv[1] = program;
} else {
argv_array_clear(out);
strvec_clear(out);
errno = ENOENT;
return -1;
}
@ -742,7 +742,7 @@ fail_pipe:
int notify_pipe[2];
int null_fd = -1;
char **childenv;
struct argv_array argv = ARGV_ARRAY_INIT;
struct strvec argv = STRVEC_INIT;
struct child_err cerr;
struct atfork_state as;
@ -888,7 +888,7 @@ fail_pipe:
if (null_fd >= 0)
close(null_fd);
argv_array_clear(&argv);
strvec_clear(&argv);
free(childenv);
}
end_of_spawn:
@ -897,7 +897,7 @@ end_of_spawn:
{
int fhin = 0, fhout = 1, fherr = 2;
const char **sargv = cmd->argv;
struct argv_array nargv = ARGV_ARRAY_INIT;
struct strvec nargv = STRVEC_INIT;
if (cmd->no_stdin)
fhin = open("/dev/null", O_RDWR);
@ -935,7 +935,7 @@ end_of_spawn:
if (cmd->clean_on_exit && cmd->pid >= 0)
mark_child_for_cleanup(cmd->pid, cmd);
argv_array_clear(&nargv);
strvec_clear(&nargv);
cmd->argv = sargv;
if (fhin != 0)
close(fhin);
@ -1352,9 +1352,9 @@ int run_hook_ve(const char *const *env, const char *name, va_list args)
if (!p)
return 0;
argv_array_push(&hook.args, p);
strvec_push(&hook.args, p);
while ((p = va_arg(args, const char *)))
argv_array_push(&hook.args, p);
strvec_push(&hook.args, p);
hook.env = env;
hook.no_stdin = 1;
hook.stdout_to_stderr = 1;
@ -1868,13 +1868,13 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
int run_auto_gc(int quiet)
{
struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
struct strvec argv_gc_auto = STRVEC_INIT;
int status;
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
if (quiet)
argv_array_push(&argv_gc_auto, "--quiet");
strvec_push(&argv_gc_auto, "--quiet");
status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
argv_array_clear(&argv_gc_auto);
strvec_clear(&argv_gc_auto);
return status;
}

@ -52,15 +52,15 @@ struct child_process {
* Note that the ownership of the memory pointed to by .argv stays with the
* caller, but it should survive until `finish_command` completes. If the
* .argv member is NULL, `start_command` will point it at the .args
* `argv_array` (so you may use one or the other, but you must use exactly
* `strvec` (so you may use one or the other, but you must use exactly
* one). The memory in .args will be cleaned up automatically during
* `finish_command` (or during `start_command` when it is unsuccessful).
*
*/
const char **argv;
struct argv_array args;
struct argv_array env_array;
struct strvec args;
struct strvec env_array;
pid_t pid;
int trace2_child_id;
@ -107,7 +107,7 @@ struct child_process {
* variable that will be removed from the child process's environment.
*
* If the .env member is NULL, `start_command` will point it at the
* .env_array `argv_array` (so you may use one or the other, but not both).
* .env_array `strvec` (so you may use one or the other, but not both).
* The memory in .env_array will be cleaned up automatically during
* `finish_command` (or during `start_command` when it is unsuccessful).
*/
@ -134,7 +134,7 @@ struct child_process {
void *clean_on_exit_handler_cbdata;
};
#define CHILD_PROCESS_INIT { NULL, ARGV_ARRAY_INIT, ARGV_ARRAY_INIT }
#define CHILD_PROCESS_INIT { NULL, STRVEC_INIT, STRVEC_INIT }
/**
* The functions: child_process_init, start_command, finish_command,

@ -68,20 +68,20 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
int i;
int rc;
argv_array_push(&po.args, "pack-objects");
argv_array_push(&po.args, "--all-progress-implied");
argv_array_push(&po.args, "--revs");
argv_array_push(&po.args, "--stdout");
strvec_push(&po.args, "pack-objects");
strvec_push(&po.args, "--all-progress-implied");
strvec_push(&po.args, "--revs");
strvec_push(&po.args, "--stdout");
if (args->use_thin_pack)
argv_array_push(&po.args, "--thin");
strvec_push(&po.args, "--thin");
if (args->use_ofs_delta)
argv_array_push(&po.args, "--delta-base-offset");
strvec_push(&po.args, "--delta-base-offset");
if (args->quiet || !args->progress)
argv_array_push(&po.args, "-q");
strvec_push(&po.args, "-q");
if (args->progress)
argv_array_push(&po.args, "--progress");
strvec_push(&po.args, "--progress");
if (is_repository_shallow(the_repository))
argv_array_push(&po.args, "--shallow");
strvec_push(&po.args, "--shallow");
po.in = -1;
po.out = args->stateless_rpc ? -1 : fd;
po.git_cmd = 1;

@ -830,10 +830,10 @@ finish:
/*
* Read a GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL AND GIT_AUTHOR_DATE from a
* file with shell quoting into struct argv_array. Returns -1 on
* file with shell quoting into struct strvec. Returns -1 on
* error, 0 otherwise.
*/
static int read_env_script(struct argv_array *env)
static int read_env_script(struct strvec *env)
{
char *name, *email, *date;
@ -841,9 +841,9 @@ static int read_env_script(struct argv_array *env)
&name, &email, &date, 0))
return -1;
argv_array_pushf(env, "GIT_AUTHOR_NAME=%s", name);
argv_array_pushf(env, "GIT_AUTHOR_EMAIL=%s", email);
argv_array_pushf(env, "GIT_AUTHOR_DATE=%s", date);
strvec_pushf(env, "GIT_AUTHOR_NAME=%s", name);
strvec_pushf(env, "GIT_AUTHOR_EMAIL=%s", email);
strvec_pushf(env, "GIT_AUTHOR_DATE=%s", date);
free(name);
free(email);
free(date);
@ -929,34 +929,34 @@ static int run_git_commit(struct repository *r,
gpg_opt, gpg_opt);
}
argv_array_push(&cmd.args, "commit");
strvec_push(&cmd.args, "commit");
if (!(flags & VERIFY_MSG))
argv_array_push(&cmd.args, "-n");
strvec_push(&cmd.args, "-n");
if ((flags & AMEND_MSG))
argv_array_push(&cmd.args, "--amend");
strvec_push(&cmd.args, "--amend");
if (opts->gpg_sign)
argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
else
argv_array_push(&cmd.args, "--no-gpg-sign");
strvec_push(&cmd.args, "--no-gpg-sign");
if (defmsg)
argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
strvec_pushl(&cmd.args, "-F", defmsg, NULL);
else if (!(flags & EDIT_MSG))
argv_array_pushl(&cmd.args, "-C", "HEAD", NULL);
strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
if ((flags & CLEANUP_MSG))
argv_array_push(&cmd.args, "--cleanup=strip");
strvec_push(&cmd.args, "--cleanup=strip");
if ((flags & EDIT_MSG))
argv_array_push(&cmd.args, "-e");
strvec_push(&cmd.args, "-e");
else if (!(flags & CLEANUP_MSG) &&
!opts->signoff && !opts->record_origin &&
!opts->explicit_cleanup)
argv_array_push(&cmd.args, "--cleanup=verbatim");
strvec_push(&cmd.args, "--cleanup=verbatim");
if ((flags & ALLOW_EMPTY))
argv_array_push(&cmd.args, "--allow-empty");
strvec_push(&cmd.args, "--allow-empty");
if (!(flags & EDIT_MSG))
argv_array_push(&cmd.args, "--allow-empty-message");
strvec_push(&cmd.args, "--allow-empty-message");
if (is_rebase_i(opts) && !(flags & EDIT_MSG))
return run_command_silent_on_success(&cmd);
@ -2754,15 +2754,15 @@ static int rollback_is_safe(void)
static int reset_merge(const struct object_id *oid)
{
int ret;
struct argv_array argv = ARGV_ARRAY_INIT;
struct strvec argv = STRVEC_INIT;
argv_array_pushl(&argv, "reset", "--merge", NULL);
strvec_pushl(&argv, "reset", "--merge", NULL);
if (!is_null_oid(oid))
argv_array_push(&argv, oid_to_hex(oid));
strvec_push(&argv, oid_to_hex(oid));
ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
argv_array_clear(&argv);
strvec_clear(&argv);
return ret;
}
@ -3125,14 +3125,14 @@ static int error_failed_squash(struct repository *r,
static int do_exec(struct repository *r, const char *command_line)
{
struct argv_array child_env = ARGV_ARRAY_INIT;
struct strvec child_env = STRVEC_INIT;
const char *child_argv[] = { NULL, NULL };
int dirty, status;
fprintf(stderr, _("Executing: %s\n"), command_line);
child_argv[0] = command_line;
argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
argv_array_pushf(&child_env, "GIT_WORK_TREE=%s",
strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
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);
@ -3165,7 +3165,7 @@ static int do_exec(struct repository *r, const char *command_line)
status = 1;
}
argv_array_clear(&child_env);
strvec_clear(&child_env);
return status;
}
@ -3544,28 +3544,28 @@ static int do_merge(struct repository *r,
}
cmd.git_cmd = 1;
argv_array_push(&cmd.args, "merge");
argv_array_push(&cmd.args, "-s");
strvec_push(&cmd.args, "merge");
strvec_push(&cmd.args, "-s");
if (!strategy)
argv_array_push(&cmd.args, "octopus");
strvec_push(&cmd.args, "octopus");
else {
argv_array_push(&cmd.args, strategy);
strvec_push(&cmd.args, strategy);
for (k = 0; k < opts->xopts_nr; k++)
argv_array_pushf(&cmd.args,
strvec_pushf(&cmd.args,
"-X%s", opts->xopts[k]);
}
argv_array_push(&cmd.args, "--no-edit");
argv_array_push(&cmd.args, "--no-ff");
argv_array_push(&cmd.args, "--no-log");
argv_array_push(&cmd.args, "--no-stat");
argv_array_push(&cmd.args, "-F");
argv_array_push(&cmd.args, git_path_merge_msg(r));
strvec_push(&cmd.args, "--no-edit");
strvec_push(&cmd.args, "--no-ff");
strvec_push(&cmd.args, "--no-log");
strvec_push(&cmd.args, "--no-stat");
strvec_push(&cmd.args, "-F");
strvec_push(&cmd.args, git_path_merge_msg(r));
if (opts->gpg_sign)
argv_array_push(&cmd.args, opts->gpg_sign);
strvec_push(&cmd.args, opts->gpg_sign);
/* Add the tips to be merged */
for (j = to_merge; j; j = j->next)
argv_array_push(&cmd.args,
strvec_push(&cmd.args,
oid_to_hex(&j->item->object.oid));
strbuf_release(&ref_name);
@ -3694,7 +3694,7 @@ void create_autostash(struct repository *r, const char *path,
struct child_process stash = CHILD_PROCESS_INIT;
struct object_id oid;
argv_array_pushl(&stash.args,
strvec_pushl(&stash.args,
"stash", "create", "autostash", NULL);
stash.git_cmd = 1;
stash.no_stdin = 1;
@ -3734,9 +3734,9 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
child.git_cmd = 1;
child.no_stdout = 1;
child.no_stderr = 1;
argv_array_push(&child.args, "stash");
argv_array_push(&child.args, "apply");
argv_array_push(&child.args, stash_oid);
strvec_push(&child.args, "stash");
strvec_push(&child.args, "apply");
strvec_push(&child.args, stash_oid);
ret = run_command(&child);
}
@ -3746,12 +3746,12 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
struct child_process store = CHILD_PROCESS_INIT;
store.git_cmd = 1;
argv_array_push(&store.args, "stash");
argv_array_push(&store.args, "store");
argv_array_push(&store.args, "-m");
argv_array_push(&store.args, "autostash");
argv_array_push(&store.args, "-q");
argv_array_push(&store.args, stash_oid);
strvec_push(&store.args, "stash");
strvec_push(&store.args, "store");
strvec_push(&store.args, "-m");
strvec_push(&store.args, "autostash");
strvec_push(&store.args, "-q");
strvec_push(&store.args, stash_oid);
if (run_command(&store))
ret = error(_("cannot store %s"), stash_oid);
else
@ -3831,9 +3831,9 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
cmd.git_cmd = 1;
argv_array_push(&cmd.args, "checkout");
argv_array_push(&cmd.args, commit);
argv_array_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
strvec_push(&cmd.args, "checkout");
strvec_push(&cmd.args, commit);
strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
if (opts->verbose)
ret = run_command(&cmd);
@ -4157,9 +4157,9 @@ cleanup_head_ref:
child.in = open(rebase_path_rewritten_list(), O_RDONLY);
child.git_cmd = 1;
argv_array_push(&child.args, "notes");
argv_array_push(&child.args, "copy");
argv_array_push(&child.args, "--for-rewrite=rebase");
strvec_push(&child.args, "notes");
strvec_push(&child.args, "copy");
strvec_push(&child.args, "--for-rewrite=rebase");
/* we don't care if this copying failed */
run_command(&child);
@ -4170,8 +4170,8 @@ cleanup_head_ref:
O_RDONLY);
hook.stdout_to_stderr = 1;
hook.trace2_hook_name = "post-rewrite";
argv_array_push(&hook.args, post_rewrite_hook);
argv_array_push(&hook.args, "rebase");
strvec_push(&hook.args, post_rewrite_hook);
strvec_push(&hook.args, "rebase");
/* we don't care if this hook failed */
run_command(&hook);
}

@ -56,7 +56,7 @@ struct protocol_capability {
* This field should be NULL for capabilities which are not commands.
*/
int (*command)(struct repository *r,
struct argv_array *keys,
struct strvec *keys,
struct packet_reader *request);
};
@ -142,7 +142,7 @@ static int is_command(const char *key, struct protocol_capability **command)
return 0;
}
int has_capability(const struct argv_array *keys, const char *capability,
int has_capability(const struct strvec *keys, const char *capability,
const char **value)
{
int i;
@ -162,7 +162,7 @@ int has_capability(const struct argv_array *keys, const char *capability,
return 0;
}
static void check_algorithm(struct repository *r, struct argv_array *keys)
static void check_algorithm(struct repository *r, struct strvec *keys)
{
int client = GIT_HASH_SHA1, server = hash_algo_by_ptr(r->hash_algo);
const char *algo_name;
@ -187,7 +187,7 @@ static int process_request(void)
{
enum request_state state = PROCESS_REQUEST_KEYS;
struct packet_reader reader;
struct argv_array keys = ARGV_ARRAY_INIT;
struct strvec keys = STRVEC_INIT;
struct protocol_capability *command = NULL;
packet_reader_init(&reader, 0, NULL, 0,
@ -211,7 +211,7 @@ static int process_request(void)
/* collect request; a sequence of keys and values */
if (is_command(reader.line, &command) ||
is_valid_capability(reader.line))
argv_array_push(&keys, reader.line);
strvec_push(&keys, reader.line);
else
die("unknown capability '%s'", reader.line);
@ -254,7 +254,7 @@ static int process_request(void)
command->command(the_repository, &keys, &reader);
argv_array_clear(&keys);
strvec_clear(&keys);
return 0;
}