Skip to content

Commit ac197cc

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

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

builtin/fetch.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ static int verbosity, deepen_relative, set_upstream, refetch;
8787
static int progress = -1;
8888
static int tags = TAGS_DEFAULT, update_shallow, deepen;
8989
static int submodule_fetch_jobs_config = -1;
90-
static int fetch_parallel_config = 1;
9190
static int atomic_fetch;
9291
static enum transport_family family;
9392
static const char *depth;
@@ -108,6 +107,7 @@ struct fetch_config {
108107
int prune_tags;
109108
int show_forced_updates;
110109
int recurse_submodules;
110+
int parallel;
111111
};
112112

113113
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)
144144
}
145145

146146
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)
149149
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();
152152
return 0;
153153
}
154154

@@ -2118,6 +2118,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21182118
.prune_tags = -1,
21192119
.show_forced_updates = 1,
21202120
.recurse_submodules = RECURSE_SUBMODULES_DEFAULT,
2121+
.parallel = 1,
21212122
};
21222123
const char *submodule_prefix = "";
21232124
const char *bundle_uri;
@@ -2411,7 +2412,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24112412
"from one remote"));
24122413

24132414
if (max_children < 0)
2414-
max_children = fetch_parallel_config;
2415+
max_children = config.parallel;
24152416

24162417
/* TODO should this also die if we have a previous partial-clone? */
24172418
result = fetch_multiple(&list, max_children, &config);
@@ -2433,7 +2434,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24332434
if (max_children < 0)
24342435
max_children = submodule_fetch_jobs_config;
24352436
if (max_children < 0)
2436-
max_children = fetch_parallel_config;
2437+
max_children = config.parallel;
24372438

24382439
add_options_to_argv(&options, &config);
24392440
result = fetch_submodules(the_repository,

0 commit comments

Comments
 (0)