Skip to content

Commit c972bf4

Browse files
peffgitster
authored andcommitted
strvec: convert remaining callers away from argv_array name
We eventually want to drop the argv_array name and just use strvec consistently. There's no particular reason we have to do it all at once, or care about interactions between converted and unconverted bits. Because of our preprocessor compat layer, the names are interchangeable to the compiler (so even a definition and declaration using different names is OK). This patch converts all of the remaining files, as the resulting diff is reasonably sized. The conversion was done purely mechanically with: git ls-files '*.c' '*.h' | xargs perl -i -pe ' s/ARGV_ARRAY/STRVEC/g; s/argv_array/strvec/g; ' We'll deal with any indentation/style fallouts separately. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef8d7ac commit c972bf4

33 files changed

+385
-385
lines changed

merge.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ int try_merge_command(struct repository *r,
1919
const char **xopts, struct commit_list *common,
2020
const char *head_arg, struct commit_list *remotes)
2121
{
22-
struct argv_array args = ARGV_ARRAY_INIT;
22+
struct strvec args = STRVEC_INIT;
2323
int i, ret;
2424
struct commit_list *j;
2525

26-
argv_array_pushf(&args, "merge-%s", strategy);
26+
strvec_pushf(&args, "merge-%s", strategy);
2727
for (i = 0; i < xopts_nr; i++)
28-
argv_array_pushf(&args, "--%s", xopts[i]);
28+
strvec_pushf(&args, "--%s", xopts[i]);
2929
for (j = common; j; j = j->next)
30-
argv_array_push(&args, merge_argument(j->item));
31-
argv_array_push(&args, "--");
32-
argv_array_push(&args, head_arg);
30+
strvec_push(&args, merge_argument(j->item));
31+
strvec_push(&args, "--");
32+
strvec_push(&args, head_arg);
3333
for (j = remotes; j; j = j->next)
34-
argv_array_push(&args, merge_argument(j->item));
34+
strvec_push(&args, merge_argument(j->item));
3535

3636
ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
37-
argv_array_clear(&args);
37+
strvec_clear(&args);
3838

3939
discard_index(r->index);
4040
if (repo_read_index(r) < 0)

midx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,21 +1408,21 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
14081408
repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
14091409
repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
14101410

1411-
argv_array_push(&cmd.args, "pack-objects");
1411+
strvec_push(&cmd.args, "pack-objects");
14121412

14131413
strbuf_addstr(&base_name, object_dir);
14141414
strbuf_addstr(&base_name, "/pack/pack");
1415-
argv_array_push(&cmd.args, base_name.buf);
1415+
strvec_push(&cmd.args, base_name.buf);
14161416

14171417
if (delta_base_offset)
1418-
argv_array_push(&cmd.args, "--delta-base-offset");
1418+
strvec_push(&cmd.args, "--delta-base-offset");
14191419
if (use_delta_islands)
1420-
argv_array_push(&cmd.args, "--delta-islands");
1420+
strvec_push(&cmd.args, "--delta-islands");
14211421

14221422
if (flags & MIDX_PROGRESS)
1423-
argv_array_push(&cmd.args, "--progress");
1423+
strvec_push(&cmd.args, "--progress");
14241424
else
1425-
argv_array_push(&cmd.args, "-q");
1425+
strvec_push(&cmd.args, "-q");
14261426

14271427
strbuf_release(&base_name);
14281428

pager.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const char *git_pager(int stdout_is_tty)
6868
return pager;
6969
}
7070

71-
static void setup_pager_env(struct argv_array *env)
71+
static void setup_pager_env(struct strvec *env)
7272
{
7373
const char **argv;
7474
int i;
@@ -88,7 +88,7 @@ static void setup_pager_env(struct argv_array *env)
8888
*cp = '\0';
8989
if (!getenv(argv[i])) {
9090
*cp = '=';
91-
argv_array_push(env, argv[i]);
91+
strvec_push(env, argv[i]);
9292
}
9393
}
9494
free(pager_env);
@@ -97,7 +97,7 @@ static void setup_pager_env(struct argv_array *env)
9797

9898
void prepare_pager_args(struct child_process *pager_process, const char *pager)
9999
{
100-
argv_array_push(&pager_process->args, pager);
100+
strvec_push(&pager_process->args, pager);
101101
pager_process->use_shell = 1;
102102
setup_pager_env(&pager_process->env_array);
103103
pager_process->trace2_child_class = "pager";
@@ -126,7 +126,7 @@ void setup_pager(void)
126126
/* spawn the pager */
127127
prepare_pager_args(&pager_process, pager);
128128
pager_process.in = -1;
129-
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
129+
strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
130130
if (start_command(&pager_process))
131131
return;
132132

parse-options-cb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,19 @@ int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
275275

276276
/**
277277
* For an option opt, recreate the command-line option, appending it to
278-
* opt->value which must be a argv_array. This is useful when we need to pass
278+
* opt->value which must be a strvec. This is useful when we need to pass
279279
* the command-line option, which can be specified multiple times, to another
280280
* command.
281281
*/
282282
int parse_opt_passthru_argv(const struct option *opt, const char *arg, int unset)
283283
{
284284
static struct strbuf sb = STRBUF_INIT;
285-
struct argv_array *opt_value = opt->value;
285+
struct strvec *opt_value = opt->value;
286286

287287
if (recreate_opt(&sb, opt, arg, unset) < 0)
288288
return -1;
289289

290-
argv_array_push(opt_value, sb.buf);
290+
strvec_push(opt_value, sb.buf);
291291

292292
return 0;
293293
}

pathspec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
624624
unsigned flags, const char *prefix,
625625
const char *file, int nul_term_line)
626626
{
627-
struct argv_array parsed_file = ARGV_ARRAY_INIT;
627+
struct strvec parsed_file = STRVEC_INIT;
628628
strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul :
629629
strbuf_getline;
630630
struct strbuf buf = STRBUF_INIT;
@@ -643,7 +643,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
643643
die(_("line is badly quoted: %s"), buf.buf);
644644
strbuf_swap(&buf, &unquoted);
645645
}
646-
argv_array_push(&parsed_file, buf.buf);
646+
strvec_push(&parsed_file, buf.buf);
647647
strbuf_reset(&buf);
648648
}
649649

