Skip to content

Commit d1adf85

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6bc7a37 commit d1adf85

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

builtin/fetch.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ static int backfill_tags(struct display_state *display_state,
15531553

15541554
static int do_fetch(struct transport *transport,
15551555
struct refspec *rs,
1556-
enum display_format display_format)
1556+
const struct fetch_config *config)
15571557
{
15581558
struct ref_transaction *transaction = NULL;
15591559
struct ref *ref_map = NULL;
@@ -1639,7 +1639,8 @@ static int do_fetch(struct transport *transport,
16391639
if (retcode)
16401640
goto cleanup;
16411641

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);
16431644

16441645
if (atomic_fetch) {
16451646
transaction = ref_transaction_begin(&err);
@@ -1828,7 +1829,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
18281829
}
18291830

18301831
static void add_options_to_argv(struct strvec *argv,
1831-
enum display_format format)
1832+
const struct fetch_config *config)
18321833
{
18331834
if (dry_run)
18341835
strvec_push(argv, "--dry-run");
@@ -1864,7 +1865,7 @@ static void add_options_to_argv(struct strvec *argv,
18641865
strvec_push(argv, "--ipv6");
18651866
if (!write_fetch_head)
18661867
strvec_push(argv, "--no-write-fetch-head");
1867-
if (format == DISPLAY_FORMAT_PORCELAIN)
1868+
if (config->display_format == DISPLAY_FORMAT_PORCELAIN)
18681869
strvec_pushf(argv, "--porcelain");
18691870
}
18701871

@@ -1874,7 +1875,7 @@ struct parallel_fetch_state {
18741875
const char **argv;
18751876
struct string_list *remotes;
18761877
int next, result;
1877-
enum display_format format;
1878+
const struct fetch_config *config;
18781879
};
18791880

18801881
static int fetch_next_remote(struct child_process *cp,
@@ -1894,7 +1895,7 @@ static int fetch_next_remote(struct child_process *cp,
18941895
strvec_push(&cp->args, remote);
18951896
cp->git_cmd = 1;
18961897

1897-
if (verbosity >= 0 && state->format != DISPLAY_FORMAT_PORCELAIN)
1898+
if (verbosity >= 0 && state->config->display_format != DISPLAY_FORMAT_PORCELAIN)
18981899
printf(_("Fetching %s\n"), remote);
18991900

19001901
return 1;
@@ -1927,7 +1928,7 @@ static int fetch_finished(int result, struct strbuf *out,
19271928
}
19281929

19291930
static int fetch_multiple(struct string_list *list, int max_children,
1930-
enum display_format format)
1931+
const struct fetch_config *config)
19311932
{
19321933
int i, result = 0;
19331934
struct strvec argv = STRVEC_INIT;
@@ -1945,10 +1946,10 @@ static int fetch_multiple(struct string_list *list, int max_children,
19451946
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
19461947
"fetch", "--append", "--no-auto-gc",
19471948
"--no-write-commit-graph", NULL);
1948-
add_options_to_argv(&argv, format);
1949+
add_options_to_argv(&argv, config);
19491950

19501951
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 };
19521953
const struct run_process_parallel_opts opts = {
19531954
.tr2_category = "fetch",
19541955
.tr2_label = "parallel/fetch",
@@ -1972,7 +1973,7 @@ static int fetch_multiple(struct string_list *list, int max_children,
19721973

19731974
strvec_pushv(&cmd.args, argv.v);
19741975
strvec_push(&cmd.args, name);
1975-
if (verbosity >= 0 && format != DISPLAY_FORMAT_PORCELAIN)
1976+
if (verbosity >= 0 && config->display_format != DISPLAY_FORMAT_PORCELAIN)
19761977
printf(_("Fetching %s\n"), name);
19771978
cmd.git_cmd = 1;
19781979
if (run_command(&cmd)) {
@@ -2028,7 +2029,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
20282029

20292030
static int fetch_one(struct remote *remote, int argc, const char **argv,
20302031
int prune_tags_ok, int use_stdin_refspecs,
2031-
enum display_format display_format)
2032+
const struct fetch_config *config)
20322033
{
20332034
struct refspec rs = REFSPEC_INIT_FETCH;
20342035
int i;
@@ -2095,7 +2096,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
20952096
sigchain_push_common(unlock_pack_on_signal);
20962097
atexit(unlock_pack_atexit);
20972098
sigchain_push(SIGPIPE, SIG_IGN);
2098-
exit_code = do_fetch(gtransport, &rs, display_format);
2099+
exit_code = do_fetch(gtransport, &rs, config);
20992100
sigchain_pop(SIGPIPE);
21002101
refspec_clear(&rs);
21012102
transport_disconnect(gtransport);
@@ -2383,7 +2384,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
23832384
if (filter_options.choice || repo_has_promisor_remote(the_repository))
23842385
fetch_one_setup_partial(remote);
23852386
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
2386-
config.display_format);
2387+
&config);
23872388
} else {
23882389
int max_children = max_jobs;
23892390

@@ -2403,7 +2404,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24032404
max_children = fetch_parallel_config;
24042405

24052406
/* 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);
24072408
}
24082409

24092410
/*
@@ -2424,7 +2425,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24242425
if (max_children < 0)
24252426
max_children = fetch_parallel_config;
24262427

2427-
add_options_to_argv(&options, config.display_format);
2428+
add_options_to_argv(&options, &config);
24282429
result = fetch_submodules(the_repository,
24292430
&options,
24302431
submodule_prefix,

0 commit comments

Comments
 (0)