fetch: use `fetch_config` to store "submodule.fetchJobs" value
Move the parsed "submodule.fetchJobs" 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
f7e063f3269ef29013db87190d1b4e152b505c3a
1 file changed
+6
-5
builtin/fetch.c
+6
-5
@@ -86,7 +86,6 @@ static int write_fetch_head = 1;
86
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;
89
static int atomic_fetch;
90
static enum transport_family family;
91
static const char *depth;
@@ -108,6 +107,7 @@ struct fetch_config {
107
int show_forced_updates;
108
int recurse_submodules;
109
int parallel;
110
+ int submodule_fetch_jobs;
111
};
112
113
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -136,7 +136,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
136
}
137
138
if (!strcmp(k, "submodule.fetchjobs")) {
139
- submodule_fetch_jobs_config = parse_submodule_fetchjobs(k, v);
139
+ fetch_config->submodule_fetch_jobs = parse_submodule_fetchjobs(k, v);
140
return 0;
141
} else if (!strcmp(k, "fetch.recursesubmodules")) {
142
fetch_config->recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
@@ -2119,6 +2119,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2119
.show_forced_updates = 1,
2120
.recurse_submodules = RECURSE_SUBMODULES_DEFAULT,
2121
.parallel = 1,
2122
+ .submodule_fetch_jobs = -1,
2123
};
2124
const char *submodule_prefix = "";
2125
const char *bundle_uri;
@@ -2268,8 +2269,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2269
}
2270
2271
if (config.recurse_submodules != RECURSE_SUBMODULES_OFF) {
2271
- int *sfjc = submodule_fetch_jobs_config == -1
2272
- ? &submodule_fetch_jobs_config : NULL;
2272
+ int *sfjc = config.submodule_fetch_jobs == -1
2273
+ ? &config.submodule_fetch_jobs : NULL;
2274
int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT
2275
? &config.recurse_submodules : NULL;
2276
@@ -2432,7 +2433,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2433
int max_children = max_jobs;
2434
2435
if (max_children < 0)
2435
- max_children = submodule_fetch_jobs_config;
2436
+ max_children = config.submodule_fetch_jobs;
2437
if (max_children < 0)
2438
max_children = config.parallel;
2439