@@ -653,7 +653,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
653653
fclose(in);
654654

655655
parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
656-
argv_array_clear(&parsed_file);
656+
strvec_clear(&parsed_file);
657657
}
658658

659659
void copy_pathspec(struct pathspec *dst, const struct pathspec *src)

quote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ char *sq_dequote(char *arg)
172172

173173
static int sq_dequote_to_argv_internal(char *arg,
174174
const char ***argv, int *nr, int *alloc,
175-
struct argv_array *array)
175+
struct strvec *array)
176176
{
177177
char *next = arg;
178178

@@ -187,7 +187,7 @@ static int sq_dequote_to_argv_internal(char *arg,
187187
(*argv)[(*nr)++] = dequoted;
188188
}
189189
if (array)
190-
argv_array_push(array, dequoted);
190+
strvec_push(array, dequoted);
191191
} while (next);
192192

193193
return 0;

range-diff.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
4141
* as struct object_id (will need to be free()d).
4242
*/
4343
static int read_patches(const char *range, struct string_list *list,
44-
const struct argv_array *other_arg)
44+
const struct strvec *other_arg)
4545
{
4646
struct child_process cp = CHILD_PROCESS_INIT;
4747
struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -51,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
5151
int offset, len;
5252
size_t size;
5353

54-
argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
54+
strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
5555
"--reverse", "--date-order", "--decorate=no",
5656
"--no-prefix",
5757
/*
@@ -67,8 +67,8 @@ static int read_patches(const char *range, struct string_list *list,
6767
"--notes",
6868
NULL);
6969
if (other_arg)
70-
argv_array_pushv(&cp.args, other_arg->argv);
71-
argv_array_push(&cp.args, range);
70+
strvec_pushv(&cp.args, other_arg->argv);
71+
strvec_push(&cp.args, range);
7272
cp.out = -1;
7373
cp.no_stdin = 1;
7474
cp.git_cmd = 1;
@@ -523,7 +523,7 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
523523
int show_range_diff(const char *range1, const char *range2,
524524
int creation_factor, int dual_color,
525525
const struct diff_options *diffopt,
526-
const struct argv_array *other_arg)
526+
const struct strvec *other_arg)
527527
{
528528
int res = 0;
529529

range-diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
int show_range_diff(const char *range1, const char *range2,
1515
int creation_factor, int dual_color,
1616
const struct diff_options *diffopt,
17-
const struct argv_array *other_arg);
17+
const struct strvec *other_arg);
1818

1919
#endif

ref-filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,15 +1914,15 @@ static void find_longest_prefixes_1(struct string_list *out,
19141914
static void find_longest_prefixes(struct string_list *out,
19151915
const char **patterns)
19161916
{
1917-
struct argv_array sorted = ARGV_ARRAY_INIT;
1917+
struct strvec sorted = STRVEC_INIT;
19181918
struct strbuf prefix = STRBUF_INIT;
19191919

1920-
argv_array_pushv(&sorted, patterns);
1920+
strvec_pushv(&sorted, patterns);
19211921
QSORT(sorted.argv, sorted.argc, qsort_strcmp);
19221922

19231923
find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
19241924

1925-
argv_array_clear(&sorted);
1925+
strvec_clear(&sorted);
19261926
strbuf_release(&prefix);
19271927
}
19281928

refs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ int refname_match(const char *abbrev_name, const char *full_name)
553553
* Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
554554
* the results to 'prefixes'
555555
*/
556-
void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
556+
void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
557557
{
558558
const char **p;
559559
int len = strlen(prefix);
560560

561561
for (p = ref_rev_parse_rules; *p; p++)
562-
argv_array_pushf(prefixes, *p, len, prefix);
562+
strvec_pushf(prefixes, *p, len, prefix);
563563
}
564564

565565
char *repo_default_branch_name(struct repository *r)
@@ -2037,7 +2037,7 @@ static int run_transaction_hook(struct ref_transaction *transaction,
20372037
return ret;
20382038
}
20392039

2040-
argv_array_pushl(&proc.args, hook, state, NULL);
2040+
strvec_pushl(&proc.args, hook, state, NULL);
20412041
proc.in = -1;
20422042
proc.stdout_to_stderr = 1;
20432043
proc.trace2_hook_name = "reference-transaction";

0 commit comments

Comments
 (0)