From dbbcd44fb47347a3fdbee88ea21805b7f4ac0b98 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:23:39 -0400 Subject: strvec: rename files from argv-array to strvec This requires updating #include lines across the code-base, but that's all fairly mechanical, and was done with: git ls-files '*.c' '*.h' | xargs perl -i -pe 's/argv-array.h/strvec.h/' Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- add-patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'add-patch.c') diff --git a/add-patch.c b/add-patch.c index f899389e2c..09d00c5574 100644 --- a/add-patch.c +++ b/add-patch.c @@ -2,7 +2,7 @@ #include "add-interactive.h" #include "strbuf.h" #include "run-command.h" -#include "argv-array.h" +#include "strvec.h" #include "pathspec.h" #include "color.h" #include "diff.h" -- cgit v1.2.3 From ef8d7ac42a6a62d678166fe25ea743315809d2bb Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:24:53 -0400 Subject: strvec: convert more 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 remaining files from the first half of the alphabet, to keep the diff to a manageable size. 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; ' and then selectively staging files with "git add '[abcdefghjkl]*'". We'll deal with any indentation/style fallouts separately. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- add-interactive.c | 14 +++++++------- add-patch.c | 28 ++++++++++++++-------------- bisect.c | 12 ++++++------ bundle.c | 12 ++++++------ bundle.h | 2 +- column.c | 12 ++++++------ commit.c | 8 ++++---- compat/mingw.c | 4 ++-- compat/terminal.c | 18 +++++++++--------- connect.c | 48 ++++++++++++++++++++++++------------------------ connected.c | 22 +++++++++++----------- daemon.c | 52 ++++++++++++++++++++++++++-------------------------- diff.c | 28 ++++++++++++++-------------- environment.c | 8 ++++---- exec-cmd.c | 10 +++++----- fast-import.c | 4 ++-- fetch-pack.c | 34 +++++++++++++++++----------------- fsmonitor.c | 6 +++--- git.c | 22 +++++++++++----------- gpg-interface.c | 8 ++++---- graph.c | 10 +++++----- http-backend.c | 4 ++-- http-push.c | 12 ++++++------ http.c | 6 +++--- imap-send.c | 2 +- line-log.c | 6 +++--- ls-refs.c | 10 +++++----- 27 files changed, 201 insertions(+), 201 deletions(-) (limited to 'add-patch.c') diff --git a/add-interactive.c b/add-interactive.c index 29cd2fe020..b345777d0c 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -935,18 +935,18 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps, opts->prompt = N_("Patch update"); count = list_and_choose(s, files, opts); if (count > 0) { - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; struct pathspec ps_selected = { 0 }; for (i = 0; i < files->items.nr; i++) if (files->selected[i]) - argv_array_push(&args, + strvec_push(&args, files->items.items[i].string); parse_pathspec(&ps_selected, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL, PATHSPEC_LITERAL_PATH, "", args.argv); res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected); - argv_array_clear(&args); + strvec_clear(&args); clear_pathspec(&ps_selected); } @@ -976,18 +976,18 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, count = list_and_choose(s, files, opts); opts->flags = 0; if (count > 0) { - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; - argv_array_pushl(&args, "git", "diff", "-p", "--cached", + strvec_pushl(&args, "git", "diff", "-p", "--cached", oid_to_hex(!is_initial ? &oid : s->r->hash_algo->empty_tree), "--", NULL); for (i = 0; i < files->items.nr; i++) if (files->selected[i]) - argv_array_push(&args, + strvec_push(&args, files->items.items[i].string); res = run_command_v_opt(args.argv, 0); - argv_array_clear(&args); + strvec_clear(&args); } putchar('\n'); diff --git a/add-patch.c b/add-patch.c index 09d00c5574..3c91ae52ae 100644 --- a/add-patch.c +++ b/add-patch.c @@ -286,11 +286,11 @@ static void setup_child_process(struct add_p_state *s, va_start(ap, cp); while ((arg = va_arg(ap, const char *))) - argv_array_push(&cp->args, arg); + strvec_push(&cp->args, arg); va_end(ap); cp->git_cmd = 1; - argv_array_pushf(&cp->env_array, + strvec_pushf(&cp->env_array, INDEX_ENVIRONMENT "=%s", s->s.r->index_file); } @@ -370,7 +370,7 @@ static int is_octal(const char *p, size_t len) static int parse_diff(struct add_p_state *s, const struct pathspec *ps) { - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; const char *diff_algorithm = s->s.interactive_diff_algorithm; struct strbuf *plain = &s->plain, *colored = NULL; struct child_process cp = CHILD_PROCESS_INIT; @@ -380,12 +380,12 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) struct hunk *hunk = NULL; int res; - argv_array_pushv(&args, s->mode->diff_cmd); + strvec_pushv(&args, s->mode->diff_cmd); if (diff_algorithm) - argv_array_pushf(&args, "--diff-algorithm=%s", diff_algorithm); + strvec_pushf(&args, "--diff-algorithm=%s", diff_algorithm); if (s->revision) { struct object_id oid; - argv_array_push(&args, + strvec_push(&args, /* could be on an unborn branch */ !strcmp("HEAD", s->revision) && get_oid("HEAD", &oid) ? @@ -393,19 +393,19 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) } color_arg_index = args.argc; /* Use `--no-color` explicitly, just in case `diff.color = always`. */ - argv_array_pushl(&args, "--no-color", "-p", "--", NULL); + strvec_pushl(&args, "--no-color", "-p", "--", NULL); for (i = 0; i < ps->nr; i++) - argv_array_push(&args, ps->items[i].original); + strvec_push(&args, ps->items[i].original); setup_child_process(s, &cp, NULL); cp.argv = args.argv; res = capture_command(&cp, plain, 0); if (res) { - argv_array_clear(&args); + strvec_clear(&args); return error(_("could not parse diff")); } if (!plain->len) { - argv_array_clear(&args); + strvec_clear(&args); return 0; } strbuf_complete_line(plain); @@ -419,7 +419,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) colored_cp.argv = args.argv; colored = &s->colored; res = capture_command(&colored_cp, colored, 0); - argv_array_clear(&args); + strvec_clear(&args); if (res) return error(_("could not parse colored diff")); @@ -444,7 +444,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) colored_p = colored->buf; colored_pend = colored_p + colored->len; } - argv_array_clear(&args); + strvec_clear(&args); /* parse files and hunks */ p = plain->buf; @@ -1158,7 +1158,7 @@ static int run_apply_check(struct add_p_state *s, setup_child_process(s, &cp, "apply", "--check", NULL); - argv_array_pushv(&cp.args, s->mode->apply_check_args); + strvec_pushv(&cp.args, s->mode->apply_check_args); if (pipe_command(&cp, s->buf.buf, s->buf.len, NULL, 0, NULL, 0)) return error(_("'git apply --cached' failed")); @@ -1619,7 +1619,7 @@ soft_increment: s->mode->is_reverse); else { setup_child_process(s, &cp, "apply", NULL); - argv_array_pushv(&cp.args, s->mode->apply_args); + strvec_pushv(&cp.args, s->mode->apply_args); if (pipe_command(&cp, s->buf.buf, s->buf.len, NULL, 0, NULL, 0)) error(_("'git apply' failed")); diff --git a/bisect.c b/bisect.c index 77e35ddd43..3e50b51c11 100644 --- a/bisect.c +++ b/bisect.c @@ -456,7 +456,7 @@ static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") static GIT_PATH_FUNC(git_path_head_name, "head-name") -static void read_bisect_paths(struct argv_array *array) +static void read_bisect_paths(struct strvec *array) { struct strbuf str = STRBUF_INIT; const char *filename = git_path_bisect_names(); @@ -632,7 +632,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, const char *bad_format, const char *good_format, int read_paths) { - struct argv_array rev_argv = ARGV_ARRAY_INIT; + struct strvec rev_argv = STRVEC_INIT; int i; repo_init_revisions(r, revs, prefix); @@ -640,12 +640,12 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, revs->commit_format = CMIT_FMT_UNSPECIFIED; /* rev_argv.argv[0] will be ignored by setup_revisions */ - argv_array_push(&rev_argv, "bisect_rev_setup"); - argv_array_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid)); + strvec_push(&rev_argv, "bisect_rev_setup"); + strvec_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid)); for (i = 0; i < good_revs.nr; i++) - argv_array_pushf(&rev_argv, good_format, + strvec_pushf(&rev_argv, good_format, oid_to_hex(good_revs.oid + i)); - argv_array_push(&rev_argv, "--"); + strvec_push(&rev_argv, "--"); if (read_paths) read_bisect_paths(&rev_argv); diff --git a/bundle.c b/bundle.c index d46a387e66..709b2abc9c 100644 --- a/bundle.c +++ b/bundle.c @@ -269,16 +269,16 @@ out: /* Write the pack data to bundle_fd */ -static int write_pack_data(int bundle_fd, struct rev_info *revs, struct argv_array *pack_options) +static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options) { struct child_process pack_objects = CHILD_PROCESS_INIT; int i; - argv_array_pushl(&pack_objects.args, + strvec_pushl(&pack_objects.args, "pack-objects", "--stdout", "--thin", "--delta-base-offset", NULL); - argv_array_pushv(&pack_objects.args, pack_options->argv); + strvec_pushv(&pack_objects.args, pack_options->argv); pack_objects.in = -1; pack_objects.out = bundle_fd; pack_objects.git_cmd = 1; @@ -321,11 +321,11 @@ static int compute_and_write_prerequisites(int bundle_fd, FILE *rls_fout; int i; - argv_array_pushl(&rls.args, + strvec_pushl(&rls.args, "rev-list", "--boundary", "--pretty=oneline", NULL); for (i = 1; i < argc; i++) - argv_array_push(&rls.args, argv[i]); + strvec_push(&rls.args, argv[i]); rls.out = -1; rls.git_cmd = 1; if (start_command(&rls)) @@ -449,7 +449,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) } int create_bundle(struct repository *r, const char *path, - int argc, const char **argv, struct argv_array *pack_options) + int argc, const char **argv, struct strvec *pack_options) { struct lock_file lock = LOCK_INIT; int bundle_fd = -1; diff --git a/bundle.h b/bundle.h index 2cf1270092..3f5c9ad220 100644 --- a/bundle.h +++ b/bundle.h @@ -21,7 +21,7 @@ struct bundle_header { int is_bundle(const char *path, int quiet); int read_bundle_header(const char *path, struct bundle_header *header); int create_bundle(struct repository *r, const char *path, - int argc, const char **argv, struct argv_array *pack_options); + int argc, const char **argv, struct strvec *pack_options); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); #define BUNDLE_VERBOSE 1 int unbundle(struct repository *r, struct bundle_header *header, diff --git a/column.c b/column.c index 4a38eed322..a79c2621b0 100644 --- a/column.c +++ b/column.c @@ -358,7 +358,7 @@ static struct child_process column_process = CHILD_PROCESS_INIT; int run_column_filter(int colopts, const struct column_options *opts) { - struct argv_array *argv; + struct strvec *argv; if (fd_out != -1) return -1; @@ -366,14 +366,14 @@ int run_column_filter(int colopts, const struct column_options *opts) child_process_init(&column_process); argv = &column_process.args; - argv_array_push(argv, "column"); - argv_array_pushf(argv, "--raw-mode=%d", colopts); + strvec_push(argv, "column"); + strvec_pushf(argv, "--raw-mode=%d", colopts); if (opts && opts->width) - argv_array_pushf(argv, "--width=%d", opts->width); + strvec_pushf(argv, "--width=%d", opts->width); if (opts && opts->indent) - argv_array_pushf(argv, "--indent=%s", opts->indent); + strvec_pushf(argv, "--indent=%s", opts->indent); if (opts && opts->padding) - argv_array_pushf(argv, "--padding=%d", opts->padding); + strvec_pushf(argv, "--padding=%d", opts->padding); fflush(stdout); column_process.in = -1; diff --git a/commit.c b/commit.c index 7128895c3a..a5176a25bd 100644 --- a/commit.c +++ b/commit.c @@ -1630,22 +1630,22 @@ size_t ignore_non_trailer(const char *buf, size_t len) int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...) { - struct argv_array hook_env = ARGV_ARRAY_INIT; + struct strvec hook_env = STRVEC_INIT; va_list args; int ret; - argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file); + strvec_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file); /* * Let the hook know that no editor will be launched. */ if (!editor_is_used) - argv_array_push(&hook_env, "GIT_EDITOR=:"); + strvec_push(&hook_env, "GIT_EDITOR=:"); va_start(args, name); ret = run_hook_ve(hook_env.argv,name, args); va_end(args); - argv_array_clear(&hook_env); + strvec_clear(&hook_env); return ret; } diff --git a/compat/mingw.c b/compat/mingw.c index 8ee0b6408e..4454b3e67b 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -18,8 +18,8 @@ void open_in_gdb(void) static struct child_process cp = CHILD_PROCESS_INIT; extern char *_pgmptr; - argv_array_pushl(&cp.args, "mintty", "gdb", NULL); - argv_array_pushf(&cp.args, "--pid=%d", getpid()); + strvec_pushl(&cp.args, "mintty", "gdb", NULL); + strvec_pushf(&cp.args, "--pid=%d", getpid()); cp.clean_on_exit = 1; if (start_command(&cp) < 0) die_errno("Could not start gdb"); diff --git a/compat/terminal.c b/compat/terminal.c index 35bca03d14..43b73ddc75 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -86,9 +86,9 @@ static void restore_term(void) if (stty_restore.nr == 0) return; - argv_array_push(&cp.args, "stty"); + strvec_push(&cp.args, "stty"); for (i = 0; i < stty_restore.nr; i++) - argv_array_push(&cp.args, stty_restore.items[i].string); + strvec_push(&cp.args, stty_restore.items[i].string); run_command(&cp); string_list_clear(&stty_restore, 0); return; @@ -107,25 +107,25 @@ static int disable_bits(DWORD bits) if (use_stty) { struct child_process cp = CHILD_PROCESS_INIT; - argv_array_push(&cp.args, "stty"); + strvec_push(&cp.args, "stty"); if (bits & ENABLE_LINE_INPUT) { string_list_append(&stty_restore, "icanon"); - argv_array_push(&cp.args, "-icanon"); + strvec_push(&cp.args, "-icanon"); } if (bits & ENABLE_ECHO_INPUT) { string_list_append(&stty_restore, "echo"); - argv_array_push(&cp.args, "-echo"); + strvec_push(&cp.args, "-echo"); } if (bits & ENABLE_PROCESSED_INPUT) { string_list_append(&stty_restore, "-ignbrk"); string_list_append(&stty_restore, "intr"); string_list_append(&stty_restore, "^c"); - argv_array_push(&cp.args, "ignbrk"); - argv_array_push(&cp.args, "intr"); - argv_array_push(&cp.args, ""); + strvec_push(&cp.args, "ignbrk"); + strvec_push(&cp.args, "intr"); + strvec_push(&cp.args, ""); } if (run_command(&cp) == 0) @@ -273,7 +273,7 @@ static int is_known_escape_sequence(const char *sequence) hashmap_init(&sequences, (hashmap_cmp_fn)sequence_entry_cmp, NULL, 0); - argv_array_pushl(&cp.args, "infocmp", "-L", "-1", NULL); + strvec_pushl(&cp.args, "infocmp", "-L", "-1", NULL); if (pipe_command(&cp, NULL, 0, &buf, 0, NULL, 0)) strbuf_setlen(&buf, 0); diff --git a/connect.c b/connect.c index e0d5b9fee0..9b453fe792 100644 --- a/connect.c +++ b/connect.c @@ -17,7 +17,7 @@ #include "alias.h" static char *server_capabilities_v1; -static struct argv_array server_capabilities_v2 = ARGV_ARRAY_INIT; +static struct strvec server_capabilities_v2 = STRVEC_INIT; static const char *next_server_feature_value(const char *feature, int *len, int *offset); static int check_ref(const char *name, unsigned int flags) @@ -123,7 +123,7 @@ int server_supports_feature(const char *c, const char *feature, static void process_capabilities_v2(struct packet_reader *reader) { while (packet_reader_read(reader) == PACKET_READ_NORMAL) - argv_array_push(&server_capabilities_v2, reader->line); + strvec_push(&server_capabilities_v2, reader->line); if (reader->status != PACKET_READ_FLUSH) die(_("expected flush after capabilities")); @@ -453,7 +453,7 @@ void check_stateless_delimiter(int stateless_rpc, struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, struct ref **list, int for_push, - const struct argv_array *ref_prefixes, + const struct strvec *ref_prefixes, const struct string_list *server_options, int stateless_rpc) { @@ -944,9 +944,9 @@ static struct child_process *git_proxy_connect(int fd[2], char *host) proxy = xmalloc(sizeof(*proxy)); child_process_init(proxy); - argv_array_push(&proxy->args, git_proxy_command); - argv_array_push(&proxy->args, host); - argv_array_push(&proxy->args, port); + strvec_push(&proxy->args, git_proxy_command); + strvec_push(&proxy->args, host); + strvec_push(&proxy->args, port); proxy->in = -1; proxy->out = -1; if (start_command(proxy)) @@ -1199,15 +1199,15 @@ static struct child_process *git_connect_git(int fd[2], char *hostandport, * Append the appropriate environment variables to `env` and options to * `args` for running ssh in Git's SSH-tunneled transport. */ -static void push_ssh_options(struct argv_array *args, struct argv_array *env, +static void push_ssh_options(struct strvec *args, struct strvec *env, enum ssh_variant variant, const char *port, enum protocol_version version, int flags) { if (variant == VARIANT_SSH && version > 0) { - argv_array_push(args, "-o"); - argv_array_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT); - argv_array_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d", + strvec_push(args, "-o"); + strvec_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT); + strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d", version); } @@ -1221,7 +1221,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env, case VARIANT_PLINK: case VARIANT_PUTTY: case VARIANT_TORTOISEPLINK: - argv_array_push(args, "-4"); + strvec_push(args, "-4"); } } else if (flags & CONNECT_IPV6) { switch (variant) { @@ -1233,12 +1233,12 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env, case VARIANT_PLINK: case VARIANT_PUTTY: case VARIANT_TORTOISEPLINK: - argv_array_push(args, "-6"); + strvec_push(args, "-6"); } } if (variant == VARIANT_TORTOISEPLINK) - argv_array_push(args, "-batch"); + strvec_push(args, "-batch"); if (port) { switch (variant) { @@ -1247,15 +1247,15 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env, case VARIANT_SIMPLE: die(_("ssh variant 'simple' does not support setting port")); case VARIANT_SSH: - argv_array_push(args, "-p"); + strvec_push(args, "-p"); break; case VARIANT_PLINK: case VARIANT_PUTTY: case VARIANT_TORTOISEPLINK: - argv_array_push(args, "-P"); + strvec_push(args, "-P"); } - argv_array_push(args, port); + strvec_push(args, port); } } @@ -1293,18 +1293,18 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host, detect.use_shell = conn->use_shell; detect.no_stdin = detect.no_stdout = detect.no_stderr = 1; - argv_array_push(&detect.args, ssh); - argv_array_push(&detect.args, "-G"); + strvec_push(&detect.args, ssh); + strvec_push(&detect.args, "-G"); push_ssh_options(&detect.args, &detect.env_array, VARIANT_SSH, port, version, flags); - argv_array_push(&detect.args, ssh_host); + strvec_push(&detect.args, ssh_host); variant = run_command(&detect) ? VARIANT_SIMPLE : VARIANT_SSH; } - argv_array_push(&conn->args, ssh); + strvec_push(&conn->args, ssh); push_ssh_options(&conn->args, &conn->env_array, variant, port, version, flags); - argv_array_push(&conn->args, ssh_host); + strvec_push(&conn->args, ssh_host); } /* @@ -1365,7 +1365,7 @@ struct child_process *git_connect(int fd[2], const char *url, /* remove repo-local variables from the environment */ for (var = local_repo_env; *var; var++) - argv_array_push(&conn->env_array, *var); + strvec_push(&conn->env_array, *var); conn->use_shell = 1; conn->in = conn->out = -1; @@ -1397,11 +1397,11 @@ struct child_process *git_connect(int fd[2], const char *url, transport_check_allowed("file"); conn->trace2_child_class = "transport/file"; if (version > 0) { - argv_array_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d", + strvec_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d", version); } } - argv_array_push(&conn->args, cmd.buf); + strvec_push(&conn->args, cmd.buf); if (start_command(conn)) die(_("unable to fork")); diff --git a/connected.c b/connected.c index 937b4bae38..96b47879d3 100644 --- a/connected.c +++ b/connected.c @@ -90,22 +90,22 @@ promisor_pack_found: no_promisor_pack_found: if (opt->shallow_file) { - argv_array_push(&rev_list.args, "--shallow-file"); - argv_array_push(&rev_list.args, opt->shallow_file); + strvec_push(&rev_list.args, "--shallow-file"); + strvec_push(&rev_list.args, opt->shallow_file); } - argv_array_push(&rev_list.args,"rev-list"); - argv_array_push(&rev_list.args, "--objects"); - argv_array_push(&rev_list.args, "--stdin"); + strvec_push(&rev_list.args,"rev-list"); + strvec_push(&rev_list.args, "--objects"); + strvec_push(&rev_list.args, "--stdin"); if (has_promisor_remote()) - argv_array_push(&rev_list.args, "--exclude-promisor-objects"); + strvec_push(&rev_list.args, "--exclude-promisor-objects"); if (!opt->is_deepening_fetch) { - argv_array_push(&rev_list.args, "--not"); - argv_array_push(&rev_list.args, "--all"); + strvec_push(&rev_list.args, "--not"); + strvec_push(&rev_list.args, "--all"); } - argv_array_push(&rev_list.args, "--quiet"); - argv_array_push(&rev_list.args, "--alternate-refs"); + strvec_push(&rev_list.args, "--quiet"); + strvec_push(&rev_list.args, "--alternate-refs"); if (opt->progress) - argv_array_pushf(&rev_list.args, "--progress=%s", + strvec_pushf(&rev_list.args, "--progress=%s", _("Checking connectivity")); rev_list.git_cmd = 1; diff --git a/daemon.c b/daemon.c index fd669ed3b4..cea5f5354f 100644 --- a/daemon.c +++ b/daemon.c @@ -296,7 +296,7 @@ static const char *path_ok(const char *directory, struct hostinfo *hi) return NULL; /* Fallthrough. Deny by default */ } -typedef int (*daemon_service_fn)(const struct argv_array *env); +typedef int (*daemon_service_fn)(const struct strvec *env); struct daemon_service { const char *name; const char *config_name; @@ -377,7 +377,7 @@ error_return: } static int run_service(const char *dir, struct daemon_service *service, - struct hostinfo *hi, const struct argv_array *env) + struct hostinfo *hi, const struct strvec *env) { const char *path; int enabled = service->enabled; @@ -462,7 +462,7 @@ static void copy_to_log(int fd) static int run_service_command(struct child_process *cld) { - argv_array_push(&cld->args, "."); + strvec_push(&cld->args, "."); cld->git_cmd = 1; cld->err = -1; if (start_command(cld)) @@ -476,33 +476,33 @@ static int run_service_command(struct child_process *cld) return finish_command(cld); } -static int upload_pack(const struct argv_array *env) +static int upload_pack(const struct strvec *env) { struct child_process cld = CHILD_PROCESS_INIT; - argv_array_pushl(&cld.args, "upload-pack", "--strict", NULL); - argv_array_pushf(&cld.args, "--timeout=%u", timeout); + strvec_pushl(&cld.args, "upload-pack", "--strict", NULL); + strvec_pushf(&cld.args, "--timeout=%u", timeout); - argv_array_pushv(&cld.env_array, env->argv); + strvec_pushv(&cld.env_array, env->argv); return run_service_command(&cld); } -static int upload_archive(const struct argv_array *env) +static int upload_archive(const struct strvec *env) { struct child_process cld = CHILD_PROCESS_INIT; - argv_array_push(&cld.args, "upload-archive"); + strvec_push(&cld.args, "upload-archive"); - argv_array_pushv(&cld.env_array, env->argv); + strvec_pushv(&cld.env_array, env->argv); return run_service_command(&cld); } -static int receive_pack(const struct argv_array *env) +static int receive_pack(const struct strvec *env) { struct child_process cld = CHILD_PROCESS_INIT; - argv_array_push(&cld.args, "receive-pack"); + strvec_push(&cld.args, "receive-pack"); - argv_array_pushv(&cld.env_array, env->argv); + strvec_pushv(&cld.env_array, env->argv); return run_service_command(&cld); } @@ -633,7 +633,7 @@ static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen) return extra_args; } -static void parse_extra_args(struct hostinfo *hi, struct argv_array *env, +static void parse_extra_args(struct hostinfo *hi, struct strvec *env, char *extra_args, int buflen) { const char *end = extra_args + buflen; @@ -664,7 +664,7 @@ static void parse_extra_args(struct hostinfo *hi, struct argv_array *env, if (git_protocol.len > 0) { loginfo("Extended attribute \"protocol\": %s", git_protocol.buf); - argv_array_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s", + strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s", git_protocol.buf); } strbuf_release(&git_protocol); @@ -761,7 +761,7 @@ static int execute(void) int pktlen, len, i; char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT"); struct hostinfo hi; - struct argv_array env = ARGV_ARRAY_INIT; + struct strvec env = STRVEC_INIT; hostinfo_init(&hi); @@ -794,13 +794,13 @@ static int execute(void) */ int rc = run_service(arg, s, &hi, &env); hostinfo_clear(&hi); - argv_array_clear(&env); + strvec_clear(&env); return rc; } } hostinfo_clear(&hi); - argv_array_clear(&env); + strvec_clear(&env); logerror("Protocol error: '%s'", line); return -1; } @@ -893,7 +893,7 @@ static void check_dead_children(void) cradle = &blanket->next; } -static struct argv_array cld_argv = ARGV_ARRAY_INIT; +static struct strvec cld_argv = STRVEC_INIT; static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) { struct child_process cld = CHILD_PROCESS_INIT; @@ -913,16 +913,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) char buf[128] = ""; struct sockaddr_in *sin_addr = (void *) addr; inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf)); - argv_array_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf); - argv_array_pushf(&cld.env_array, "REMOTE_PORT=%d", + strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf); + strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", ntohs(sin_addr->sin_port)); #ifndef NO_IPV6 } else if (addr->sa_family == AF_INET6) { char buf[128] = ""; struct sockaddr_in6 *sin6_addr = (void *) addr; inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf)); - argv_array_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf); - argv_array_pushf(&cld.env_array, "REMOTE_PORT=%d", + strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf); + strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", ntohs(sin6_addr->sin6_port)); #endif } @@ -1476,10 +1476,10 @@ int cmd_main(int argc, const char **argv) write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid()); /* prepare argv for serving-processes */ - argv_array_push(&cld_argv, argv[0]); /* git-daemon */ - argv_array_push(&cld_argv, "--serve"); + strvec_push(&cld_argv, argv[0]); /* git-daemon */ + strvec_push(&cld_argv, "--serve"); for (i = 1; i < argc; ++i) - argv_array_push(&cld_argv, argv[i]); + strvec_push(&cld_argv, argv[i]); return serve(&listen_addr, listen_port, cred); } diff --git a/diff.c b/diff.c index ee008155e4..f1a3758922 100644 --- a/diff.c +++ b/diff.c @@ -4192,14 +4192,14 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r, } static void add_external_diff_name(struct repository *r, - struct argv_array *argv, + struct strvec *argv, const char *name, struct diff_filespec *df) { struct diff_tempfile *temp = prepare_temp_file(r, name, df); - argv_array_push(argv, temp->name); - argv_array_push(argv, temp->hex); - argv_array_push(argv, temp->mode); + strvec_push(argv, temp->name); + strvec_push(argv, temp->hex); + strvec_push(argv, temp->mode); } /* An external diff command takes: @@ -4216,12 +4216,12 @@ static void run_external_diff(const char *pgm, const char *xfrm_msg, struct diff_options *o) { - struct argv_array argv = ARGV_ARRAY_INIT; - struct argv_array env = ARGV_ARRAY_INIT; + struct strvec argv = STRVEC_INIT; + struct strvec env = STRVEC_INIT; struct diff_queue_struct *q = &diff_queued_diff; - argv_array_push(&argv, pgm); - argv_array_push(&argv, name); + strvec_push(&argv, pgm); + strvec_push(&argv, name); if (one && two) { add_external_diff_name(o->repo, &argv, name, one); @@ -4229,13 +4229,13 @@ static void run_external_diff(const char *pgm, add_external_diff_name(o->repo, &argv, name, two); else { add_external_diff_name(o->repo, &argv, other, two); - argv_array_push(&argv, other); - argv_array_push(&argv, xfrm_msg); + strvec_push(&argv, other); + strvec_push(&argv, xfrm_msg); } } - argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter); - argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr); + strvec_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter); + strvec_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr); diff_free_filespec_data(one); diff_free_filespec_data(two); @@ -4243,8 +4243,8 @@ static void run_external_diff(const char *pgm, die(_("external diff died, stopping at %s"), name); remove_tempfile(); - argv_array_clear(&argv); - argv_array_clear(&env); + strvec_clear(&argv); + strvec_clear(&env); } static int similarity_index(struct diff_filepair *p) diff --git a/environment.c b/environment.c index 75fe5f4c56..00fe20e496 100644 --- a/environment.c +++ b/environment.c @@ -156,14 +156,14 @@ static char *expand_namespace(const char *raw_namespace) * Wrapper of getenv() that returns a strdup value. This value is kept * in argv to be freed later. */ -static const char *getenv_safe(struct argv_array *argv, const char *name) +static const char *getenv_safe(struct strvec *argv, const char *name) { const char *value = getenv(name); if (!value) return NULL; - argv_array_push(argv, value); + strvec_push(argv, value); return argv->argv[argv->argc - 1]; } @@ -172,7 +172,7 @@ void setup_git_env(const char *git_dir) const char *shallow_file; const char *replace_ref_base; struct set_gitdir_args args = { NULL }; - struct argv_array to_free = ARGV_ARRAY_INIT; + struct strvec to_free = STRVEC_INIT; args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT); args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT); @@ -180,7 +180,7 @@ void setup_git_env(const char *git_dir) args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT); args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT); repo_set_gitdir(the_repository, git_dir, &args); - argv_array_clear(&to_free); + strvec_clear(&to_free); if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT)) read_replace_refs = 0; diff --git a/exec-cmd.c b/exec-cmd.c index bb24c2f3bc..0f8e888424 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -320,16 +320,16 @@ void setup_path(void) strbuf_release(&new_path); } -const char **prepare_git_cmd(struct argv_array *out, const char **argv) +const char **prepare_git_cmd(struct strvec *out, const char **argv) { - argv_array_push(out, "git"); - argv_array_pushv(out, argv); + strvec_push(out, "git"); + strvec_pushv(out, argv); return out->argv; } int execv_git_cmd(const char **argv) { - struct argv_array nargv = ARGV_ARRAY_INIT; + struct strvec nargv = STRVEC_INIT; prepare_git_cmd(&nargv, argv); trace_argv_printf(nargv.argv, "trace: exec:"); @@ -339,7 +339,7 @@ int execv_git_cmd(const char **argv) trace_printf("trace: exec failed: %s\n", strerror(errno)); - argv_array_clear(&nargv); + strvec_clear(&nargv); return -1; } diff --git a/fast-import.c b/fast-import.c index 0dfa14dc8c..ce47794db6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -843,9 +843,9 @@ static int loosen_small_pack(const struct packed_git *p) unpack.in = p->pack_fd; unpack.git_cmd = 1; unpack.stdout_to_stderr = 1; - argv_array_push(&unpack.args, "unpack-objects"); + strvec_push(&unpack.args, "unpack-objects"); if (!show_stats) - argv_array_push(&unpack.args, "-q"); + strvec_push(&unpack.args, "-q"); return run_command(&unpack); } diff --git a/fetch-pack.c b/fetch-pack.c index 80fb3bd899..7aa5dfbdad 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -835,30 +835,30 @@ static int get_pack(struct fetch_pack_args *args, } if (alternate_shallow_file) { - argv_array_push(&cmd.args, "--shallow-file"); - argv_array_push(&cmd.args, alternate_shallow_file); + strvec_push(&cmd.args, "--shallow-file"); + strvec_push(&cmd.args, alternate_shallow_file); } if (do_keep || args->from_promisor) { if (pack_lockfiles) cmd.out = -1; cmd_name = "index-pack"; - argv_array_push(&cmd.args, cmd_name); - argv_array_push(&cmd.args, "--stdin"); + strvec_push(&cmd.args, cmd_name); + strvec_push(&cmd.args, "--stdin"); if (!args->quiet && !args->no_progress) - argv_array_push(&cmd.args, "-v"); + strvec_push(&cmd.args, "-v"); if (args->use_thin_pack) - argv_array_push(&cmd.args, "--fix-thin"); + strvec_push(&cmd.args, "--fix-thin"); if (do_keep && (args->lock_pack || unpack_limit)) { char hostname[HOST_NAME_MAX + 1]; if (xgethostname(hostname, sizeof(hostname))) xsnprintf(hostname, sizeof(hostname), "localhost"); - argv_array_pushf(&cmd.args, + strvec_pushf(&cmd.args, "--keep=fetch-pack %"PRIuMAX " on %s", (uintmax_t)getpid(), hostname); } if (only_packfile && args->check_self_contained_and_connected) - argv_array_push(&cmd.args, "--check-self-contained-and-connected"); + strvec_push(&cmd.args, "--check-self-contained-and-connected"); else /* * We cannot perform any connectivity checks because @@ -873,18 +873,18 @@ static int get_pack(struct fetch_pack_args *args, * us. */ if (!(do_keep && pack_lockfiles) && args->from_promisor) - argv_array_push(&cmd.args, "--promisor"); + strvec_push(&cmd.args, "--promisor"); } else { cmd_name = "unpack-objects"; - argv_array_push(&cmd.args, cmd_name); + strvec_push(&cmd.args, cmd_name); if (args->quiet || args->no_progress) - argv_array_push(&cmd.args, "-q"); + strvec_push(&cmd.args, "-q"); args->check_self_contained_and_connected = 0; } if (pass_header) - argv_array_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32, + strvec_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32, ntohl(header.hdr_version), ntohl(header.hdr_entries)); if (fetch_fsck_objects >= 0 @@ -898,9 +898,9 @@ static int get_pack(struct fetch_pack_args *args, * checks both broken objects and links, but we only * want to check for broken objects. */ - argv_array_push(&cmd.args, "--fsck-objects"); + strvec_push(&cmd.args, "--fsck-objects"); else - argv_array_pushf(&cmd.args, "--strict%s", + strvec_pushf(&cmd.args, "--strict%s", fsck_msg_types.buf); } @@ -1652,11 +1652,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, const char *uri = packfile_uris.items[i].string + the_hash_algo->hexsz + 1; - argv_array_push(&cmd.args, "http-fetch"); - argv_array_pushf(&cmd.args, "--packfile=%.*s", + strvec_push(&cmd.args, "http-fetch"); + strvec_pushf(&cmd.args, "--packfile=%.*s", (int) the_hash_algo->hexsz, packfile_uris.items[i].string); - argv_array_push(&cmd.args, uri); + strvec_push(&cmd.args, uri); cmd.git_cmd = 1; cmd.no_stdin = 1; cmd.out = -1; diff --git a/fsmonitor.c b/fsmonitor.c index 932bd9012d..e3c982e814 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -146,9 +146,9 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf * if (!core_fsmonitor) return -1; - argv_array_push(&cp.args, core_fsmonitor); - argv_array_pushf(&cp.args, "%d", version); - argv_array_pushf(&cp.args, "%s", last_update); + strvec_push(&cp.args, core_fsmonitor); + strvec_pushf(&cp.args, "%d", version); + strvec_pushf(&cp.args, "%s", last_update); cp.use_shell = 1; cp.dir = get_git_work_tree(); diff --git a/git.c b/git.c index 6cd887bb0c..258035cfb1 100644 --- a/git.c +++ b/git.c @@ -349,8 +349,8 @@ static int handle_alias(int *argcp, const char ***argv) child.clean_on_exit = 1; child.wait_after_clean = 1; child.trace2_child_class = "shell_alias"; - argv_array_push(&child.args, alias_string + 1); - argv_array_pushv(&child.args, (*argv) + 1); + strvec_push(&child.args, alias_string + 1); + strvec_pushv(&child.args, (*argv) + 1); trace2_cmd_alias(alias_command, child.args.argv); trace2_cmd_list_config(); @@ -646,7 +646,7 @@ static void strip_extension(const char **argv) static void handle_builtin(int argc, const char **argv) { - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; const char *cmd; struct cmd_struct *builtin; @@ -661,9 +661,9 @@ static void handle_builtin(int argc, const char **argv) argv[0] = cmd = "help"; for (i = 0; i < argc; i++) { - argv_array_push(&args, argv[i]); + strvec_push(&args, argv[i]); if (!i) - argv_array_push(&args, "--exclude-guides"); + strvec_push(&args, "--exclude-guides"); } argc++; @@ -673,7 +673,7 @@ static void handle_builtin(int argc, const char **argv) builtin = get_builtin(cmd); if (builtin) exit(run_builtin(builtin, argc, argv)); - argv_array_clear(&args); + strvec_clear(&args); } static void execv_dashed_external(const char **argv) @@ -688,8 +688,8 @@ static void execv_dashed_external(const char **argv) use_pager = check_pager_config(argv[0]); commit_pager_choice(); - argv_array_pushf(&cmd.args, "git-%s", argv[0]); - argv_array_pushv(&cmd.args, argv + 1); + strvec_pushf(&cmd.args, "git-%s", argv[0]); + strvec_pushv(&cmd.args, argv + 1); cmd.clean_on_exit = 1; cmd.wait_after_clean = 1; cmd.silent_exec_failure = 1; @@ -741,7 +741,7 @@ static int run_argv(int *argcp, const char ***argv) if (!done_alias) handle_builtin(*argcp, *argv); else if (get_builtin(**argv)) { - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; int i; /* @@ -758,9 +758,9 @@ static int run_argv(int *argcp, const char ***argv) commit_pager_choice(); - argv_array_push(&args, "git"); + strvec_push(&args, "git"); for (i = 0; i < *argcp; i++) - argv_array_push(&args, (*argv)[i]); + strvec_push(&args, (*argv)[i]); trace_argv_printf(args.argv, "trace: exec:"); diff --git a/gpg-interface.c b/gpg-interface.c index 2d538bcd6e..cf56fe838f 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -282,9 +282,9 @@ static int verify_signed_buffer(const char *payload, size_t payload_size, if (!fmt) BUG("bad signature '%s'", signature); - argv_array_push(&gpg.args, fmt->program); - argv_array_pushv(&gpg.args, fmt->verify_args); - argv_array_pushl(&gpg.args, + strvec_push(&gpg.args, fmt->program); + strvec_pushv(&gpg.args, fmt->verify_args); + strvec_pushl(&gpg.args, "--status-fd=1", "--verify", temp->filename.buf, "-", NULL); @@ -434,7 +434,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig size_t i, j, bottom; struct strbuf gpg_status = STRBUF_INIT; - argv_array_pushl(&gpg.args, + strvec_pushl(&gpg.args, use_format->program, "--status-fd=2", "-bsau", signing_key, diff --git a/graph.c b/graph.c index 96af8f605a..09c9cc968c 100644 --- a/graph.c +++ b/graph.c @@ -82,7 +82,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt) static const char **column_colors; static unsigned short column_colors_max; -static void parse_graph_colors_config(struct argv_array *colors, const char *string) +static void parse_graph_colors_config(struct strvec *colors, const char *string) { const char *end, *start; @@ -93,13 +93,13 @@ static void parse_graph_colors_config(struct argv_array *colors, const char *str char color[COLOR_MAXLEN]; if (!color_parse_mem(start, comma - start, color)) - argv_array_push(colors, color); + strvec_push(colors, color); else warning(_("ignore invalid color '%.*s' in log.graphColors"), (int)(comma - start), start); start = comma + 1; } - argv_array_push(colors, GIT_COLOR_RESET); + strvec_push(colors, GIT_COLOR_RESET); } void graph_set_column_colors(const char **colors, unsigned short colors_max) @@ -350,8 +350,8 @@ struct git_graph *graph_init(struct rev_info *opt) graph_set_column_colors(column_colors_ansi, column_colors_ansi_max); } else { - static struct argv_array custom_colors = ARGV_ARRAY_INIT; - argv_array_clear(&custom_colors); + static struct strvec custom_colors = STRVEC_INIT; + strvec_clear(&custom_colors); parse_graph_colors_config(&custom_colors, string); free(string); /* graph_set_column_colors takes a max-index, not a count */ diff --git a/http-backend.c b/http-backend.c index 6a42badf33..92fd62f73f 100644 --- a/http-backend.c +++ b/http-backend.c @@ -477,9 +477,9 @@ static void run_service(const char **argv, int buffer_input) host = "(none)"; if (!getenv("GIT_COMMITTER_NAME")) - argv_array_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user); + strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user); if (!getenv("GIT_COMMITTER_EMAIL")) - argv_array_pushf(&cld.env_array, + strvec_pushf(&cld.env_array, "GIT_COMMITTER_EMAIL=%s@http.%s", user, host); cld.argv = argv; diff --git a/http-push.c b/http-push.c index 3a47921cc3..e1deea6fe4 100644 --- a/http-push.c +++ b/http-push.c @@ -1846,7 +1846,7 @@ int cmd_main(int argc, const char **argv) new_refs = 0; for (ref = remote_refs; ref; ref = ref->next) { - struct argv_array commit_argv = ARGV_ARRAY_INIT; + struct strvec commit_argv = STRVEC_INIT; if (!ref->peer_ref) continue; @@ -1924,11 +1924,11 @@ int cmd_main(int argc, const char **argv) } /* Set up revision info for this refspec */ - argv_array_push(&commit_argv, ""); /* ignored */ - argv_array_push(&commit_argv, "--objects"); - argv_array_push(&commit_argv, oid_to_hex(&ref->new_oid)); + strvec_push(&commit_argv, ""); /* ignored */ + strvec_push(&commit_argv, "--objects"); + strvec_push(&commit_argv, oid_to_hex(&ref->new_oid)); if (!push_all && !is_null_oid(&ref->old_oid)) - argv_array_pushf(&commit_argv, "^%s", + 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); @@ -1961,7 +1961,7 @@ int cmd_main(int argc, const char **argv) printf("%s %s\n", !rc ? "ok" : "error", ref->name); unlock_remote(ref_lock); check_locks(); - argv_array_clear(&commit_argv); + strvec_clear(&commit_argv); } /* Update remote server info if appropriate */ diff --git a/http.c b/http.c index 3b12843a5b..268a1e9744 100644 --- a/http.c +++ b/http.c @@ -2270,12 +2270,12 @@ int finish_http_pack_request(struct http_pack_request *preq) tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY); - argv_array_push(&ip.args, "index-pack"); - argv_array_push(&ip.args, "--stdin"); + strvec_push(&ip.args, "index-pack"); + strvec_push(&ip.args, "--stdin"); ip.git_cmd = 1; ip.in = tmpfile_fd; if (preq->generate_keep) { - argv_array_pushf(&ip.args, "--keep=git %"PRIuMAX, + strvec_pushf(&ip.args, "--keep=git %"PRIuMAX, (uintmax_t)getpid()); ip.out = 0; } else { diff --git a/imap-send.c b/imap-send.c index 52737546f3..5764dd812c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -976,7 +976,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f imap_info("Starting tunnel '%s'... ", srvc->tunnel); - argv_array_push(&tunnel.args, srvc->tunnel); + strvec_push(&tunnel.args, srvc->tunnel); tunnel.use_shell = 1; tunnel.in = -1; tunnel.out = -1; diff --git a/line-log.c b/line-log.c index 05d077b8e7..bf73ea95ac 100644 --- a/line-log.c +++ b/line-log.c @@ -758,12 +758,12 @@ static void parse_pathspec_from_ranges(struct pathspec *pathspec, struct line_log_data *range) { struct line_log_data *r; - struct argv_array array = ARGV_ARRAY_INIT; + struct strvec array = STRVEC_INIT; const char **paths; for (r = range; r; r = r->next) - argv_array_push(&array, r->path); - paths = argv_array_detach(&array); + strvec_push(&array, r->path); + paths = strvec_detach(&array); parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL, "", paths); /* strings are now owned by pathspec */ diff --git a/ls-refs.c b/ls-refs.c index 98fb19092a..8192c949f4 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -11,7 +11,7 @@ * Check if one of the prefixes is a prefix of the ref. * If no prefixes were provided, all refs match. */ -static int ref_match(const struct argv_array *prefixes, const char *refname) +static int ref_match(const struct strvec *prefixes, const char *refname) { int i; @@ -31,7 +31,7 @@ static int ref_match(const struct argv_array *prefixes, const char *refname) struct ls_refs_data { unsigned peel; unsigned symrefs; - struct argv_array prefixes; + struct strvec prefixes; }; static int send_ref(const char *refname, const struct object_id *oid, @@ -84,7 +84,7 @@ static int ls_refs_config(const char *var, const char *value, void *data) return parse_hide_refs_config(var, value, "uploadpack"); } -int ls_refs(struct repository *r, struct argv_array *keys, +int ls_refs(struct repository *r, struct strvec *keys, struct packet_reader *request) { struct ls_refs_data data; @@ -102,7 +102,7 @@ int ls_refs(struct repository *r, struct argv_array *keys, else if (!strcmp("symrefs", arg)) data.symrefs = 1; else if (skip_prefix(arg, "ref-prefix ", &out)) - argv_array_push(&data.prefixes, out); + strvec_push(&data.prefixes, out); } if (request->status != PACKET_READ_FLUSH) @@ -111,6 +111,6 @@ int ls_refs(struct repository *r, struct argv_array *keys, head_ref_namespaced(send_ref, &data); for_each_namespaced_ref(send_ref, &data); packet_flush(1); - argv_array_clear(&data.prefixes); + strvec_clear(&data.prefixes); return 0; } -- cgit v1.2.3 From f6d8942b1fc6c968980c8ae03054d7b2114b4415 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:26:31 -0400 Subject: strvec: fix indentation in renamed calls Code which split an argv_array call across multiple lines, like: argv_array_pushl(&args, "one argument", "another argument", "and more", NULL); was recently mechanically renamed to use strvec, which results in mis-matched indentation like: strvec_pushl(&args, "one argument", "another argument", "and more", NULL); Let's fix these up to align the arguments with the opening paren. I did this manually by sifting through the results of: git jump grep 'strvec_.*,$' and liberally applying my editor's auto-format. Most of the changes are of the form shown above, though I also normalized a few that had originally used a single-tab indentation (rather than our usual style of aligning with the open paren). I also rewrapped a couple of obvious cases (e.g., where previously too-long lines became short enough to fit on one), but I wasn't aggressive about it. In cases broken to three or more lines, the grouping of arguments is sometimes meaningful, and it wasn't worth my time or reviewer time to ponder each case individually. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- add-interactive.c | 10 +++++----- add-patch.c | 10 +++++----- bisect.c | 2 +- builtin/bisect--helper.c | 2 +- builtin/describe.c | 8 ++++---- builtin/difftool.c | 12 ++++++------ builtin/fetch.c | 2 +- builtin/gc.c | 2 +- builtin/pull.c | 6 +++--- builtin/rebase.c | 14 +++++++------- builtin/receive-pack.c | 42 +++++++++++++++++++++--------------------- builtin/repack.c | 8 ++++---- builtin/stash.c | 38 +++++++++++++++++++------------------- builtin/submodule--helper.c | 20 ++++++++++---------- builtin/worktree.c | 18 +++++++++--------- bundle.c | 10 +++++----- connect.c | 7 ++++--- connected.c | 2 +- daemon.c | 6 +++--- fetch-pack.c | 12 ++++++------ gpg-interface.c | 14 +++++++------- http-backend.c | 2 +- http-push.c | 2 +- http.c | 2 +- range-diff.c | 28 ++++++++++++++-------------- refspec.c | 4 ++-- remote-curl.c | 8 ++++---- remote.c | 4 ++-- sequencer.c | 8 ++++---- submodule.c | 30 +++++++++++++++--------------- t/helper/test-run-command.c | 6 +++--- transport-helper.c | 2 +- upload-pack.c | 3 +-- wt-status.c | 3 +-- 34 files changed, 173 insertions(+), 174 deletions(-) (limited to 'add-patch.c') diff --git a/add-interactive.c b/add-interactive.c index b345777d0c..458f3a3e69 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -941,7 +941,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps, for (i = 0; i < files->items.nr; i++) if (files->selected[i]) strvec_push(&args, - files->items.items[i].string); + files->items.items[i].string); parse_pathspec(&ps_selected, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL, PATHSPEC_LITERAL_PATH, "", args.argv); @@ -979,13 +979,13 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, struct strvec args = STRVEC_INIT; strvec_pushl(&args, "git", "diff", "-p", "--cached", - oid_to_hex(!is_initial ? &oid : - s->r->hash_algo->empty_tree), - "--", NULL); + oid_to_hex(!is_initial ? &oid : + s->r->hash_algo->empty_tree), + "--", NULL); for (i = 0; i < files->items.nr; i++) if (files->selected[i]) strvec_push(&args, - files->items.items[i].string); + files->items.items[i].string); res = run_command_v_opt(args.argv, 0); strvec_clear(&args); } diff --git a/add-patch.c b/add-patch.c index 3c91ae52ae..8c0772803b 100644 --- a/add-patch.c +++ b/add-patch.c @@ -291,7 +291,7 @@ static void setup_child_process(struct add_p_state *s, cp->git_cmd = 1; strvec_pushf(&cp->env_array, - INDEX_ENVIRONMENT "=%s", s->s.r->index_file); + INDEX_ENVIRONMENT "=%s", s->s.r->index_file); } static int parse_range(const char **p, @@ -386,10 +386,10 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) if (s->revision) { struct object_id oid; strvec_push(&args, - /* could be on an unborn branch */ - !strcmp("HEAD", s->revision) && - get_oid("HEAD", &oid) ? - empty_tree_oid_hex() : s->revision); + /* could be on an unborn branch */ + !strcmp("HEAD", s->revision) && + get_oid("HEAD", &oid) ? + empty_tree_oid_hex() : s->revision); } color_arg_index = args.argc; /* Use `--no-color` explicitly, just in case `diff.color = always`. */ diff --git a/bisect.c b/bisect.c index 3e50b51c11..99ff694960 100644 --- a/bisect.c +++ b/bisect.c @@ -644,7 +644,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, strvec_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid)); for (i = 0; i < good_revs.nr; i++) strvec_pushf(&rev_argv, good_format, - oid_to_hex(good_revs.oid + i)); + oid_to_hex(good_revs.oid + i)); strvec_push(&rev_argv, "--"); if (read_paths) read_bisect_paths(&rev_argv); diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 9815e78871..dd52878413 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -529,7 +529,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, struct strvec argv = STRVEC_INIT; strvec_pushl(&argv, "checkout", start_head.buf, - "--", NULL); + "--", NULL); if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) { res = error(_("checking out '%s' failed." " Try 'git bisect start " diff --git a/builtin/describe.c b/builtin/describe.c index ff3c169fa9..e3cac8002c 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -505,8 +505,8 @@ static void describe_blob(struct object_id oid, struct strbuf *dst) struct process_commit_data pcd = { null_oid, oid, dst, &revs}; strvec_pushl(&args, "internal: The first arg is not parsed", - "--objects", "--in-commit-order", "--reverse", "HEAD", - NULL); + "--objects", "--in-commit-order", "--reverse", "HEAD", + NULL); repo_init_revisions(the_repository, &revs, NULL); if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1) @@ -598,8 +598,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix) strvec_init(&args); strvec_pushl(&args, "name-rev", - "--peel-tag", "--name-only", "--no-undefined", - NULL); + "--peel-tag", "--name-only", "--no-undefined", + NULL); if (always) strvec_push(&args, "--always"); if (!all) { diff --git a/builtin/difftool.c b/builtin/difftool.c index 40c4d7b6b6..5ac021a1d4 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -211,9 +211,9 @@ static void changed_files(struct hashmap *result, const char *index_path, env[0] = index_env.buf; strvec_pushl(&update_index.args, - "--git-dir", git_dir, "--work-tree", workdir, - "update-index", "--really-refresh", "-q", - "--unmerged", NULL); + "--git-dir", git_dir, "--work-tree", workdir, + "update-index", "--really-refresh", "-q", + "--unmerged", NULL); update_index.no_stdin = 1; update_index.no_stdout = 1; update_index.no_stderr = 1; @@ -226,8 +226,8 @@ static void changed_files(struct hashmap *result, const char *index_path, run_command(&update_index); strvec_pushl(&diff_files.args, - "--git-dir", git_dir, "--work-tree", workdir, - "diff-files", "--name-only", "-z", NULL); + "--git-dir", git_dir, "--work-tree", workdir, + "diff-files", "--name-only", "-z", NULL); diff_files.no_stdin = 1; diff_files.git_cmd = 1; diff_files.use_shell = 0; @@ -394,7 +394,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, child.dir = prefix; child.out = -1; strvec_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z", - NULL); + NULL); for (i = 0; i < argc; i++) strvec_push(&child.args, argv[i]); if (start_command(&child)) diff --git a/builtin/fetch.c b/builtin/fetch.c index cc636188ad..c2e7afeb6a 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1601,7 +1601,7 @@ static int fetch_multiple(struct string_list *list, int max_children) } strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc", - "--no-write-commit-graph", NULL); + "--no-write-commit-graph", NULL); add_options_to_argv(&argv); if (max_children != 1 && list->nr != 1) { diff --git a/builtin/gc.c b/builtin/gc.c index 89742e159e..98719800a3 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -662,7 +662,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix) strvec_push(&prune, "--no-progress"); if (has_promisor_remote()) strvec_push(&prune, - "--exclude-promisor-objects"); + "--exclude-promisor-objects"); if (run_command_v_opt(prune.argv, RUN_GIT_CMD)) die(FAILED_RUN, prune.argv[0]); } diff --git a/builtin/pull.c b/builtin/pull.c index 8a8d30e1dc..dae8766646 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -638,7 +638,7 @@ static int rebase_submodules(void) cp.git_cmd = 1; cp.no_stdin = 1; strvec_pushl(&cp.args, "submodule", "update", - "--recursive", "--rebase", NULL); + "--recursive", "--rebase", NULL); argv_push_verbosity(&cp.args); return run_command(&cp); @@ -651,7 +651,7 @@ static int update_submodules(void) cp.git_cmd = 1; cp.no_stdin = 1; strvec_pushl(&cp.args, "submodule", "update", - "--recursive", "--checkout", NULL); + "--recursive", "--checkout", NULL); argv_push_verbosity(&cp.args); return run_command(&cp); @@ -802,7 +802,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo, return -1; strvec_pushl(&cp.args, "merge-base", "--fork-point", - remote_branch, curr_branch->name, NULL); + remote_branch, curr_branch->name, NULL); cp.no_stdin = 1; cp.no_stderr = 1; cp.git_cmd = 1; diff --git a/builtin/rebase.c b/builtin/rebase.c index fb56b9e263..35aeb8effc 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -348,7 +348,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) strvec_pushl(&make_script_args, "", revisions, NULL); if (opts->restrict_revision) strvec_pushf(&make_script_args, "^%s", - oid_to_hex(&opts->restrict_revision->object.oid)); + 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, @@ -858,17 +858,17 @@ static int run_am(struct rebase_options *opts) format_patch.git_cmd = 1; strvec_pushl(&format_patch.args, "format-patch", "-k", "--stdout", - "--full-index", "--cherry-pick", "--right-only", - "--src-prefix=a/", "--dst-prefix=b/", "--no-renames", - "--no-cover-letter", "--pretty=mboxrd", "--topo-order", - "--no-base", NULL); + "--full-index", "--cherry-pick", "--right-only", + "--src-prefix=a/", "--dst-prefix=b/", "--no-renames", + "--no-cover-letter", "--pretty=mboxrd", "--topo-order", + "--no-base", NULL); if (opts->git_format_patch_opt.len) strvec_split(&format_patch.args, - opts->git_format_patch_opt.buf); + opts->git_format_patch_opt.buf); strvec_push(&format_patch.args, revisions.buf); if (opts->restrict_revision) strvec_pushf(&format_patch.args, "^%s", - oid_to_hex(&opts->restrict_revision->object.oid)); + oid_to_hex(&opts->restrict_revision->object.oid)); status = run_command(&format_patch); if (status) { diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 71274231aa..1fc69cf5bc 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -668,24 +668,24 @@ static void prepare_push_cert_sha1(struct child_process *proc) } if (!is_null_oid(&push_cert_oid)) { strvec_pushf(&proc->env_array, "GIT_PUSH_CERT=%s", - oid_to_hex(&push_cert_oid)); + oid_to_hex(&push_cert_oid)); strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_SIGNER=%s", - sigcheck.signer ? sigcheck.signer : ""); + sigcheck.signer ? sigcheck.signer : ""); strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_KEY=%s", - sigcheck.key ? sigcheck.key : ""); + sigcheck.key ? sigcheck.key : ""); strvec_pushf(&proc->env_array, "GIT_PUSH_CERT_STATUS=%c", - sigcheck.result); + sigcheck.result); if (push_cert_nonce) { strvec_pushf(&proc->env_array, - "GIT_PUSH_CERT_NONCE=%s", - push_cert_nonce); + "GIT_PUSH_CERT_NONCE=%s", + push_cert_nonce); strvec_pushf(&proc->env_array, - "GIT_PUSH_CERT_NONCE_STATUS=%s", - nonce_status); + "GIT_PUSH_CERT_NONCE_STATUS=%s", + nonce_status); if (nonce_status == NONCE_SLOP) strvec_pushf(&proc->env_array, - "GIT_PUSH_CERT_NONCE_SLOP=%ld", - nonce_stamp_slop); + "GIT_PUSH_CERT_NONCE_SLOP=%ld", + nonce_stamp_slop); } } } @@ -721,10 +721,10 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, int i; for (i = 0; i < feed_state->push_options->nr; i++) strvec_pushf(&proc.env_array, - "GIT_PUSH_OPTION_%d=%s", i, - feed_state->push_options->items[i].string); + "GIT_PUSH_OPTION_%d=%s", i, + feed_state->push_options->items[i].string); strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%d", - feed_state->push_options->nr); + feed_state->push_options->nr); } else strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT"); @@ -1718,7 +1718,7 @@ static const char *pack_lockfile; static void push_header_arg(struct strvec *args, struct pack_header *hdr) { strvec_pushf(args, "--pack_header=%"PRIu32",%"PRIu32, - ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries)); + ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries)); } static const char *unpack(int err_fd, struct shallow_info *si) @@ -1768,10 +1768,10 @@ static const char *unpack(int err_fd, struct shallow_info *si) strvec_push(&child.args, "-q"); if (fsck_objects) strvec_pushf(&child.args, "--strict%s", - fsck_msg_types.buf); + fsck_msg_types.buf); if (max_input_size) strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX, - (uintmax_t)max_input_size); + (uintmax_t)max_input_size); child.no_stdout = 1; child.err = err_fd; child.git_cmd = 1; @@ -1787,9 +1787,9 @@ static const char *unpack(int err_fd, struct shallow_info *si) if (xgethostname(hostname, sizeof(hostname))) xsnprintf(hostname, sizeof(hostname), "localhost"); strvec_pushf(&child.args, - "--keep=receive-pack %"PRIuMAX" on %s", - (uintmax_t)getpid(), - hostname); + "--keep=receive-pack %"PRIuMAX" on %s", + (uintmax_t)getpid(), + hostname); if (!quiet && err_fd) strvec_push(&child.args, "--show-resolving-progress"); @@ -1797,12 +1797,12 @@ static const char *unpack(int err_fd, struct shallow_info *si) strvec_push(&child.args, "--report-end-of-input"); if (fsck_objects) strvec_pushf(&child.args, "--strict%s", - fsck_msg_types.buf); + fsck_msg_types.buf); if (!reject_thin) strvec_push(&child.args, "--fix-thin"); if (max_input_size) strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX, - (uintmax_t)max_input_size); + (uintmax_t)max_input_size); child.out = -1; child.err = err_fd; child.git_cmd = 1; diff --git a/builtin/repack.c b/builtin/repack.c index 7435ee9af1..04c5ceaf7e 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -366,7 +366,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) strvec_push(&cmd.args, "--honor-pack-keep"); for (i = 0; i < keep_pack_list.nr; i++) strvec_pushf(&cmd.args, "--keep-pack=%s", - keep_pack_list.items[i].string); + keep_pack_list.items[i].string); strvec_push(&cmd.args, "--non-empty"); strvec_push(&cmd.args, "--all"); strvec_push(&cmd.args, "--reflog"); @@ -388,12 +388,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix) if (existing_packs.nr && delete_redundant) { if (unpack_unreachable) { strvec_pushf(&cmd.args, - "--unpack-unreachable=%s", - unpack_unreachable); + "--unpack-unreachable=%s", + unpack_unreachable); strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1"); } else if (pack_everything & LOOSEN_UNREACHABLE) { strvec_push(&cmd.args, - "--unpack-unreachable"); + "--unpack-unreachable"); } else if (keep_unreachable) { strvec_push(&cmd.args, "--keep-unreachable"); strvec_push(&cmd.args, "--pack-loose-unreachable"); diff --git a/builtin/stash.c b/builtin/stash.c index 05c086e54c..bfdbafae89 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -336,7 +336,7 @@ static int get_newly_staged(struct strbuf *out, struct object_id *c_tree) */ cp.git_cmd = 1; strvec_pushl(&cp.args, "diff-index", "--cached", "--name-only", - "--diff-filter=A", NULL); + "--diff-filter=A", NULL); strvec_push(&cp.args, c_tree_hex); return pipe_command(&cp, NULL, 0, out, 0, NULL, 0); } @@ -368,7 +368,7 @@ static int restore_untracked(struct object_id *u_tree) strvec_push(&cp.args, "read-tree"); strvec_push(&cp.args, oid_to_hex(u_tree)); strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); + stash_index_path.buf); if (run_command(&cp)) { remove_path(stash_index_path.buf); return -1; @@ -378,7 +378,7 @@ static int restore_untracked(struct object_id *u_tree) cp.git_cmd = 1; strvec_pushl(&cp.args, "checkout-index", "--all", NULL); strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); + stash_index_path.buf); res = run_command(&cp); remove_path(stash_index_path.buf); @@ -500,9 +500,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, cp.git_cmd = 1; cp.dir = prefix; strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s", - absolute_path(get_git_work_tree())); + absolute_path(get_git_work_tree())); strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s", - absolute_path(get_git_dir())); + absolute_path(get_git_dir())); strvec_push(&cp.args, "status"); run_command(&cp); } @@ -547,7 +547,7 @@ static int do_drop_stash(struct stash_info *info, int quiet) cp_reflog.git_cmd = 1; strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref", - "--rewrite", NULL); + "--rewrite", NULL); strvec_push(&cp_reflog.args, info->revision.buf); ret = run_command(&cp_reflog); if (!ret) { @@ -693,7 +693,7 @@ static int list_stash(int argc, const char **argv, const char *prefix) cp.git_cmd = 1; strvec_pushl(&cp.args, "log", "--format=%gd: %gs", "-g", - "--first-parent", "-m", NULL); + "--first-parent", "-m", NULL); strvec_pushv(&cp.args, argv); strvec_push(&cp.args, ref_stash); strvec_push(&cp.args, "--"); @@ -961,7 +961,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg, cp_upd_index.git_cmd = 1; strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add", - "--remove", "--stdin", NULL); + "--remove", "--stdin", NULL); strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s", stash_index_path.buf); @@ -1005,7 +1005,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, cp_read_tree.git_cmd = 1; strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL); strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); + stash_index_path.buf); if (run_command(&cp_read_tree)) { ret = -1; goto done; @@ -1035,7 +1035,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, cp_diff_tree.git_cmd = 1; strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD", - oid_to_hex(&info->w_tree), "--", NULL); + oid_to_hex(&info->w_tree), "--", NULL); if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) { ret = -1; goto done; @@ -1089,10 +1089,10 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps cp_upd_index.git_cmd = 1; strvec_pushl(&cp_upd_index.args, "update-index", - "--ignore-skip-worktree-entries", - "-z", "--add", "--remove", "--stdin", NULL); + "--ignore-skip-worktree-entries", + "-z", "--add", "--remove", "--stdin", NULL); strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); + stash_index_path.buf); if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len, NULL, 0, NULL, 0)) { @@ -1343,7 +1343,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp.git_cmd = 1; strvec_pushl(&cp.args, "clean", "--force", - "--quiet", "-d", NULL); + "--quiet", "-d", NULL); if (include_untracked == INCLUDE_ALL_FILES) strvec_push(&cp.args, "-x"); if (run_command(&cp)) { @@ -1373,8 +1373,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp_diff.git_cmd = 1; strvec_pushl(&cp_diff.args, "diff-index", "-p", - "--cached", "--binary", "HEAD", "--", - NULL); + "--cached", "--binary", "HEAD", "--", + NULL); add_pathspecs(&cp_diff.args, ps); if (pipe_command(&cp_diff, NULL, 0, &out, 0, NULL, 0)) { ret = -1; @@ -1383,7 +1383,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp_apply.git_cmd = 1; strvec_pushl(&cp_apply.args, "apply", "--index", - "-R", NULL); + "-R", NULL); if (pipe_command(&cp_apply, out.buf, out.len, NULL, 0, NULL, 0)) { ret = -1; @@ -1393,7 +1393,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q struct child_process cp = CHILD_PROCESS_INIT; cp.git_cmd = 1; strvec_pushl(&cp.args, "reset", "--hard", "-q", - "--no-recurse-submodules", NULL); + "--no-recurse-submodules", NULL); if (run_command(&cp)) { ret = -1; goto done; @@ -1405,7 +1405,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp.git_cmd = 1; strvec_pushl(&cp.args, "checkout", "--no-overlay", - oid_to_hex(&info.i_tree), "--", NULL); + oid_to_hex(&info.i_tree), "--", NULL); if (!ps->nr) strvec_push(&cp.args, ":/"); else diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 7705e8eabf..665db1ffed 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -499,7 +499,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item, strvec_pushf(&cp.env_array, "sm_path=%s", path); strvec_pushf(&cp.env_array, "displaypath=%s", displaypath); strvec_pushf(&cp.env_array, "sha1=%s", - oid_to_hex(ce_oid)); + oid_to_hex(ce_oid)); strvec_pushf(&cp.env_array, "toplevel=%s", toplevel); /* @@ -513,7 +513,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item, */ sq_quote_buf(&sb, path); strvec_pushf(&cp.args, "path=%s; %s", - sb.buf, info->argv[0]); + sb.buf, info->argv[0]); strbuf_release(&sb); free(toplevel); } else { @@ -537,7 +537,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item, strvec_pushl(&cpr.args, "--super-prefix", NULL); strvec_pushf(&cpr.args, "%s/", displaypath); strvec_pushl(&cpr.args, "submodule--helper", "foreach", "--recursive", - NULL); + NULL); if (info->quiet) strvec_push(&cpr.args, "--quiet"); @@ -810,8 +810,8 @@ static void status_submodule(const char *path, const struct object_id *ce_oid, strbuf_release(&buf); strvec_pushl(&diff_files_args, "diff-files", - "--ignore-submodules=dirty", "--quiet", "--", - path, NULL); + "--ignore-submodules=dirty", "--quiet", "--", + path, NULL); git_config(git_diff_basic_config, NULL); @@ -852,7 +852,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid, strvec_push(&cpr.args, "--super-prefix"); strvec_pushf(&cpr.args, "%s/", displaypath); strvec_pushl(&cpr.args, "submodule--helper", "status", - "--recursive", NULL); + "--recursive", NULL); if (flags & OPT_CACHED) strvec_push(&cpr.args, "--cached"); @@ -996,7 +996,7 @@ static void sync_submodule(const char *path, const char *prefix, cp.git_cmd = 1; cp.dir = path; strvec_pushl(&cp.args, "submodule--helper", - "print-default-remote", NULL); + "print-default-remote", NULL); strbuf_reset(&sb); if (capture_command(&cp, &sb, 0)) @@ -1024,7 +1024,7 @@ static void sync_submodule(const char *path, const char *prefix, strvec_push(&cpr.args, "--super-prefix"); strvec_pushf(&cpr.args, "%s/", displaypath); strvec_pushl(&cpr.args, "submodule--helper", "sync", - "--recursive", NULL); + "--recursive", NULL); if (flags & OPT_QUIET) strvec_push(&cpr.args, "--quiet"); @@ -1128,7 +1128,7 @@ static void deinit_submodule(const char *path, const char *prefix, struct child_process cp_rm = CHILD_PROCESS_INIT; cp_rm.git_cmd = 1; strvec_pushl(&cp_rm.args, "rm", "-qn", - path, NULL); + path, NULL); if (run_command(&cp_rm)) die(_("Submodule work tree '%s' contains local " @@ -1251,7 +1251,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url struct string_list_item *item; for_each_string_list_item(item, reference) strvec_pushl(&cp.args, "--reference", - item->string, NULL); + item->string, NULL); } if (dissociate) strvec_push(&cp.args, "--dissociate"); diff --git a/builtin/worktree.c b/builtin/worktree.c index 3c483c23d4..be5d84f0a0 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -414,10 +414,10 @@ static int add_worktree(const char *path, const char *refname, if (!is_branch) strvec_pushl(&cp.args, "update-ref", "HEAD", - oid_to_hex(&commit->object.oid), NULL); + oid_to_hex(&commit->object.oid), NULL); else { strvec_pushl(&cp.args, "symbolic-ref", "HEAD", - symref.buf, NULL); + symref.buf, NULL); if (opts->quiet) strvec_push(&cp.args, "--quiet"); } @@ -466,9 +466,9 @@ done: cp.argv = NULL; cp.trace2_hook_name = "post-checkout"; strvec_pushl(&cp.args, absolute_path(hook), - oid_to_hex(&null_oid), - oid_to_hex(&commit->object.oid), - "1", NULL); + oid_to_hex(&null_oid), + oid_to_hex(&commit->object.oid), + "1", NULL); ret = run_command(&cp); } } @@ -936,13 +936,13 @@ static void check_clean_worktree(struct worktree *wt, validate_no_submodules(wt); strvec_pushf(&child_env, "%s=%s/.git", - GIT_DIR_ENVIRONMENT, wt->path); + GIT_DIR_ENVIRONMENT, wt->path); strvec_pushf(&child_env, "%s=%s", - GIT_WORK_TREE_ENVIRONMENT, wt->path); + GIT_WORK_TREE_ENVIRONMENT, wt->path); memset(&cp, 0, sizeof(cp)); strvec_pushl(&cp.args, "status", - "--porcelain", "--ignore-submodules=none", - NULL); + "--porcelain", "--ignore-submodules=none", + NULL); cp.env = child_env.argv; cp.git_cmd = 1; cp.dir = wt->path; diff --git a/bundle.c b/bundle.c index 709b2abc9c..565d05367f 100644 --- a/bundle.c +++ b/bundle.c @@ -275,9 +275,9 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec * int i; strvec_pushl(&pack_objects.args, - "pack-objects", - "--stdout", "--thin", "--delta-base-offset", - NULL); + "pack-objects", + "--stdout", "--thin", "--delta-base-offset", + NULL); strvec_pushv(&pack_objects.args, pack_options->argv); pack_objects.in = -1; pack_objects.out = bundle_fd; @@ -322,8 +322,8 @@ static int compute_and_write_prerequisites(int bundle_fd, int i; strvec_pushl(&rls.args, - "rev-list", "--boundary", "--pretty=oneline", - NULL); + "rev-list", "--boundary", "--pretty=oneline", + NULL); for (i = 1; i < argc; i++) strvec_push(&rls.args, argv[i]); rls.out = -1; diff --git a/connect.c b/connect.c index 9b453fe792..3299ea956a 100644 --- a/connect.c +++ b/connect.c @@ -1208,7 +1208,7 @@ static void push_ssh_options(struct strvec *args, struct strvec *env, strvec_push(args, "-o"); strvec_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT); strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d", - version); + version); } if (flags & CONNECT_IPV4) { @@ -1397,8 +1397,9 @@ struct child_process *git_connect(int fd[2], const char *url, transport_check_allowed("file"); conn->trace2_child_class = "transport/file"; if (version > 0) { - strvec_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d", - version); + strvec_pushf(&conn->env_array, + GIT_PROTOCOL_ENVIRONMENT "=version=%d", + version); } } strvec_push(&conn->args, cmd.buf); diff --git a/connected.c b/connected.c index 96b47879d3..21c1ebe9fb 100644 --- a/connected.c +++ b/connected.c @@ -106,7 +106,7 @@ no_promisor_pack_found: strvec_push(&rev_list.args, "--alternate-refs"); if (opt->progress) strvec_pushf(&rev_list.args, "--progress=%s", - _("Checking connectivity")); + _("Checking connectivity")); rev_list.git_cmd = 1; rev_list.env = opt->env; diff --git a/daemon.c b/daemon.c index cea5f5354f..0dec89fa02 100644 --- a/daemon.c +++ b/daemon.c @@ -665,7 +665,7 @@ static void parse_extra_args(struct hostinfo *hi, struct strvec *env, if (git_protocol.len > 0) { loginfo("Extended attribute \"protocol\": %s", git_protocol.buf); strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s", - git_protocol.buf); + git_protocol.buf); } strbuf_release(&git_protocol); } @@ -915,7 +915,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf)); strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf); strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", - ntohs(sin_addr->sin_port)); + ntohs(sin_addr->sin_port)); #ifndef NO_IPV6 } else if (addr->sa_family == AF_INET6) { char buf[128] = ""; @@ -923,7 +923,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf)); strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf); strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", - ntohs(sin6_addr->sin6_port)); + ntohs(sin6_addr->sin6_port)); #endif } diff --git a/fetch-pack.c b/fetch-pack.c index 7aa5dfbdad..7f20eca4f8 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -854,8 +854,8 @@ static int get_pack(struct fetch_pack_args *args, if (xgethostname(hostname, sizeof(hostname))) xsnprintf(hostname, sizeof(hostname), "localhost"); strvec_pushf(&cmd.args, - "--keep=fetch-pack %"PRIuMAX " on %s", - (uintmax_t)getpid(), hostname); + "--keep=fetch-pack %"PRIuMAX " on %s", + (uintmax_t)getpid(), hostname); } if (only_packfile && args->check_self_contained_and_connected) strvec_push(&cmd.args, "--check-self-contained-and-connected"); @@ -885,7 +885,7 @@ static int get_pack(struct fetch_pack_args *args, if (pass_header) strvec_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32, - ntohl(header.hdr_version), + ntohl(header.hdr_version), ntohl(header.hdr_entries)); if (fetch_fsck_objects >= 0 ? fetch_fsck_objects @@ -901,7 +901,7 @@ static int get_pack(struct fetch_pack_args *args, strvec_push(&cmd.args, "--fsck-objects"); else strvec_pushf(&cmd.args, "--strict%s", - fsck_msg_types.buf); + fsck_msg_types.buf); } cmd.in = demux.out; @@ -1654,8 +1654,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, strvec_push(&cmd.args, "http-fetch"); strvec_pushf(&cmd.args, "--packfile=%.*s", - (int) the_hash_algo->hexsz, - packfile_uris.items[i].string); + (int) the_hash_algo->hexsz, + packfile_uris.items[i].string); strvec_push(&cmd.args, uri); cmd.git_cmd = 1; cmd.no_stdin = 1; diff --git a/gpg-interface.c b/gpg-interface.c index cf56fe838f..b499270836 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -285,9 +285,9 @@ static int verify_signed_buffer(const char *payload, size_t payload_size, strvec_push(&gpg.args, fmt->program); strvec_pushv(&gpg.args, fmt->verify_args); strvec_pushl(&gpg.args, - "--status-fd=1", - "--verify", temp->filename.buf, "-", - NULL); + "--status-fd=1", + "--verify", temp->filename.buf, "-", + NULL); if (!gpg_status) gpg_status = &buf; @@ -435,10 +435,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig struct strbuf gpg_status = STRBUF_INIT; strvec_pushl(&gpg.args, - use_format->program, - "--status-fd=2", - "-bsau", signing_key, - NULL); + use_format->program, + "--status-fd=2", + "-bsau", signing_key, + NULL); bottom = signature->len; diff --git a/http-backend.c b/http-backend.c index 92fd62f73f..a03b4bae22 100644 --- a/http-backend.c +++ b/http-backend.c @@ -480,7 +480,7 @@ static void run_service(const char **argv, int buffer_input) strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user); if (!getenv("GIT_COMMITTER_EMAIL")) strvec_pushf(&cld.env_array, - "GIT_COMMITTER_EMAIL=%s@http.%s", user, host); + "GIT_COMMITTER_EMAIL=%s@http.%s", user, host); cld.argv = argv; if (buffer_input || gzipped_request || req_len >= 0) diff --git a/http-push.c b/http-push.c index e1deea6fe4..31911aa345 100644 --- a/http-push.c +++ b/http-push.c @@ -1929,7 +1929,7 @@ int cmd_main(int argc, const char **argv) strvec_push(&commit_argv, oid_to_hex(&ref->new_oid)); if (!push_all && !is_null_oid(&ref->old_oid)) strvec_pushf(&commit_argv, "^%s", - oid_to_hex(&ref->old_oid)); + 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); revs.edge_hint = 0; /* just in case */ diff --git a/http.c b/http.c index 268a1e9744..8b23a546af 100644 --- a/http.c +++ b/http.c @@ -2276,7 +2276,7 @@ int finish_http_pack_request(struct http_pack_request *preq) ip.in = tmpfile_fd; if (preq->generate_keep) { strvec_pushf(&ip.args, "--keep=git %"PRIuMAX, - (uintmax_t)getpid()); + (uintmax_t)getpid()); ip.out = 0; } else { ip.no_stdout = 1; diff --git a/range-diff.c b/range-diff.c index 3a0eb70c89..831c490bf2 100644 --- a/range-diff.c +++ b/range-diff.c @@ -52,20 +52,20 @@ static int read_patches(const char *range, struct string_list *list, size_t size; strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges", - "--reverse", "--date-order", "--decorate=no", - "--no-prefix", - /* - * Choose indicators that are not used anywhere - * else in diffs, but still look reasonable - * (e.g. will not be confusing when debugging) - */ - "--output-indicator-new=>", - "--output-indicator-old=<", - "--output-indicator-context=#", - "--no-abbrev-commit", - "--pretty=medium", - "--notes", - NULL); + "--reverse", "--date-order", "--decorate=no", + "--no-prefix", + /* + * Choose indicators that are not used anywhere + * else in diffs, but still look reasonable + * (e.g. will not be confusing when debugging) + */ + "--output-indicator-new=>", + "--output-indicator-old=<", + "--output-indicator-context=#", + "--no-abbrev-commit", + "--pretty=medium", + "--notes", + NULL); if (other_arg) strvec_pushv(&cp.args, other_arg->argv); strvec_push(&cp.args, range); diff --git a/refspec.c b/refspec.c index 6f317d6b44..f10ef284ce 100644 --- a/refspec.c +++ b/refspec.c @@ -222,8 +222,8 @@ void refspec_ref_prefixes(const struct refspec *rs, if (item->pattern) { const char *glob = strchr(prefix, '*'); strvec_pushf(ref_prefixes, "%.*s", - (int)(glob - prefix), - prefix); + (int)(glob - prefix), + prefix); } else { expand_ref_prefix(ref_prefixes, prefix); } diff --git a/remote-curl.c b/remote-curl.c index 85ce4f7e6f..7feaddc003 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1145,7 +1145,7 @@ static int fetch_git(struct discovery *heads, struct strbuf rpc_result = STRBUF_INIT; strvec_pushl(&args, "fetch-pack", "--stateless-rpc", - "--stdin", "--lock-pack", NULL); + "--stdin", "--lock-pack", NULL); if (options.followtags) strvec_push(&args, "--include-tag"); if (options.thin) @@ -1166,7 +1166,7 @@ static int fetch_git(struct discovery *heads, strvec_pushf(&args, "--shallow-since=%s", options.deepen_since); for (i = 0; i < options.deepen_not.nr; i++) strvec_pushf(&args, "--shallow-exclude=%s", - options.deepen_not.items[i].string); + options.deepen_not.items[i].string); if (options.deepen_relative && options.depth) strvec_push(&args, "--deepen-relative"); if (options.from_promisor) @@ -1293,7 +1293,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) strvec_init(&args); strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status", - NULL); + NULL); if (options.thin) strvec_push(&args, "--thin"); @@ -1311,7 +1311,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) strvec_push(&args, "--verbose"); for (i = 0; i < options.push_options.nr; i++) strvec_pushf(&args, "--push-option=%s", - options.push_options.items[i].string); + options.push_options.items[i].string); strvec_push(&args, options.progress ? "--progress" : "--no-progress"); for_each_string_list_item(cas_option, &cas_options) strvec_push(&args, cas_option->string); diff --git a/remote.c b/remote.c index 13b097866c..b4665fe5a3 100644 --- a/remote.c +++ b/remote.c @@ -1914,8 +1914,8 @@ static int stat_branch_pair(const char *branch_name, const char *base, 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)); + oid_to_hex(&ours->object.oid), + oid_to_hex(&theirs->object.oid)); strvec_push(&argv, "--"); repo_init_revisions(the_repository, &revs, NULL); diff --git a/sequencer.c b/sequencer.c index 80c770968a..31a2b1ab55 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3133,7 +3133,7 @@ static int do_exec(struct repository *r, const char *command_line) child_argv[0] = command_line; 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())); + absolute_path(get_git_work_tree())); status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL, child_env.argv); @@ -3552,7 +3552,7 @@ static int do_merge(struct repository *r, strvec_push(&cmd.args, strategy); for (k = 0; k < opts->xopts_nr; k++) strvec_pushf(&cmd.args, - "-X%s", opts->xopts[k]); + "-X%s", opts->xopts[k]); } strvec_push(&cmd.args, "--no-edit"); strvec_push(&cmd.args, "--no-ff"); @@ -3566,7 +3566,7 @@ static int do_merge(struct repository *r, /* Add the tips to be merged */ for (j = to_merge; j; j = j->next) strvec_push(&cmd.args, - oid_to_hex(&j->item->object.oid)); + oid_to_hex(&j->item->object.oid)); strbuf_release(&ref_name); unlink(git_path_cherry_pick_head(r)); @@ -3695,7 +3695,7 @@ void create_autostash(struct repository *r, const char *path, struct object_id oid; strvec_pushl(&stash.args, - "stash", "create", "autostash", NULL); + "stash", "create", "autostash", NULL); stash.git_cmd = 1; stash.no_stdin = 1; strbuf_reset(&buf); diff --git a/submodule.c b/submodule.c index 5c9447422d..fb96d595b0 100644 --- a/submodule.c +++ b/submodule.c @@ -495,7 +495,7 @@ void prepare_submodule_repo_env(struct strvec *out) { prepare_submodule_repo_env_no_git_dir(out); strvec_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT, - DEFAULT_GIT_DIR_ENVIRONMENT); + DEFAULT_GIT_DIR_ENVIRONMENT); } static void prepare_submodule_repo_env_in_gitdir(struct strvec *out) @@ -687,14 +687,14 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, if (o->flags.reverse_diff) { strvec_pushf(&cp.args, "--src-prefix=%s%s/", - o->b_prefix, path); + o->b_prefix, path); strvec_pushf(&cp.args, "--dst-prefix=%s%s/", - o->a_prefix, path); + o->a_prefix, path); } else { strvec_pushf(&cp.args, "--src-prefix=%s%s/", - o->a_prefix, path); + o->a_prefix, path); strvec_pushf(&cp.args, "--dst-prefix=%s%s/", - o->b_prefix, path); + o->b_prefix, path); } strvec_push(&cp.args, oid_to_hex(old_oid)); /* @@ -1062,7 +1062,7 @@ static int push_submodule(const char *path, const struct string_list_item *item; for_each_string_list_item(item, push_options) strvec_pushf(&cp.args, "--push-option=%s", - item->string); + item->string); } if (remote->origin != REMOTE_UNCONFIGURED) { @@ -1780,7 +1780,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags) return 1; strvec_pushl(&cp.args, "status", "--porcelain", - "--ignore-submodules=none", NULL); + "--ignore-submodules=none", NULL); if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) strvec_push(&cp.args, "-uno"); @@ -1847,7 +1847,7 @@ static int submodule_has_dirty_index(const struct submodule *sub) cp.git_cmd = 1; strvec_pushl(&cp.args, "diff-index", "--quiet", - "--cached", "HEAD", NULL); + "--cached", "HEAD", NULL); cp.no_stdin = 1; cp.no_stdout = 1; cp.dir = sub->path; @@ -1867,7 +1867,7 @@ static void submodule_reset_index(const char *path) cp.dir = path; strvec_pushf(&cp.args, "--super-prefix=%s%s/", - get_super_prefix_or_empty(), path); + get_super_prefix_or_empty(), path); strvec_pushl(&cp.args, "read-tree", "-u", "--reset", NULL); strvec_push(&cp.args, empty_tree_oid_hex()); @@ -1948,7 +1948,7 @@ int submodule_move_head(const char *path, cp.dir = path; strvec_pushf(&cp.args, "--super-prefix=%s%s/", - get_super_prefix_or_empty(), path); + get_super_prefix_or_empty(), path); strvec_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL); if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN) @@ -1981,7 +1981,7 @@ int submodule_move_head(const char *path, prepare_submodule_repo_env(&cp.env_array); strvec_pushl(&cp.args, "update-ref", "HEAD", - "--no-deref", new_head, NULL); + "--no-deref", new_head, NULL); if (run_command(&cp)) { ret = -1; @@ -2158,8 +2158,8 @@ void absorb_git_dir_into_superproject(const char *path, cp.git_cmd = 1; cp.no_stdin = 1; strvec_pushl(&cp.args, "--super-prefix", sb.buf, - "submodule--helper", - "absorb-git-dirs", NULL); + "submodule--helper", + "absorb-git-dirs", NULL); prepare_submodule_repo_env(&cp.env_array); if (run_command(&cp)) die(_("could not recurse into submodule '%s'"), path); @@ -2197,8 +2197,8 @@ int get_superproject_working_tree(struct strbuf *buf) strvec_pop(&cp.env_array); strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..", - "ls-files", "-z", "--stage", "--full-name", "--", - subpath, NULL); + "ls-files", "-z", "--stage", "--full-name", "--", + subpath, NULL); strbuf_reset(&sb); cp.no_stdin = 1; diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 67dde56962..726835fcc2 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -244,10 +244,10 @@ static int quote_stress_test(int argc, const char **argv) strvec_clear(&args); if (msys2) strvec_pushl(&args, "sh", "-c", - "printf %s\\\\0 \"$@\"", "skip", NULL); + "printf %s\\\\0 \"$@\"", "skip", NULL); else strvec_pushl(&args, "test-tool", "run-command", - "quote-echo", NULL); + "quote-echo", NULL); arg_offset = args.argc; if (argc > 0) { @@ -339,7 +339,7 @@ static int inherit_handle(const char *argv0) tmp = xmkstemp(path); strvec_pushl(&cp.args, - "test-tool", argv0, "inherited-handle-child", NULL); + "test-tool", argv0, "inherited-handle-child", NULL); cp.in = -1; cp.no_stdout = cp.no_stderr = 1; if (start_command(&cp) < 0) diff --git a/transport-helper.c b/transport-helper.c index dcd4adf444..ae8011e9d5 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -136,7 +136,7 @@ static struct child_process *get_helper(struct transport *transport) if (have_git_dir()) strvec_pushf(&helper->env_array, "%s=%s", - GIT_DIR_ENVIRONMENT, get_git_dir()); + GIT_DIR_ENVIRONMENT, get_git_dir()); helper->trace2_child_class = helper->args.argv[0]; /* "remote-" */ diff --git a/upload-pack.c b/upload-pack.c index 1b0e1fca1a..4a7918e04e 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -301,8 +301,7 @@ static void create_pack_file(struct upload_pack_data *pack_data, strvec_pushf(&pack_objects.args, "--filter=%s", buf.buf); strbuf_release(&buf); } else { - strvec_pushf(&pack_objects.args, "--filter=%s", - spec); + strvec_pushf(&pack_objects.args, "--filter=%s", spec); } } if (uri_protocols) { diff --git a/wt-status.c b/wt-status.c index 60d4e847a5..8454662c90 100644 --- a/wt-status.c +++ b/wt-status.c @@ -913,8 +913,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom struct strbuf summary = STRBUF_INIT; char *summary_content; - strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s", - s->index_file); + strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s", s->index_file); strvec_push(&sm_summary.args, "submodule"); strvec_push(&sm_summary.args, "summary"); -- cgit v1.2.3 From d70a9eb611a9d242c1d26847d223b8677609305b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 20:37:20 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- add-interactive.c | 4 ++-- add-patch.c | 8 ++++---- bisect.c | 2 +- builtin/add.c | 2 +- builtin/am.c | 16 ++++++++-------- builtin/annotate.c | 2 +- builtin/bisect--helper.c | 4 ++-- builtin/clone.c | 4 ++-- builtin/commit.c | 2 +- builtin/describe.c | 6 +++--- builtin/difftool.c | 2 +- builtin/fetch.c | 6 +++--- builtin/gc.c | 24 ++++++++++++------------ builtin/pack-objects.c | 2 +- builtin/pull.c | 16 ++++++++-------- builtin/rebase.c | 16 ++++++++-------- builtin/receive-pack.c | 14 +++++++------- builtin/remote.c | 4 ++-- builtin/replace.c | 2 +- builtin/show-branch.c | 8 ++++---- builtin/stash.c | 8 ++++---- builtin/submodule--helper.c | 6 +++--- builtin/upload-archive.c | 4 ++-- builtin/worktree.c | 6 +++--- bundle.c | 2 +- commit.c | 2 +- connect.c | 16 ++++++++-------- daemon.c | 8 ++++---- diff.c | 2 +- environment.c | 2 +- exec-cmd.c | 6 +++--- git.c | 10 +++++----- graph.c | 4 ++-- http-push.c | 2 +- ls-refs.c | 6 +++--- merge.c | 2 +- pathspec.c | 2 +- range-diff.c | 2 +- ref-filter.c | 4 ++-- remote-curl.c | 6 +++--- remote.c | 2 +- revision.c | 4 ++-- run-command.c | 20 ++++++++++---------- sequencer.c | 4 ++-- serve.c | 6 +++--- strvec.c | 44 ++++++++++++++++++++++---------------------- strvec.h | 20 ++++++++++---------- submodule.c | 14 +++++++------- t/helper/test-run-command.c | 8 ++++---- tmp-objdir.c | 2 +- transport-helper.c | 2 +- upload-pack.c | 2 +- 52 files changed, 186 insertions(+), 186 deletions(-) (limited to 'add-patch.c') diff --git a/add-interactive.c b/add-interactive.c index 458f3a3e69..555c4abf32 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps, 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); @@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, 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); } diff --git a/add-patch.c b/add-patch.c index 8c0772803b..0f68eb665e 100644 --- a/add-patch.c +++ b/add-patch.c @@ -391,14 +391,14 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) 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); @@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) 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); diff --git a/bisect.c b/bisect.c index 99ff694960..6959fb8aad 100644 --- a/bisect.c +++ b/bisect.c @@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, 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 */ } diff --git a/builtin/add.c b/builtin/add.c index 6185dd12a8..ab39a60a0d 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode, /* 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; } diff --git a/builtin/am.c b/builtin/am.c index 992ab3ca27..dd4e6c2d9b 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths, 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; @@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, } 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) @@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file) 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); @@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file) 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); @@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f 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")); @@ -2376,10 +2376,10 @@ int cmd_am(int argc, const char **argv, const char *prefix) 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); } diff --git a/builtin/annotate.c b/builtin/annotate.c index 7b7ecd366d..58ff977a23 100644 --- a/builtin/annotate.c +++ b/builtin/annotate.c @@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix) strvec_push(&args, argv[i]); } - return cmd_blame(args.argc, args.argv, prefix); + return cmd_blame(args.nr, args.v, prefix); } diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index dd52878413..b46de0489e 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -168,7 +168,7 @@ static int bisect_reset(const char *commit) 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 '."), branch.buf); @@ -530,7 +530,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, 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 " "'."), diff --git a/builtin/clone.c b/builtin/clone.c index e26bd82dc4..fccc814a54 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo) */ 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; } @@ -844,7 +844,7 @@ static int checkout(int submodule_progress) "--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); } diff --git a/builtin/commit.c b/builtin/commit.c index c3f4067537..69ac78d5e5 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, 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); diff --git a/builtin/describe.c b/builtin/describe.c index e3cac8002c..7668591d57 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst) 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)) @@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix) 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); @@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix) 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); diff --git a/builtin/difftool.c b/builtin/difftool.c index 5ac021a1d4..7ac432b881 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -683,7 +683,7 @@ static int run_file_diff(int prompt, const char *prefix, 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); } diff --git a/builtin/fetch.c b/builtin/fetch.c index c2e7afeb6a..c49f0e9752 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1354,7 +1354,7 @@ static int do_fetch(struct transport *transport, 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/"); } @@ -1605,7 +1605,7 @@ static int fetch_multiple(struct string_list *list, int max_children) 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, @@ -1623,7 +1623,7 @@ static int fetch_multiple(struct string_list *list, int 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; } diff --git a/builtin/gc.c b/builtin/gc.c index 98719800a3..aafa0946f5 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -514,11 +514,11 @@ static void gc_before_repack(void) 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) @@ -653,8 +653,8 @@ 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); @@ -663,19 +663,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix) 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); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 323f8bce80..f00ae80796 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3704,7 +3704,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) 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(); diff --git a/builtin/pull.c b/builtin/pull.c index dae8766646..015f6ded0b 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -584,14 +584,14 @@ static int run_fetch(const char *repo, const char **refspecs) 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; } @@ -691,8 +691,8 @@ static int run_merge(void) 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) @@ -703,7 +703,7 @@ static int run_merge(void) 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; } @@ -882,8 +882,8 @@ static int run_rebase(const struct object_id *curr_head, 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) @@ -902,7 +902,7 @@ static int run_rebase(const struct object_id *curr_head, 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; } diff --git a/builtin/rebase.c b/builtin/rebase.c index 35aeb8effc..dadb52fa92 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -351,7 +351,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) 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) @@ -900,7 +900,7 @@ static int run_am(struct rebase_options *opts) 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"); @@ -969,7 +969,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action) 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", @@ -1625,8 +1625,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) 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") || @@ -1721,10 +1721,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) 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) { diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 1fc69cf5bc..439f29d6c7 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -950,7 +950,7 @@ static const char *push_to_deploy(unsigned char *sha1, 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; @@ -961,7 +961,7 @@ static const char *push_to_deploy(unsigned char *sha1, /* 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; @@ -974,7 +974,7 @@ static const char *push_to_deploy(unsigned char *sha1, 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; @@ -985,7 +985,7 @@ static const char *push_to_deploy(unsigned char *sha1, 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; @@ -1004,7 +1004,7 @@ static const char *push_to_checkout(unsigned char *hash, 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 @@ -1205,11 +1205,11 @@ static void run_update_post_hook(struct command *commands) 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; diff --git a/builtin/remote.c b/builtin/remote.c index a3b33c2c88..c8240e9fcd 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1470,7 +1470,7 @@ static int update(int argc, const char **argv) 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); @@ -1478,7 +1478,7 @@ static int update(int argc, const char **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; } diff --git a/builtin/replace.c b/builtin/replace.c index 7bc5d66ed9..cd48765911 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -513,7 +513,7 @@ static int convert_graft_file(int force) 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); } diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 4c918ce90d..7eae5f3801 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -561,7 +561,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb) * 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; @@ -684,9 +684,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) 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, diff --git a/builtin/stash.c b/builtin/stash.c index bfdbafae89..10d87630cd 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -745,7 +745,7 @@ static int show_stash(int argc, const char **argv, const char *prefix) 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; @@ -754,7 +754,7 @@ static int show_stash(int argc, const char **argv, const char *prefix) * 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; @@ -767,7 +767,7 @@ static int show_stash(int argc, const char **argv, const char *prefix) } } - 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); @@ -1611,5 +1611,5 @@ int cmd_stash(int argc, const char **argv, const char *prefix) /* 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); } diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 665db1ffed..df135abbf1 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -817,9 +817,9 @@ static void status_submodule(const char *path, const struct object_id *ce_oid, 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)) { diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c index f02bb0ea15..24654b4c9b 100644 --- a/builtin/upload-archive.c +++ b/builtin/upload-archive.c @@ -36,7 +36,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix) 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)) @@ -45,7 +45,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix) } /* 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); } diff --git a/builtin/worktree.c b/builtin/worktree.c index be5d84f0a0..378f332b5d 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -422,7 +422,7 @@ static int add_worktree(const char *path, const char *refname, strvec_push(&cp.args, "--quiet"); } - cp.env = child_env.argv; + cp.env = child_env.v; ret = run_command(&cp); if (ret) goto done; @@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname, 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; @@ -943,7 +943,7 @@ static void check_clean_worktree(struct worktree *wt, 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; diff --git a/bundle.c b/bundle.c index 565d05367f..7ef9c3a7c3 100644 --- a/bundle.c +++ b/bundle.c @@ -278,7 +278,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec * "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; diff --git a/commit.c b/commit.c index a5176a25bd..4ce8cb38d5 100644 --- a/commit.c +++ b/commit.c @@ -1643,7 +1643,7 @@ int run_commit_hook(int editor_is_used, const char *index_file, 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); diff --git a/connect.c b/connect.c index 3299ea956a..0b6aba177e 100644 --- a/connect.c +++ b/connect.c @@ -70,9 +70,9 @@ int server_supports_v2(const char *c, int die_on_error) { 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; } @@ -87,9 +87,9 @@ int server_feature_v2(const char *c, const char **v) { 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; @@ -103,9 +103,9 @@ int server_supports_feature(const char *c, const char *feature, { 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; @@ -488,9 +488,9 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, 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); diff --git a/daemon.c b/daemon.c index 0dec89fa02..2ab7ea82eb 100644 --- a/daemon.c +++ b/daemon.c @@ -482,7 +482,7 @@ static int upload_pack(const struct strvec *env) 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); } @@ -492,7 +492,7 @@ static int upload_archive(const struct strvec *env) 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); } @@ -502,7 +502,7 @@ static int receive_pack(const struct strvec *env) 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); } @@ -927,7 +927,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) #endif } - cld.argv = cld_argv.argv; + cld.argv = cld_argv.v; cld.in = incoming; cld.out = dup(incoming); diff --git a/diff.c b/diff.c index f1a3758922..f9709de7b4 100644 --- a/diff.c +++ b/diff.c @@ -4239,7 +4239,7 @@ static void run_external_diff(const char *pgm, 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(); diff --git a/environment.c b/environment.c index 00fe20e496..52e0c979ba 100644 --- a/environment.c +++ b/environment.c @@ -164,7 +164,7 @@ static const char *getenv_safe(struct strvec *argv, const char *name) 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) diff --git a/exec-cmd.c b/exec-cmd.c index 0f8e888424..eeb2ee52b8 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -324,7 +324,7 @@ const char **prepare_git_cmd(struct strvec *out, const char **argv) { strvec_push(out, "git"); strvec_pushv(out, argv); - return out->argv; + return out->v; } int execv_git_cmd(const char **argv) @@ -332,10 +332,10 @@ 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)); diff --git a/git.c b/git.c index 258035cfb1..8bd1d7551d 100644 --- a/git.c +++ b/git.c @@ -352,7 +352,7 @@ static int handle_alias(int *argcp, const char ***argv) 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_"); @@ -667,7 +667,7 @@ static void handle_builtin(int argc, const char **argv) } argc++; - argv = args.argv; + argv = args.v; } builtin = get_builtin(cmd); @@ -701,7 +701,7 @@ static void execv_dashed_external(const char **argv) * 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 @@ -762,13 +762,13 @@ static int run_argv(int *argcp, const char ***argv) 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); diff --git a/graph.c b/graph.c index 09c9cc968c..c128ad0cce 100644 --- a/graph.c +++ b/graph.c @@ -355,8 +355,8 @@ struct git_graph *graph_init(struct rev_info *opt) 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); } } diff --git a/http-push.c b/http-push.c index 31911aa345..6a4a43e07f 100644 --- a/http-push.c +++ b/http-push.c @@ -1931,7 +1931,7 @@ int cmd_main(int argc, const char **argv) 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 */ diff --git a/ls-refs.c b/ls-refs.c index 8192c949f4..a1e0b473e4 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -15,11 +15,11 @@ static int ref_match(const struct strvec *prefixes, const char *refname) { 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; diff --git a/merge.c b/merge.c index a05b054faa..753e461659 100644 --- a/merge.c +++ b/merge.c @@ -33,7 +33,7 @@ int try_merge_command(struct repository *r, 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); diff --git a/pathspec.c b/pathspec.c index c303126f37..7a229d8d22 100644 --- a/pathspec.c +++ b/pathspec.c @@ -652,7 +652,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask, 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); } diff --git a/range-diff.c b/range-diff.c index 831c490bf2..24dc435e48 100644 --- a/range-diff.c +++ b/range-diff.c @@ -67,7 +67,7 @@ static int read_patches(const char *range, struct string_list *list, "--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; diff --git a/ref-filter.c b/ref-filter.c index 7f013851ed..0d3a56b79b 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1918,9 +1918,9 @@ static void find_longest_prefixes(struct string_list *out, 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); diff --git a/remote-curl.c b/remote-curl.c index 7feaddc003..41c3ac5c92 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1190,7 +1190,7 @@ static int fetch_git(struct discovery *heads, 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); @@ -1325,7 +1325,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) 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); @@ -1366,7 +1366,7 @@ static void parse_push(struct strbuf *buf) break; } while (1); - ret = push(specs.argc, specs.argv); + ret = push(specs.nr, specs.v); printf("\n"); fflush(stdout); diff --git a/remote.c b/remote.c index b4665fe5a3..c5ed74f91c 100644 --- a/remote.c +++ b/remote.c @@ -1919,7 +1919,7 @@ static int stat_branch_pair(const char *branch_name, const char *base, 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")); diff --git a/revision.c b/revision.c index e144132ae9..bc69f19141 100644 --- a/revision.c +++ b/revision.c @@ -2767,7 +2767,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s 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. @@ -2783,7 +2783,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); + revs->prefix, prune_data.v); } strvec_clear(&prune_data); diff --git a/run-command.c b/run-command.c index b9630a1b5f..cc9c3296ba 100644 --- a/run-command.c +++ b/run-command.c @@ -287,7 +287,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv) } strvec_pushv(out, argv); - return out->argv; + return out->v; } #ifndef GIT_WINDOWS_NATIVE @@ -426,11 +426,11 @@ static int prepare_cmd(struct strvec *out, const struct child_process *cmd) * 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; @@ -672,9 +672,9 @@ int start_command(struct child_process *cmd) 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 @@ -846,10 +846,10 @@ fail_pipe: * 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) { @@ -1874,7 +1874,7 @@ int run_auto_gc(int quiet) 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; } diff --git a/sequencer.c b/sequencer.c index 31a2b1ab55..cc3f8fa88e 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2761,7 +2761,7 @@ static int reset_merge(const struct object_id *oid) 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; @@ -3135,7 +3135,7 @@ static int do_exec(struct repository *r, const char *command_line) 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) diff --git a/serve.c b/serve.c index 523a9be32d..f6341206c4 100644 --- a/serve.c +++ b/serve.c @@ -146,9 +146,9 @@ int has_capability(const struct strvec *keys, const char *capability, 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 == '=') @@ -223,7 +223,7 @@ static int process_request(void) * If no command and no keys were given then the client * wanted to terminate the connection. */ - if (!keys.argc) + if (!keys.nr) return 1; /* diff --git a/strvec.c b/strvec.c index 9e76ab9295..21dce0a7a4 100644 --- a/strvec.c +++ b/strvec.c @@ -6,25 +6,25 @@ const char *empty_strvec[] = { NULL }; 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, ...) @@ -37,7 +37,7 @@ 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, ...) @@ -51,19 +51,19 @@ 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) @@ -88,21 +88,21 @@ 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; } diff --git a/strvec.h b/strvec.h index bd35de1ce4..fdcad75b45 100644 --- a/strvec.h +++ b/strvec.h @@ -2,10 +2,10 @@ #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(). * @@ -22,15 +22,15 @@ extern const char *empty_strvec[]; /** * 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 } @@ -78,7 +78,7 @@ void strvec_split(struct strvec *, const char *); 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 diff --git a/submodule.c b/submodule.c index fb96d595b0..a52b93a87f 100644 --- a/submodule.c +++ b/submodule.c @@ -269,7 +269,7 @@ int is_submodule_active(struct repository *repo, const char *path) 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); @@ -842,7 +842,7 @@ static void collect_changed_submodules(struct repository *r, 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")); @@ -1014,7 +1014,7 @@ int find_unpushed_submodules(struct repository *r, 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"); @@ -1453,7 +1453,7 @@ static int get_next_submodule(struct child_process *cp, 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"); @@ -1501,7 +1501,7 @@ static int get_next_submodule(struct child_process *cp, 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); @@ -1619,8 +1619,8 @@ int fetch_populated_submodules(struct repository *r, 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 */ diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 726835fcc2..7ae03dc712 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -248,7 +248,7 @@ static int quote_stress_test(int argc, const char **argv) else strvec_pushl(&args, "test-tool", "run-command", "quote-echo", NULL); - arg_offset = args.argc; + arg_offset = args.nr; if (argc > 0) { trials = 1; @@ -275,13 +275,13 @@ static int quote_stress_test(int argc, const char **argv) 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', " @@ -298,7 +298,7 @@ static int quote_stress_test(int argc, const char **argv) 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); diff --git a/tmp-objdir.c b/tmp-objdir.c index e78e481d8e..42ed4db5d3 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -283,7 +283,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t) { if (!t) return NULL; - return t->env.argv; + return t->env.v; } void tmp_objdir_add_as_alternate(const struct tmp_objdir *t) diff --git a/transport-helper.c b/transport-helper.c index ae8011e9d5..defafbf4c1 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -138,7 +138,7 @@ static struct child_process *get_helper(struct transport *transport) strvec_pushf(&helper->env_array, "%s=%s", GIT_DIR_ENVIRONMENT, get_git_dir()); - helper->trace2_child_class = helper->args.argv[0]; /* "remote-" */ + helper->trace2_child_class = helper->args.v[0]; /* "remote-" */ code = start_command(helper); if (code < 0 && errno == ENOENT) diff --git a/upload-pack.c b/upload-pack.c index 4a7918e04e..db8c6509fe 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -897,7 +897,7 @@ static int send_shallow_list(struct upload_pack_data *data) 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 { -- cgit v1.2.3