fetch: use `fetch_config` to store "fetch.parallel" value
Move the parsed "fetch.parallel" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). 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:49 UTC
ac197cc094e1d39fa32eb935825cdfcd8c6bd79f
1 file changed
+8
-7
builtin/fetch.c
+8
-7
@@ -87,7 +87,6 @@ static int verbosity, deepen_relative, set_upstream, refetch;
87
static int progress = -1;
88
static int tags = TAGS_DEFAULT, update_shallow, deepen;
89
static int submodule_fetch_jobs_config = -1;
90
-static int fetch_parallel_config = 1;
90
static int atomic_fetch;
91
static enum transport_family family;
92
static const char *depth;
@@ -108,6 +107,7 @@ struct fetch_config {
107
int prune_tags;
108
int show_forced_updates;
109
int recurse_submodules;
110
+ int parallel;
111
};
112
113
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -144,11 +144,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
144
}
145
146
if (!strcmp(k, "fetch.parallel")) {
147
- fetch_parallel_config = git_config_int(k, v);
148
- if (fetch_parallel_config < 0)
147
+ fetch_config->parallel = git_config_int(k, v);
148
+ if (fetch_config->parallel < 0)
149
die(_("fetch.parallel cannot be negative"));
150
- if (!fetch_parallel_config)
151
- fetch_parallel_config = online_cpus();
150
+ if (!fetch_config->parallel)
151
+ fetch_config->parallel = online_cpus();
152
return 0;
153
}
154
@@ -2118,6 +2118,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2118
.prune_tags = -1,
2119
.show_forced_updates = 1,
2120
.recurse_submodules = RECURSE_SUBMODULES_DEFAULT,
2121
+ .parallel = 1,
2122
};
2123
const char *submodule_prefix = "";
2124
const char *bundle_uri;
@@ -2411,7 +2412,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2412
"from one remote"));
2413
2414
if (max_children < 0)
2414
- max_children = fetch_parallel_config;
2415
+ max_children = config.parallel;
2416
2417
/* TODO should this also die if we have a previous partial-clone? */
2418
result = fetch_multiple(&list, max_children, &config);
@@ -2433,7 +2434,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2434
if (max_children < 0)
2435
max_children = submodule_fetch_jobs_config;
2436
if (max_children < 0)
2436
- max_children = fetch_parallel_config;
2437
+ max_children = config.parallel;
2438
2439
add_options_to_argv(&options, &config);
2440
result = fetch_submodules(the_repository,