@matheusbsbs / matheus-bagliano / commits / ef8d7ac42a
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 28, 2020 at 16:24 UTC ef8d7ac42a6a62d678166fe25ea743315809d2bb
27 files changed +201 -201
add-interactive.c
+7 -7
@@ -935,18 +935,18 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
935 opts->prompt = N_("Patch update");
936 count = list_and_choose(s, files, opts);
937 if (count > 0) {
938 - struct argv_array args = ARGV_ARRAY_INIT;
938 + struct strvec args = STRVEC_INIT;
939 struct pathspec ps_selected = { 0 };
940
941 for (i = 0; i < files->items.nr; i++)
942 if (files->selected[i])
943 - argv_array_push(&args,
943 + strvec_push(&args,
944 files->items.items[i].string);
945 parse_pathspec(&ps_selected,
946 PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
947 PATHSPEC_LITERAL_PATH, "", args.argv);
948 res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
949 - argv_array_clear(&args);
949 + strvec_clear(&args);
950 clear_pathspec(&ps_selected);
951 }
952
@@ -976,18 +976,18 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
976 count = list_and_choose(s, files, opts);
977 opts->flags = 0;
978 if (count > 0) {
979 - struct argv_array args = ARGV_ARRAY_INIT;
979 + struct strvec args = STRVEC_INIT;
980
981 - argv_array_pushl(&args, "git", "diff", "-p", "--cached",
981 + strvec_pushl(&args, "git", "diff", "-p", "--cached",
982 oid_to_hex(!is_initial ? &oid :
983 s->r->hash_algo->empty_tree),
984 "--", NULL);
985 for (i = 0; i < files->items.nr; i++)
986 if (files->selected[i])
987 - argv_array_push(&args,
987 + strvec_push(&args,
988 files->items.items[i].string);
989 res = run_command_v_opt(args.argv, 0);
990 - argv_array_clear(&args);
990 + strvec_clear(&args);
991 }
992
993 putchar('\n');
add-patch.c
+14 -14
@@ -286,11 +286,11 @@ static void setup_child_process(struct add_p_state *s,
286
287 va_start(ap, cp);
288 while ((arg = va_arg(ap, const char *)))
289 - argv_array_push(&cp->args, arg);
289 + strvec_push(&cp->args, arg);
290 va_end(ap);
291
292 cp->git_cmd = 1;
293 - argv_array_pushf(&cp->env_array,
293 + strvec_pushf(&cp->env_array,
294 INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
295 }
296
@@ -370,7 +370,7 @@ static int is_octal(const char *p, size_t len)
370
371 static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
372 {
373 - struct argv_array args = ARGV_ARRAY_INIT;
373 + struct strvec args = STRVEC_INIT;
374 const char *diff_algorithm = s->s.interactive_diff_algorithm;
375 struct strbuf *plain = &s->plain, *colored = NULL;
376 struct child_process cp = CHILD_PROCESS_INIT;
@@ -380,12 +380,12 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
380 struct hunk *hunk = NULL;
381 int res;
382
383 - argv_array_pushv(&args, s->mode->diff_cmd);
383 + strvec_pushv(&args, s->mode->diff_cmd);
384 if (diff_algorithm)
385 - argv_array_pushf(&args, "--diff-algorithm=%s", diff_algorithm);
385 + strvec_pushf(&args, "--diff-algorithm=%s", diff_algorithm);
386 if (s->revision) {
387 struct object_id oid;
388 - argv_array_push(&args,
388 + strvec_push(&args,
389 /* could be on an unborn branch */
390 !strcmp("HEAD", s->revision) &&
391 get_oid("HEAD", &oid) ?
@@ -393,19 +393,19 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
393 }
394 color_arg_index = args.argc;
395 /* Use `--no-color` explicitly, just in case `diff.color = always`. */
396 - argv_array_pushl(&args, "--no-color", "-p", "--", NULL);
396 + strvec_pushl(&args, "--no-color", "-p", "--", NULL);
397 for (i = 0; i < ps->nr; i++)
398 - argv_array_push(&args, ps->items[i].original);
398 + strvec_push(&args, ps->items[i].original);
399
400 setup_child_process(s, &cp, NULL);
401 cp.argv = args.argv;
402 res = capture_command(&cp, plain, 0);
403 if (res) {
404 - argv_array_clear(&args);
404 + strvec_clear(&args);
405 return error(_("could not parse diff"));
406 }
407 if (!plain->len) {
408 - argv_array_clear(&args);
408 + strvec_clear(&args);
409 return 0;
410 }
411 strbuf_complete_line(plain);
@@ -419,7 +419,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
419 colored_cp.argv = args.argv;
420 colored = &s->colored;
421 res = capture_command(&colored_cp, colored, 0);
422 - argv_array_clear(&args);
422 + strvec_clear(&args);
423 if (res)
424 return error(_("could not parse colored diff"));
425
@@ -444,7 +444,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
444 colored_p = colored->buf;
445 colored_pend = colored_p + colored->len;
446 }
447 - argv_array_clear(&args);
447 + strvec_clear(&args);
448
449 /* parse files and hunks */
450 p = plain->buf;
@@ -1158,7 +1158,7 @@ static int run_apply_check(struct add_p_state *s,
1158
1159 setup_child_process(s, &cp,
1160 "apply", "--check", NULL);
1161 - argv_array_pushv(&cp.args, s->mode->apply_check_args);
1161 + strvec_pushv(&cp.args, s->mode->apply_check_args);
1162 if (pipe_command(&cp, s->buf.buf, s->buf.len, NULL, 0, NULL, 0))
1163 return error(_("'git apply --cached' failed"));
1164
@@ -1619,7 +1619,7 @@ soft_increment:
1619 s->mode->is_reverse);
1620 else {
1621 setup_child_process(s, &cp, "apply", NULL);
1622 - argv_array_pushv(&cp.args, s->mode->apply_args);
1622 + strvec_pushv(&cp.args, s->mode->apply_args);
1623 if (pipe_command(&cp, s->buf.buf, s->buf.len,
1624 NULL, 0, NULL, 0))
1625 error(_("'git apply' failed"));
bisect.c
+6 -6
@@ -456,7 +456,7 @@ static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
456 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
457 static GIT_PATH_FUNC(git_path_head_name, "head-name")
458
459 -static void read_bisect_paths(struct argv_array *array)
459 +static void read_bisect_paths(struct strvec *array)
460 {
461 struct strbuf str = STRBUF_INIT;
462 const char *filename = git_path_bisect_names();
@@ -632,7 +632,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
632 const char *bad_format, const char *good_format,
633 int read_paths)
634 {
635 - struct argv_array rev_argv = ARGV_ARRAY_INIT;
635 + struct strvec rev_argv = STRVEC_INIT;
636 int i;
637
638 repo_init_revisions(r, revs, prefix);
@@ -640,12 +640,12 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
640 revs->commit_format = CMIT_FMT_UNSPECIFIED;
641
642 /* rev_argv.argv[0] will be ignored by setup_revisions */
643 - argv_array_push(&rev_argv, "bisect_rev_setup");
644 - argv_array_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
643 + strvec_push(&rev_argv, "bisect_rev_setup");
644 + strvec_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
645 for (i = 0; i < good_revs.nr; i++)
646 - argv_array_pushf(&rev_argv, good_format,
646 + strvec_pushf(&rev_argv, good_format,
647 oid_to_hex(good_revs.oid + i));
648 - argv_array_push(&rev_argv, "--");
648 + strvec_push(&rev_argv, "--");
649 if (read_paths)
650 read_bisect_paths(&rev_argv);
651
bundle.c
+6 -6
@@ -269,16 +269,16 @@ out:
269
270
271 /* Write the pack data to bundle_fd */
272 -static int write_pack_data(int bundle_fd, struct rev_info *revs, struct argv_array *pack_options)
272 +static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)
273 {
274 struct child_process pack_objects = CHILD_PROCESS_INIT;
275 int i;
276
277 - argv_array_pushl(&pack_objects.args,
277 + strvec_pushl(&pack_objects.args,
278 "pack-objects",
279 "--stdout", "--thin", "--delta-base-offset",
280 NULL);
281 - argv_array_pushv(&pack_objects.args, pack_options->argv);
281 + strvec_pushv(&pack_objects.args, pack_options->argv);
282 pack_objects.in = -1;
283 pack_objects.out = bundle_fd;
284 pack_objects.git_cmd = 1;
@@ -321,11 +321,11 @@ static int compute_and_write_prerequisites(int bundle_fd,
321 FILE *rls_fout;
322 int i;
323
324 - argv_array_pushl(&rls.args,
324 + strvec_pushl(&rls.args,
325 "rev-list", "--boundary", "--pretty=oneline",
326 NULL);
327 for (i = 1; i < argc; i++)
328 - argv_array_push(&rls.args, argv[i]);
328 + strvec_push(&rls.args, argv[i]);
329 rls.out = -1;
330 rls.git_cmd = 1;
331 if (start_command(&rls))
@@ -449,7 +449,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
449 }
450
451 int create_bundle(struct repository *r, const char *path,
452 - int argc, const char **argv, struct argv_array *pack_options)
452 + int argc, const char **argv, struct strvec *pack_options)
453 {
454 struct lock_file lock = LOCK_INIT;
455 int bundle_fd = -1;
bundle.h
+1 -1
@@ -21,7 +21,7 @@ struct bundle_header {
21 int is_bundle(const char *path, int quiet);
22 int read_bundle_header(const char *path, struct bundle_header *header);
23 int create_bundle(struct repository *r, const char *path,
24 - int argc, const char **argv, struct argv_array *pack_options);
24 + int argc, const char **argv, struct strvec *pack_options);
25 int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
26 #define BUNDLE_VERBOSE 1
27 int unbundle(struct repository *r, struct bundle_header *header,
column.c
+6 -6
@@ -358,7 +358,7 @@ static struct child_process column_process = CHILD_PROCESS_INIT;
358
359 int run_column_filter(int colopts, const struct column_options *opts)
360 {
361 - struct argv_array *argv;
361 + struct strvec *argv;
362
363 if (fd_out != -1)
364 return -1;
@@ -366,14 +366,14 @@ int run_column_filter(int colopts, const struct column_options *opts)
366 child_process_init(&column_process);
367 argv = &column_process.args;
368
369 - argv_array_push(argv, "column");
370 - argv_array_pushf(argv, "--raw-mode=%d", colopts);
369 + strvec_push(argv, "column");
370 + strvec_pushf(argv, "--raw-mode=%d", colopts);
371 if (opts && opts->width)
372 - argv_array_pushf(argv, "--width=%d", opts->width);
372 + strvec_pushf(argv, "--width=%d", opts->width);
373 if (opts && opts->indent)
374 - argv_array_pushf(argv, "--indent=%s", opts->indent);
374 + strvec_pushf(argv, "--indent=%s", opts->indent);
375 if (opts && opts->padding)
376 - argv_array_pushf(argv, "--padding=%d", opts->padding);
376 + strvec_pushf(argv, "--padding=%d", opts->padding);
377
378 fflush(stdout);
379 column_process.in = -1;
commit.c
+4 -4
@@ -1630,22 +1630,22 @@ size_t ignore_non_trailer(const char *buf, size_t len)
1630 int run_commit_hook(int editor_is_used, const char *index_file,
1631 const char *name, ...)
1632 {
1633 - struct argv_array hook_env = ARGV_ARRAY_INIT;
1633 + struct strvec hook_env = STRVEC_INIT;
1634 va_list args;
1635 int ret;
1636
1637 - argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
1637 + strvec_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
1638
1639 /*
1640 * Let the hook know that no editor will be launched.
1641 */
1642 if (!editor_is_used)
1643 - argv_array_push(&hook_env, "GIT_EDITOR=:");
1643 + strvec_push(&hook_env, "GIT_EDITOR=:");
1644
1645 va_start(args, name);
1646 ret = run_hook_ve(hook_env.argv,name, args);
1647 va_end(args);
1648 - argv_array_clear(&hook_env);
1648 + strvec_clear(&hook_env);
1649
1650 return ret;
1651 }
compat/mingw.c
+2 -2
@@ -18,8 +18,8 @@ void open_in_gdb(void)
18 static struct child_process cp = CHILD_PROCESS_INIT;
19 extern char *_pgmptr;
20
21 - argv_array_pushl(&cp.args, "mintty", "gdb", NULL);
22 - argv_array_pushf(&cp.args, "--pid=%d", getpid());
21 + strvec_pushl(&cp.args, "mintty", "gdb", NULL);
22 + strvec_pushf(&cp.args, "--pid=%d", getpid());
23 cp.clean_on_exit = 1;
24 if (start_command(&cp) < 0)
25 die_errno("Could not start gdb");
compat/terminal.c
+9 -9
@@ -86,9 +86,9 @@ static void restore_term(void)
86 if (stty_restore.nr == 0)
87 return;
88
89 - argv_array_push(&cp.args, "stty");
89 + strvec_push(&cp.args, "stty");
90 for (i = 0; i < stty_restore.nr; i++)
91 - argv_array_push(&cp.args, stty_restore.items[i].string);
91 + strvec_push(&cp.args, stty_restore.items[i].string);
92 run_command(&cp);
93 string_list_clear(&stty_restore, 0);
94 return;
@@ -107,25 +107,25 @@ static int disable_bits(DWORD bits)
107 if (use_stty) {
108 struct child_process cp = CHILD_PROCESS_INIT;
109
110 - argv_array_push(&cp.args, "stty");
110 + strvec_push(&cp.args, "stty");
111
112 if (bits & ENABLE_LINE_INPUT) {
113 string_list_append(&stty_restore, "icanon");
114 - argv_array_push(&cp.args, "-icanon");
114 + strvec_push(&cp.args, "-icanon");
115 }
116
117 if (bits & ENABLE_ECHO_INPUT) {
118 string_list_append(&stty_restore, "echo");
119 - argv_array_push(&cp.args, "-echo");
119 + strvec_push(&cp.args, "-echo");
120 }
121
122 if (bits & ENABLE_PROCESSED_INPUT) {
123 string_list_append(&stty_restore, "-ignbrk");
124 string_list_append(&stty_restore, "intr");
125 string_list_append(&stty_restore, "^c");
126 - argv_array_push(&cp.args, "ignbrk");
127 - argv_array_push(&cp.args, "intr");
128 - argv_array_push(&cp.args, "");
126 + strvec_push(&cp.args, "ignbrk");
127 + strvec_push(&cp.args, "intr");
128 + strvec_push(&cp.args, "");
129 }
130
131 if (run_command(&cp) == 0)
@@ -273,7 +273,7 @@ static int is_known_escape_sequence(const char *sequence)
273 hashmap_init(&sequences, (hashmap_cmp_fn)sequence_entry_cmp,
274 NULL, 0);
275
276 - argv_array_pushl(&cp.args, "infocmp", "-L", "-1", NULL);
276 + strvec_pushl(&cp.args, "infocmp", "-L", "-1", NULL);
277 if (pipe_command(&cp, NULL, 0, &buf, 0, NULL, 0))
278 strbuf_setlen(&buf, 0);
279
connect.c
+24 -24
@@ -17,7 +17,7 @@
17 #include "alias.h"
18
19 static char *server_capabilities_v1;
20 -static struct argv_array server_capabilities_v2 = ARGV_ARRAY_INIT;
20 +static struct strvec server_capabilities_v2 = STRVEC_INIT;
21 static const char *next_server_feature_value(const char *feature, int *len, int *offset);
22
23 static int check_ref(const char *name, unsigned int flags)
@@ -123,7 +123,7 @@ int server_supports_feature(const char *c, const char *feature,
123 static void process_capabilities_v2(struct packet_reader *reader)
124 {
125 while (packet_reader_read(reader) == PACKET_READ_NORMAL)
126 - argv_array_push(&server_capabilities_v2, reader->line);
126 + strvec_push(&server_capabilities_v2, reader->line);
127
128 if (reader->status != PACKET_READ_FLUSH)
129 die(_("expected flush after capabilities"));
@@ -453,7 +453,7 @@ void check_stateless_delimiter(int stateless_rpc,
453
454 struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
455 struct ref **list, int for_push,
456 - const struct argv_array *ref_prefixes,
456 + const struct strvec *ref_prefixes,
457 const struct string_list *server_options,
458 int stateless_rpc)
459 {
@@ -944,9 +944,9 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
944
945 proxy = xmalloc(sizeof(*proxy));
946 child_process_init(proxy);
947 - argv_array_push(&proxy->args, git_proxy_command);
948 - argv_array_push(&proxy->args, host);
949 - argv_array_push(&proxy->args, port);
947 + strvec_push(&proxy->args, git_proxy_command);
948 + strvec_push(&proxy->args, host);
949 + strvec_push(&proxy->args, port);
950 proxy->in = -1;
951 proxy->out = -1;
952 if (start_command(proxy))
@@ -1199,15 +1199,15 @@ static struct child_process *git_connect_git(int fd[2], char *hostandport,
1199 * Append the appropriate environment variables to `env` and options to
1200 * `args` for running ssh in Git's SSH-tunneled transport.
1201 */
1202 -static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1202 +static void push_ssh_options(struct strvec *args, struct strvec *env,
1203 enum ssh_variant variant, const char *port,
1204 enum protocol_version version, int flags)
1205 {
1206 if (variant == VARIANT_SSH &&
1207 version > 0) {
1208 - argv_array_push(args, "-o");
1209 - argv_array_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT);
1210 - argv_array_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
1208 + strvec_push(args, "-o");
1209 + strvec_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT);
1210 + strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
1211 version);
1212 }
1213
@@ -1221,7 +1221,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1221 case VARIANT_PLINK:
1222 case VARIANT_PUTTY:
1223 case VARIANT_TORTOISEPLINK:
1224 - argv_array_push(args, "-4");
1224 + strvec_push(args, "-4");
1225 }
1226 } else if (flags & CONNECT_IPV6) {
1227 switch (variant) {
@@ -1233,12 +1233,12 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1233 case VARIANT_PLINK:
1234 case VARIANT_PUTTY:
1235 case VARIANT_TORTOISEPLINK:
1236 - argv_array_push(args, "-6");
1236 + strvec_push(args, "-6");
1237 }
1238 }
1239
1240 if (variant == VARIANT_TORTOISEPLINK)
1241 - argv_array_push(args, "-batch");
1241 + strvec_push(args, "-batch");
1242
1243 if (port) {
1244 switch (variant) {
@@ -1247,15 +1247,15 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1247 case VARIANT_SIMPLE:
1248 die(_("ssh variant 'simple' does not support setting port"));
1249 case VARIANT_SSH:
1250 - argv_array_push(args, "-p");
1250 + strvec_push(args, "-p");
1251 break;
1252 case VARIANT_PLINK:
1253 case VARIANT_PUTTY:
1254 case VARIANT_TORTOISEPLINK:
1255 - argv_array_push(args, "-P");
1255 + strvec_push(args, "-P");
1256 }
1257
1258 - argv_array_push(args, port);
1258 + strvec_push(args, port);
1259 }
1260 }
1261
@@ -1293,18 +1293,18 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1293 detect.use_shell = conn->use_shell;
1294 detect.no_stdin = detect.no_stdout = detect.no_stderr = 1;
1295
1296 - argv_array_push(&detect.args, ssh);
1297 - argv_array_push(&detect.args, "-G");
1296 + strvec_push(&detect.args, ssh);
1297 + strvec_push(&detect.args, "-G");
1298 push_ssh_options(&detect.args, &detect.env_array,
1299 VARIANT_SSH, port, version, flags);
1300 - argv_array_push(&detect.args, ssh_host);
1300 + strvec_push(&detect.args, ssh_host);
1301
1302 variant = run_command(&detect) ? VARIANT_SIMPLE : VARIANT_SSH;
1303 }
1304
1305 - argv_array_push(&conn->args, ssh);
1305 + strvec_push(&conn->args, ssh);
1306 push_ssh_options(&conn->args, &conn->env_array, variant, port, version, flags);
1307 - argv_array_push(&conn->args, ssh_host);
1307 + strvec_push(&conn->args, ssh_host);
1308 }
1309
1310 /*
@@ -1365,7 +1365,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1365
1366 /* remove repo-local variables from the environment */
1367 for (var = local_repo_env; *var; var++)
1368 - argv_array_push(&conn->env_array, *var);
1368 + strvec_push(&conn->env_array, *var);
1369
1370 conn->use_shell = 1;
1371 conn->in = conn->out = -1;
@@ -1397,11 +1397,11 @@ struct child_process *git_connect(int fd[2], const char *url,
1397 transport_check_allowed("file");
1398 conn->trace2_child_class = "transport/file";
1399 if (version > 0) {
1400 - argv_array_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
1400 + strvec_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
1401 version);
1402 }
1403 }
1404 - argv_array_push(&conn->args, cmd.buf);
1404 + strvec_push(&conn->args, cmd.buf);
1405
1406 if (start_command(conn))
1407 die(_("unable to fork"));
connected.c
+11 -11
@@ -90,22 +90,22 @@ promisor_pack_found:
90
91 no_promisor_pack_found:
92 if (opt->shallow_file) {
93 - argv_array_push(&rev_list.args, "--shallow-file");
94 - argv_array_push(&rev_list.args, opt->shallow_file);
93 + strvec_push(&rev_list.args, "--shallow-file");
94 + strvec_push(&rev_list.args, opt->shallow_file);
95 }
96 - argv_array_push(&rev_list.args,"rev-list");
97 - argv_array_push(&rev_list.args, "--objects");
98 - argv_array_push(&rev_list.args, "--stdin");
96 + strvec_push(&rev_list.args,"rev-list");
97 + strvec_push(&rev_list.args, "--objects");
98 + strvec_push(&rev_list.args, "--stdin");
99 if (has_promisor_remote())
100 - argv_array_push(&rev_list.args, "--exclude-promisor-objects");
100 + strvec_push(&rev_list.args, "--exclude-promisor-objects");
101 if (!opt->is_deepening_fetch) {
102 - argv_array_push(&rev_list.args, "--not");
103 - argv_array_push(&rev_list.args, "--all");
102 + strvec_push(&rev_list.args, "--not");
103 + strvec_push(&rev_list.args, "--all");
104 }
105 - argv_array_push(&rev_list.args, "--quiet");
106 - argv_array_push(&rev_list.args, "--alternate-refs");
105 + strvec_push(&rev_list.args, "--quiet");
106 + strvec_push(&rev_list.args, "--alternate-refs");
107 if (opt->progress)
108 - argv_array_pushf(&rev_list.args, "--progress=%s",
108 + strvec_pushf(&rev_list.args, "--progress=%s",
109 _("Checking connectivity"));
110
111 rev_list.git_cmd = 1;
daemon.c
+26 -26
@@ -296,7 +296,7 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
296 return NULL; /* Fallthrough. Deny by default */
297 }
298
299 -typedef int (*daemon_service_fn)(const struct argv_array *env);
299 +typedef int (*daemon_service_fn)(const struct strvec *env);
300 struct daemon_service {
301 const char *name;
302 const char *config_name;
@@ -377,7 +377,7 @@ error_return:
377 }
378
379 static int run_service(const char *dir, struct daemon_service *service,
380 - struct hostinfo *hi, const struct argv_array *env)
380 + struct hostinfo *hi, const struct strvec *env)
381 {
382 const char *path;
383 int enabled = service->enabled;
@@ -462,7 +462,7 @@ static void copy_to_log(int fd)
462
463 static int run_service_command(struct child_process *cld)
464 {
465 - argv_array_push(&cld->args, ".");
465 + strvec_push(&cld->args, ".");
466 cld->git_cmd = 1;
467 cld->err = -1;
468 if (start_command(cld))
@@ -476,33 +476,33 @@ static int run_service_command(struct child_process *cld)
476 return finish_command(cld);
477 }
478
479 -static int upload_pack(const struct argv_array *env)
479 +static int upload_pack(const struct strvec *env)
480 {
481 struct child_process cld = CHILD_PROCESS_INIT;
482 - argv_array_pushl(&cld.args, "upload-pack", "--strict", NULL);
483 - argv_array_pushf(&cld.args, "--timeout=%u", timeout);
482 + strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
483 + strvec_pushf(&cld.args, "--timeout=%u", timeout);
484
485 - argv_array_pushv(&cld.env_array, env->argv);
485 + strvec_pushv(&cld.env_array, env->argv);
486
487 return run_service_command(&cld);
488 }
489
490 -static int upload_archive(const struct argv_array *env)
490 +static int upload_archive(const struct strvec *env)
491 {
492 struct child_process cld = CHILD_PROCESS_INIT;
493 - argv_array_push(&cld.args, "upload-archive");
493 + strvec_push(&cld.args, "upload-archive");
494
495 - argv_array_pushv(&cld.env_array, env->argv);
495 + strvec_pushv(&cld.env_array, env->argv);
496
497 return run_service_command(&cld);
498 }
499
500 -static int receive_pack(const struct argv_array *env)
500 +static int receive_pack(const struct strvec *env)
501 {
502 struct child_process cld = CHILD_PROCESS_INIT;
503 - argv_array_push(&cld.args, "receive-pack");
503 + strvec_push(&cld.args, "receive-pack");
504
505 - argv_array_pushv(&cld.env_array, env->argv);
505 + strvec_pushv(&cld.env_array, env->argv);
506
507 return run_service_command(&cld);
508 }
@@ -633,7 +633,7 @@ static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)
633 return extra_args;
634 }
635
636 -static void parse_extra_args(struct hostinfo *hi, struct argv_array *env,
636 +static void parse_extra_args(struct hostinfo *hi, struct strvec *env,
637 char *extra_args, int buflen)
638 {
639 const char *end = extra_args + buflen;
@@ -664,7 +664,7 @@ static void parse_extra_args(struct hostinfo *hi, struct argv_array *env,
664
665 if (git_protocol.len > 0) {
666 loginfo("Extended attribute \"protocol\": %s", git_protocol.buf);
667 - argv_array_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s",
667 + strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s",
668 git_protocol.buf);
669 }
670 strbuf_release(&git_protocol);
@@ -761,7 +761,7 @@ static int execute(void)
761 int pktlen, len, i;
762 char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT");
763 struct hostinfo hi;
764 - struct argv_array env = ARGV_ARRAY_INIT;
764 + struct strvec env = STRVEC_INIT;
765
766 hostinfo_init(&hi);
767
@@ -794,13 +794,13 @@ static int execute(void)
794 */
795 int rc = run_service(arg, s, &hi, &env);
796 hostinfo_clear(&hi);
797 - argv_array_clear(&env);
797 + strvec_clear(&env);
798 return rc;
799 }
800 }
801
802 hostinfo_clear(&hi);
803 - argv_array_clear(&env);
803 + strvec_clear(&env);
804 logerror("Protocol error: '%s'", line);
805 return -1;
806 }
@@ -893,7 +893,7 @@ static void check_dead_children(void)
893 cradle = &blanket->next;
894 }
895
896 -static struct argv_array cld_argv = ARGV_ARRAY_INIT;
896 +static struct strvec cld_argv = STRVEC_INIT;
897 static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
898 {
899 struct child_process cld = CHILD_PROCESS_INIT;
@@ -913,16 +913,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
913 char buf[128] = "";
914 struct sockaddr_in *sin_addr = (void *) addr;
915 inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf));
916 - argv_array_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf);
917 - argv_array_pushf(&cld.env_array, "REMOTE_PORT=%d",
916 + strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf);
917 + strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
918 ntohs(sin_addr->sin_port));
919 #ifndef NO_IPV6
920 } else if (addr->sa_family == AF_INET6) {
921 char buf[128] = "";
922 struct sockaddr_in6 *sin6_addr = (void *) addr;
923 inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf));
924 - argv_array_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf);
925 - argv_array_pushf(&cld.env_array, "REMOTE_PORT=%d",
924 + strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf);
925 + strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
926 ntohs(sin6_addr->sin6_port));
927 #endif
928 }
@@ -1476,10 +1476,10 @@ int cmd_main(int argc, const char **argv)
1476 write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid());
1477
1478 /* prepare argv for serving-processes */
1479 - argv_array_push(&cld_argv, argv[0]); /* git-daemon */
1480 - argv_array_push(&cld_argv, "--serve");
1479 + strvec_push(&cld_argv, argv[0]); /* git-daemon */
1480 + strvec_push(&cld_argv, "--serve");
1481 for (i = 1; i < argc; ++i)
1482 - argv_array_push(&cld_argv, argv[i]);
1482 + strvec_push(&cld_argv, argv[i]);
1483
1484 return serve(&listen_addr, listen_port, cred);
1485 }
diff.c
+14 -14
@@ -4192,14 +4192,14 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
4192 }
4193
4194 static void add_external_diff_name(struct repository *r,
4195 - struct argv_array *argv,
4195 + struct strvec *argv,
4196 const char *name,
4197 struct diff_filespec *df)
4198 {
4199 struct diff_tempfile *temp = prepare_temp_file(r, name, df);
4200 - argv_array_push(argv, temp->name);
4201 - argv_array_push(argv, temp->hex);
4202 - argv_array_push(argv, temp->mode);
4200 + strvec_push(argv, temp->name);
4201 + strvec_push(argv, temp->hex);
4202 + strvec_push(argv, temp->mode);
4203 }
4204
4205 /* An external diff command takes:
@@ -4216,12 +4216,12 @@ static void run_external_diff(const char *pgm,
4216 const char *xfrm_msg,
4217 struct diff_options *o)
4218 {
4219 - struct argv_array argv = ARGV_ARRAY_INIT;
4220 - struct argv_array env = ARGV_ARRAY_INIT;
4219 + struct strvec argv = STRVEC_INIT;
4220 + struct strvec env = STRVEC_INIT;
4221 struct diff_queue_struct *q = &diff_queued_diff;
4222
4223 - argv_array_push(&argv, pgm);
4224 - argv_array_push(&argv, name);
4223 + strvec_push(&argv, pgm);
4224 + strvec_push(&argv, name);
4225
4226 if (one && two) {
4227 add_external_diff_name(o->repo, &argv, name, one);
@@ -4229,13 +4229,13 @@ static void run_external_diff(const char *pgm,
4229 add_external_diff_name(o->repo, &argv, name, two);
4230 else {
4231 add_external_diff_name(o->repo, &argv, other, two);
4232 - argv_array_push(&argv, other);
4233 - argv_array_push(&argv, xfrm_msg);
4232 + strvec_push(&argv, other);
4233 + strvec_push(&argv, xfrm_msg);
4234 }
4235 }
4236
4237 - argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
4238 - argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
4237 + strvec_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
4238 + strvec_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
4239
4240 diff_free_filespec_data(one);
4241 diff_free_filespec_data(two);
@@ -4243,8 +4243,8 @@ static void run_external_diff(const char *pgm,
4243 die(_("external diff died, stopping at %s"), name);
4244
4245 remove_tempfile();
4246 - argv_array_clear(&argv);
4247 - argv_array_clear(&env);
4246 + strvec_clear(&argv);
4247 + strvec_clear(&env);
4248 }
4249
4250 static int similarity_index(struct diff_filepair *p)
environment.c
+4 -4
@@ -156,14 +156,14 @@ static char *expand_namespace(const char *raw_namespace)
156 * Wrapper of getenv() that returns a strdup value. This value is kept
157 * in argv to be freed later.
158 */
159 -static const char *getenv_safe(struct argv_array *argv, const char *name)
159 +static const char *getenv_safe(struct strvec *argv, const char *name)
160 {
161 const char *value = getenv(name);
162
163 if (!value)
164 return NULL;
165
166 - argv_array_push(argv, value);
166 + strvec_push(argv, value);
167 return argv->argv[argv->argc - 1];
168 }
169
@@ -172,7 +172,7 @@ void setup_git_env(const char *git_dir)
172 const char *shallow_file;
173 const char *replace_ref_base;
174 struct set_gitdir_args args = { NULL };
175 - struct argv_array to_free = ARGV_ARRAY_INIT;
175 + struct strvec to_free = STRVEC_INIT;
176
177 args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT);
178 args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
@@ -180,7 +180,7 @@ void setup_git_env(const char *git_dir)
180 args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
181 args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
182 repo_set_gitdir(the_repository, git_dir, &args);
183 - argv_array_clear(&to_free);
183 + strvec_clear(&to_free);
184
185 if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
186 read_replace_refs = 0;
exec-cmd.c
+5 -5
@@ -320,16 +320,16 @@ void setup_path(void)
320 strbuf_release(&new_path);
321 }
322
323 -const char **prepare_git_cmd(struct argv_array *out, const char **argv)
323 +const char **prepare_git_cmd(struct strvec *out, const char **argv)
324 {
325 - argv_array_push(out, "git");
326 - argv_array_pushv(out, argv);
325 + strvec_push(out, "git");
326 + strvec_pushv(out, argv);
327 return out->argv;
328 }
329
330 int execv_git_cmd(const char **argv)
331 {
332 - struct argv_array nargv = ARGV_ARRAY_INIT;
332 + struct strvec nargv = STRVEC_INIT;
333
334 prepare_git_cmd(&nargv, argv);
335 trace_argv_printf(nargv.argv, "trace: exec:");
@@ -339,7 +339,7 @@ int execv_git_cmd(const char **argv)
339
340 trace_printf("trace: exec failed: %s\n", strerror(errno));
341
342 - argv_array_clear(&nargv);
342 + strvec_clear(&nargv);
343 return -1;
344 }
345
fast-import.c
+2 -2
@@ -843,9 +843,9 @@ static int loosen_small_pack(const struct packed_git *p)
843 unpack.in = p->pack_fd;
844 unpack.git_cmd = 1;
845 unpack.stdout_to_stderr = 1;
846 - argv_array_push(&unpack.args, "unpack-objects");
846 + strvec_push(&unpack.args, "unpack-objects");
847 if (!show_stats)
848 - argv_array_push(&unpack.args, "-q");
848 + strvec_push(&unpack.args, "-q");
849
850 return run_command(&unpack);
851 }
fetch-pack.c
+17 -17
@@ -835,30 +835,30 @@ static int get_pack(struct fetch_pack_args *args,
835 }
836
837 if (alternate_shallow_file) {
838 - argv_array_push(&cmd.args, "--shallow-file");
839 - argv_array_push(&cmd.args, alternate_shallow_file);
838 + strvec_push(&cmd.args, "--shallow-file");
839 + strvec_push(&cmd.args, alternate_shallow_file);
840 }
841
842 if (do_keep || args->from_promisor) {
843 if (pack_lockfiles)
844 cmd.out = -1;
845 cmd_name = "index-pack";
846 - argv_array_push(&cmd.args, cmd_name);
847 - argv_array_push(&cmd.args, "--stdin");
846 + strvec_push(&cmd.args, cmd_name);
847 + strvec_push(&cmd.args, "--stdin");
848 if (!args->quiet && !args->no_progress)
849 - argv_array_push(&cmd.args, "-v");
849 + strvec_push(&cmd.args, "-v");
850 if (args->use_thin_pack)
851 - argv_array_push(&cmd.args, "--fix-thin");
851 + strvec_push(&cmd.args, "--fix-thin");
852 if (do_keep && (args->lock_pack || unpack_limit)) {
853 char hostname[HOST_NAME_MAX + 1];
854 if (xgethostname(hostname, sizeof(hostname)))
855 xsnprintf(hostname, sizeof(hostname), "localhost");
856 - argv_array_pushf(&cmd.args,
856 + strvec_pushf(&cmd.args,
857 "--keep=fetch-pack %"PRIuMAX " on %s",
858 (uintmax_t)getpid(), hostname);
859 }
860 if (only_packfile && args->check_self_contained_and_connected)
861 - argv_array_push(&cmd.args, "--check-self-contained-and-connected");
861 + strvec_push(&cmd.args, "--check-self-contained-and-connected");
862 else
863 /*
864 * We cannot perform any connectivity checks because
@@ -873,18 +873,18 @@ static int get_pack(struct fetch_pack_args *args,
873 * us.
874 */
875 if (!(do_keep && pack_lockfiles) && args->from_promisor)
876 - argv_array_push(&cmd.args, "--promisor");
876 + strvec_push(&cmd.args, "--promisor");
877 }
878 else {
879 cmd_name = "unpack-objects";
880 - argv_array_push(&cmd.args, cmd_name);
880 + strvec_push(&cmd.args, cmd_name);
881 if (args->quiet || args->no_progress)
882 - argv_array_push(&cmd.args, "-q");
882 + strvec_push(&cmd.args, "-q");
883 args->check_self_contained_and_connected = 0;
884 }
885
886 if (pass_header)
887 - argv_array_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32,
887 + strvec_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32,
888 ntohl(header.hdr_version),
889 ntohl(header.hdr_entries));
890 if (fetch_fsck_objects >= 0
@@ -898,9 +898,9 @@ static int get_pack(struct fetch_pack_args *args,
898 * checks both broken objects and links, but we only
899 * want to check for broken objects.
900 */
901 - argv_array_push(&cmd.args, "--fsck-objects");
901 + strvec_push(&cmd.args, "--fsck-objects");
902 else
903 - argv_array_pushf(&cmd.args, "--strict%s",
903 + strvec_pushf(&cmd.args, "--strict%s",
904 fsck_msg_types.buf);
905 }
906
@@ -1652,11 +1652,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1652 const char *uri = packfile_uris.items[i].string +
1653 the_hash_algo->hexsz + 1;
1654
1655 - argv_array_push(&cmd.args, "http-fetch");
1656 - argv_array_pushf(&cmd.args, "--packfile=%.*s",
1655 + strvec_push(&cmd.args, "http-fetch");
1656 + strvec_pushf(&cmd.args, "--packfile=%.*s",
1657 (int) the_hash_algo->hexsz,
1658 packfile_uris.items[i].string);
1659 - argv_array_push(&cmd.args, uri);
1659 + strvec_push(&cmd.args, uri);
1660 cmd.git_cmd = 1;
1661 cmd.no_stdin = 1;
1662 cmd.out = -1;
fsmonitor.c
+3 -3
@@ -146,9 +146,9 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf *
146 if (!core_fsmonitor)
147 return -1;
148
149 - argv_array_push(&cp.args, core_fsmonitor);
150 - argv_array_pushf(&cp.args, "%d", version);
151 - argv_array_pushf(&cp.args, "%s", last_update);
149 + strvec_push(&cp.args, core_fsmonitor);
150 + strvec_pushf(&cp.args, "%d", version);
151 + strvec_pushf(&cp.args, "%s", last_update);
152 cp.use_shell = 1;
153 cp.dir = get_git_work_tree();
154
git.c
+11 -11
@@ -349,8 +349,8 @@ static int handle_alias(int *argcp, const char ***argv)
349 child.clean_on_exit = 1;
350 child.wait_after_clean = 1;
351 child.trace2_child_class = "shell_alias";
352 - argv_array_push(&child.args, alias_string + 1);
353 - argv_array_pushv(&child.args, (*argv) + 1);
352 + strvec_push(&child.args, alias_string + 1);
353 + strvec_pushv(&child.args, (*argv) + 1);
354
355 trace2_cmd_alias(alias_command, child.args.argv);
356 trace2_cmd_list_config();
@@ -646,7 +646,7 @@ static void strip_extension(const char **argv)
646
647 static void handle_builtin(int argc, const char **argv)
648 {
649 - struct argv_array args = ARGV_ARRAY_INIT;
649 + struct strvec args = STRVEC_INIT;
650 const char *cmd;
651 struct cmd_struct *builtin;
652
@@ -661,9 +661,9 @@ static void handle_builtin(int argc, const char **argv)
661 argv[0] = cmd = "help";
662
663 for (i = 0; i < argc; i++) {
664 - argv_array_push(&args, argv[i]);
664 + strvec_push(&args, argv[i]);
665 if (!i)
666 - argv_array_push(&args, "--exclude-guides");
666 + strvec_push(&args, "--exclude-guides");
667 }
668
669 argc++;
@@ -673,7 +673,7 @@ static void handle_builtin(int argc, const char **argv)
673 builtin = get_builtin(cmd);
674 if (builtin)
675 exit(run_builtin(builtin, argc, argv));
676 - argv_array_clear(&args);
676 + strvec_clear(&args);
677 }
678
679 static void execv_dashed_external(const char **argv)
@@ -688,8 +688,8 @@ static void execv_dashed_external(const char **argv)
688 use_pager = check_pager_config(argv[0]);
689 commit_pager_choice();
690
691 - argv_array_pushf(&cmd.args, "git-%s", argv[0]);
692 - argv_array_pushv(&cmd.args, argv + 1);
691 + strvec_pushf(&cmd.args, "git-%s", argv[0]);
692 + strvec_pushv(&cmd.args, argv + 1);
693 cmd.clean_on_exit = 1;
694 cmd.wait_after_clean = 1;
695 cmd.silent_exec_failure = 1;
@@ -741,7 +741,7 @@ static int run_argv(int *argcp, const char ***argv)
741 if (!done_alias)
742 handle_builtin(*argcp, *argv);
743 else if (get_builtin(**argv)) {
744 - struct argv_array args = ARGV_ARRAY_INIT;
744 + struct strvec args = STRVEC_INIT;
745 int i;
746
747 /*
@@ -758,9 +758,9 @@ static int run_argv(int *argcp, const char ***argv)
758
759 commit_pager_choice();
760
761 - argv_array_push(&args, "git");
761 + strvec_push(&args, "git");
762 for (i = 0; i < *argcp; i++)
763 - argv_array_push(&args, (*argv)[i]);
763 + strvec_push(&args, (*argv)[i]);
764
765 trace_argv_printf(args.argv, "trace: exec:");
766
gpg-interface.c
+4 -4
@@ -282,9 +282,9 @@ static int verify_signed_buffer(const char *payload, size_t payload_size,
282 if (!fmt)
283 BUG("bad signature '%s'", signature);
284
285 - argv_array_push(&gpg.args, fmt->program);
286 - argv_array_pushv(&gpg.args, fmt->verify_args);
287 - argv_array_pushl(&gpg.args,
285 + strvec_push(&gpg.args, fmt->program);
286 + strvec_pushv(&gpg.args, fmt->verify_args);
287 + strvec_pushl(&gpg.args,
288 "--status-fd=1",
289 "--verify", temp->filename.buf, "-",
290 NULL);
@@ -434,7 +434,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
434 size_t i, j, bottom;
435 struct strbuf gpg_status = STRBUF_INIT;
436
437 - argv_array_pushl(&gpg.args,
437 + strvec_pushl(&gpg.args,
438 use_format->program,
439 "--status-fd=2",
440 "-bsau", signing_key,
graph.c
+5 -5
@@ -82,7 +82,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt)
82 static const char **column_colors;
83 static unsigned short column_colors_max;
84
85 -static void parse_graph_colors_config(struct argv_array *colors, const char *string)
85 +static void parse_graph_colors_config(struct strvec *colors, const char *string)
86 {
87 const char *end, *start;
88
@@ -93,13 +93,13 @@ static void parse_graph_colors_config(struct argv_array *colors, const char *str
93 char color[COLOR_MAXLEN];
94
95 if (!color_parse_mem(start, comma - start, color))
96 - argv_array_push(colors, color);
96 + strvec_push(colors, color);
97 else
98 warning(_("ignore invalid color '%.*s' in log.graphColors"),
99 (int)(comma - start), start);
100 start = comma + 1;
101 }
102 - argv_array_push(colors, GIT_COLOR_RESET);
102 + strvec_push(colors, GIT_COLOR_RESET);
103 }
104
105 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)
350 graph_set_column_colors(column_colors_ansi,
351 column_colors_ansi_max);
352 } else {
353 - static struct argv_array custom_colors = ARGV_ARRAY_INIT;
354 - argv_array_clear(&custom_colors);
353 + static struct strvec custom_colors = STRVEC_INIT;
354 + strvec_clear(&custom_colors);
355 parse_graph_colors_config(&custom_colors, string);
356 free(string);
357 /* graph_set_column_colors takes a max-index, not a count */
http-backend.c
+2 -2
@@ -477,9 +477,9 @@ static void run_service(const char **argv, int buffer_input)
477 host = "(none)";
478
479 if (!getenv("GIT_COMMITTER_NAME"))
480 - argv_array_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
480 + strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
481 if (!getenv("GIT_COMMITTER_EMAIL"))
482 - argv_array_pushf(&cld.env_array,
482 + strvec_pushf(&cld.env_array,
483 "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
484
485 cld.argv = argv;
http-push.c
+6 -6
@@ -1846,7 +1846,7 @@ int cmd_main(int argc, const char **argv)
1846
1847 new_refs = 0;
1848 for (ref = remote_refs; ref; ref = ref->next) {
1849 - struct argv_array commit_argv = ARGV_ARRAY_INIT;
1849 + struct strvec commit_argv = STRVEC_INIT;
1850
1851 if (!ref->peer_ref)
1852 continue;
@@ -1924,11 +1924,11 @@ int cmd_main(int argc, const char **argv)
1924 }
1925
1926 /* Set up revision info for this refspec */
1927 - argv_array_push(&commit_argv, ""); /* ignored */
1928 - argv_array_push(&commit_argv, "--objects");
1929 - argv_array_push(&commit_argv, oid_to_hex(&ref->new_oid));
1927 + strvec_push(&commit_argv, ""); /* ignored */
1928 + strvec_push(&commit_argv, "--objects");
1929 + strvec_push(&commit_argv, oid_to_hex(&ref->new_oid));
1930 if (!push_all && !is_null_oid(&ref->old_oid))
1931 - argv_array_pushf(&commit_argv, "^%s",
1931 + strvec_pushf(&commit_argv, "^%s",
1932 oid_to_hex(&ref->old_oid));
1933 repo_init_revisions(the_repository, &revs, setup_git_directory());
1934 setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
@@ -1961,7 +1961,7 @@ int cmd_main(int argc, const char **argv)
1961 printf("%s %s\n", !rc ? "ok" : "error", ref->name);
1962 unlock_remote(ref_lock);
1963 check_locks();
1964 - argv_array_clear(&commit_argv);
1964 + strvec_clear(&commit_argv);
1965 }
1966
1967 /* Update remote server info if appropriate */
http.c
+3 -3
@@ -2270,12 +2270,12 @@ int finish_http_pack_request(struct http_pack_request *preq)
2270
2271 tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY);
2272
2273 - argv_array_push(&ip.args, "index-pack");
2274 - argv_array_push(&ip.args, "--stdin");
2273 + strvec_push(&ip.args, "index-pack");
2274 + strvec_push(&ip.args, "--stdin");
2275 ip.git_cmd = 1;
2276 ip.in = tmpfile_fd;
2277 if (preq->generate_keep) {
2278 - argv_array_pushf(&ip.args, "--keep=git %"PRIuMAX,
2278 + strvec_pushf(&ip.args, "--keep=git %"PRIuMAX,
2279 (uintmax_t)getpid());
2280 ip.out = 0;
2281 } else {
imap-send.c
+1 -1
@@ -976,7 +976,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
976
977 imap_info("Starting tunnel '%s'... ", srvc->tunnel);
978
979 - argv_array_push(&tunnel.args, srvc->tunnel);
979 + strvec_push(&tunnel.args, srvc->tunnel);
980 tunnel.use_shell = 1;
981 tunnel.in = -1;
982 tunnel.out = -1;
line-log.c
+3 -3
@@ -758,12 +758,12 @@ static void parse_pathspec_from_ranges(struct pathspec *pathspec,
758 struct line_log_data *range)
759 {
760 struct line_log_data *r;
761 - struct argv_array array = ARGV_ARRAY_INIT;
761 + struct strvec array = STRVEC_INIT;
762 const char **paths;
763
764 for (r = range; r; r = r->next)
765 - argv_array_push(&array, r->path);
766 - paths = argv_array_detach(&array);
765 + strvec_push(&array, r->path);
766 + paths = strvec_detach(&array);
767
768 parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL, "", paths);
769 /* strings are now owned by pathspec */
ls-refs.c
+5 -5
@@ -11,7 +11,7 @@
11 * Check if one of the prefixes is a prefix of the ref.
12 * If no prefixes were provided, all refs match.
13 */
14 -static int ref_match(const struct argv_array *prefixes, const char *refname)
14 +static int ref_match(const struct strvec *prefixes, const char *refname)
15 {
16 int i;
17
@@ -31,7 +31,7 @@ static int ref_match(const struct argv_array *prefixes, const char *refname)
31 struct ls_refs_data {
32 unsigned peel;
33 unsigned symrefs;
34 - struct argv_array prefixes;
34 + struct strvec prefixes;
35 };
36
37 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)
84 return parse_hide_refs_config(var, value, "uploadpack");
85 }
86
87 -int ls_refs(struct repository *r, struct argv_array *keys,
87 +int ls_refs(struct repository *r, struct strvec *keys,
88 struct packet_reader *request)
89 {
90 struct ls_refs_data data;
@@ -102,7 +102,7 @@ int ls_refs(struct repository *r, struct argv_array *keys,
102 else if (!strcmp("symrefs", arg))
103 data.symrefs = 1;
104 else if (skip_prefix(arg, "ref-prefix ", &out))
105 - argv_array_push(&data.prefixes, out);
105 + strvec_push(&data.prefixes, out);
106 }
107
108 if (request->status != PACKET_READ_FLUSH)
@@ -111,6 +111,6 @@ int ls_refs(struct repository *r, struct argv_array *keys,
111 head_ref_namespaced(send_ref, &data);
112 for_each_namespaced_ref(send_ref, &data);
113 packet_flush(1);
114 - argv_array_clear(&data.prefixes);
114 + strvec_clear(&data.prefixes);
115 return 0;
116 }