fetch: pass through `fetch_config` directly
The `fetch_config` structure currently only has a single member, which is the `display_format`. We're about extend it to contain all parsed config values and will thus need it available in most of the code. Prepare for this change by passing through the `fetch_config` directly instead of only passing its single member. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 17, 2023 at 13:48 UTC
d1adf85b0a21ea6575b145959c53e7d5e4a0cba4
1 file changed
+16
-15
builtin/fetch.c
+16
-15
@@ -1553,7 +1553,7 @@ static int backfill_tags(struct display_state *display_state,
1553
1554
static int do_fetch(struct transport *transport,
1555
struct refspec *rs,
1556
- enum display_format display_format)
1556
+ const struct fetch_config *config)
1557
{
1558
struct ref_transaction *transaction = NULL;
1559
struct ref *ref_map = NULL;
@@ -1639,7 +1639,8 @@ static int do_fetch(struct transport *transport,
1639
if (retcode)
1640
goto cleanup;
1641
1642
- display_state_init(&display_state, ref_map, transport->url, display_format);
1642
+ display_state_init(&display_state, ref_map, transport->url,
1643
+ config->display_format);
1644
1645
if (atomic_fetch) {
1646
transaction = ref_transaction_begin(&err);
@@ -1828,7 +1829,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
1829
}
1830
1831
static void add_options_to_argv(struct strvec *argv,
1831
- enum display_format format)
1832
+ const struct fetch_config *config)
1833
{
1834
if (dry_run)
1835
strvec_push(argv, "--dry-run");
@@ -1864,7 +1865,7 @@ static void add_options_to_argv(struct strvec *argv,
1865
strvec_push(argv, "--ipv6");
1866
if (!write_fetch_head)
1867
strvec_push(argv, "--no-write-fetch-head");
1867
- if (format == DISPLAY_FORMAT_PORCELAIN)
1868
+ if (config->display_format == DISPLAY_FORMAT_PORCELAIN)
1869
strvec_pushf(argv, "--porcelain");
1870
}
1871
@@ -1874,7 +1875,7 @@ struct parallel_fetch_state {
1875
const char **argv;
1876
struct string_list *remotes;
1877
int next, result;
1877
- enum display_format format;
1878
+ const struct fetch_config *config;
1879
};
1880
1881
static int fetch_next_remote(struct child_process *cp,
@@ -1894,7 +1895,7 @@ static int fetch_next_remote(struct child_process *cp,
1895
strvec_push(&cp->args, remote);
1896
cp->git_cmd = 1;
1897
1897
- if (verbosity >= 0 && state->format != DISPLAY_FORMAT_PORCELAIN)
1898
+ if (verbosity >= 0 && state->config->display_format != DISPLAY_FORMAT_PORCELAIN)
1899
printf(_("Fetching %s\n"), remote);
1900
1901
return 1;
@@ -1927,7 +1928,7 @@ static int fetch_finished(int result, struct strbuf *out,
1928
}
1929
1930
static int fetch_multiple(struct string_list *list, int max_children,
1930
- enum display_format format)
1931
+ const struct fetch_config *config)
1932
{
1933
int i, result = 0;
1934
struct strvec argv = STRVEC_INIT;
@@ -1945,10 +1946,10 @@ static int fetch_multiple(struct string_list *list, int max_children,
1946
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
1947
"fetch", "--append", "--no-auto-gc",
1948
"--no-write-commit-graph", NULL);
1948
- add_options_to_argv(&argv, format);
1949
+ add_options_to_argv(&argv, config);
1950
1951
if (max_children != 1 && list->nr != 1) {
1951
- struct parallel_fetch_state state = { argv.v, list, 0, 0, format };
1952
+ struct parallel_fetch_state state = { argv.v, list, 0, 0, config };
1953
const struct run_process_parallel_opts opts = {
1954
.tr2_category = "fetch",
1955
.tr2_label = "parallel/fetch",
@@ -1972,7 +1973,7 @@ static int fetch_multiple(struct string_list *list, int max_children,
1973
1974
strvec_pushv(&cmd.args, argv.v);
1975
strvec_push(&cmd.args, name);
1975
- if (verbosity >= 0 && format != DISPLAY_FORMAT_PORCELAIN)
1976
+ if (verbosity >= 0 && config->display_format != DISPLAY_FORMAT_PORCELAIN)
1977
printf(_("Fetching %s\n"), name);
1978
cmd.git_cmd = 1;
1979
if (run_command(&cmd)) {
@@ -2028,7 +2029,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
2029
2030
static int fetch_one(struct remote *remote, int argc, const char **argv,
2031
int prune_tags_ok, int use_stdin_refspecs,
2031
- enum display_format display_format)
2032
+ const struct fetch_config *config)
2033
{
2034
struct refspec rs = REFSPEC_INIT_FETCH;
2035
int i;
@@ -2095,7 +2096,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
2096
sigchain_push_common(unlock_pack_on_signal);
2097
atexit(unlock_pack_atexit);
2098
sigchain_push(SIGPIPE, SIG_IGN);
2098
- exit_code = do_fetch(gtransport, &rs, display_format);
2099
+ exit_code = do_fetch(gtransport, &rs, config);
2100
sigchain_pop(SIGPIPE);
2101
refspec_clear(&rs);
2102
transport_disconnect(gtransport);
@@ -2383,7 +2384,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2384
if (filter_options.choice || repo_has_promisor_remote(the_repository))
2385
fetch_one_setup_partial(remote);
2386
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
2386
- config.display_format);
2387
+ &config);
2388
} else {
2389
int max_children = max_jobs;
2390
@@ -2403,7 +2404,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2404
max_children = fetch_parallel_config;
2405
2406
/* TODO should this also die if we have a previous partial-clone? */
2406
- result = fetch_multiple(&list, max_children, config.display_format);
2407
+ result = fetch_multiple(&list, max_children, &config);
2408
}
2409
2410
/*
@@ -2424,7 +2425,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2425
if (max_children < 0)
2426
max_children = fetch_parallel_config;
2427
2427
- add_options_to_argv(&options, config.display_format);
2428
+ add_options_to_argv(&options, &config);
2429
result = fetch_submodules(the_repository,
2430
&options,
2431
submodule_prefix,