Skip to content

Commit f20e7c1

Browse files
bmwillgitster
authored andcommitted
submodule: remove submodule.fetchjobs from submodule-config parsing
The '.gitmodules' file should only contain information pertinent to configuring individual submodules (name to path mapping, URL where to obtain the submodule, etc.) while other configuration like the number of jobs to use when fetching submodules should be a part of the repository's config. Remove the 'submodule.fetchjobs' configuration option from the general submodule-config parsing and instead rely on using the 'config_from_gitmodules()' in order to maintain backwards compatibility with this config being placed in the '.gitmodules' file. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b22e51c commit f20e7c1

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed

builtin/fetch.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int prune = -1; /* unspecified */
3939
static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity, deepen_relative;
4040
static int progress = -1;
4141
static int tags = TAGS_DEFAULT, unshallow, update_shallow, deepen;
42-
static int max_children = -1;
42+
static int max_children = 1;
4343
static enum transport_family family;
4444
static const char *depth;
4545
static const char *deepen_since;
@@ -68,9 +68,24 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
6868
recurse_submodules = r;
6969
}
7070

71+
if (!strcmp(k, "submodule.fetchjobs")) {
72+
max_children = parse_submodule_fetchjobs(k, v);
73+
return 0;
74+
}
75+
7176
return git_default_config(k, v, cb);
7277
}
7378

79+
static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
80+
{
81+
if (!strcmp(var, "submodule.fetchjobs")) {
82+
max_children = parse_submodule_fetchjobs(var, value);
83+
return 0;
84+
}
85+
86+
return 0;
87+
}
88+
7489
static int parse_refmap_arg(const struct option *opt, const char *arg, int unset)
7590
{
7691
ALLOC_GROW(refmap_array, refmap_nr + 1, refmap_alloc);
@@ -1311,6 +1326,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13111326
for (i = 1; i < argc; i++)
13121327
strbuf_addf(&default_rla, " %s", argv[i]);
13131328

1329+
config_from_gitmodules(gitmodules_fetch_config, NULL);
13141330
git_config(git_fetch_config, NULL);
13151331

13161332
argc = parse_options(argc, argv, prefix,

builtin/submodule--helper.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,19 @@ static int update_clone_task_finished(int result,
960960
return 0;
961961
}
962962

963+
static int gitmodules_update_clone_config(const char *var, const char *value,
964+
void *cb)
965+
{
966+
int *max_jobs = cb;
967+
if (!strcmp(var, "submodule.fetchjobs"))
968+
*max_jobs = parse_submodule_fetchjobs(var, value);
969+
return 0;
970+
}
971+
963972
static int update_clone(int argc, const char **argv, const char *prefix)
964973
{
965974
const char *update = NULL;
966-
int max_jobs = -1;
975+
int max_jobs = 1;
967976
struct string_list_item *item;
968977
struct pathspec pathspec;
969978
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
@@ -1000,6 +1009,9 @@ static int update_clone(int argc, const char **argv, const char *prefix)
10001009
};
10011010
suc.prefix = prefix;
10021011

1012+
config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
1013+
git_config(gitmodules_update_clone_config, &max_jobs);
1014+
10031015
argc = parse_options(argc, argv, prefix, module_update_clone_options,
10041016
git_submodule_helper_usage, 0);
10051017

@@ -1017,9 +1029,6 @@ static int update_clone(int argc, const char **argv, const char *prefix)
10171029
gitmodules_config();
10181030
git_config(submodule_config, NULL);
10191031

1020-
if (max_jobs < 0)
1021-
max_jobs = parallel_submodules();
1022-
10231032
run_processes_parallel(max_jobs,
10241033
update_clone_get_next_task,
10251034
update_clone_start_failure,

submodule-config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ static int parse_fetch_recurse(const char *opt, const char *arg,
248248
}
249249
}
250250

251+
int parse_submodule_fetchjobs(const char *var, const char *value)
252+
{
253+
int fetchjobs = git_config_int(var, value);
254+
if (fetchjobs < 0)
255+
die(_("negative values not allowed for submodule.fetchjobs"));
256+
return fetchjobs;
257+
}
258+
251259
int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
252260
{
253261
return parse_fetch_recurse(opt, arg, 1);

submodule-config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct repository;
2727

2828
extern void submodule_cache_free(struct submodule_cache *cache);
2929

30+
extern int parse_submodule_fetchjobs(const char *var, const char *value);
3031
extern int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
3132
struct option;
3233
extern int option_fetch_parse_recurse_submodules(const struct option *opt,

submodule.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
2424
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
25-
static int parallel_jobs = 1;
2625
static struct string_list changed_submodule_paths = STRING_LIST_INIT_DUP;
2726
static int initialized_fetch_ref_tips;
2827
static struct oid_array ref_tips_before_fetch;
@@ -159,12 +158,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
159158
/* For loading from the .gitmodules file. */
160159
static int git_modules_config(const char *var, const char *value, void *cb)
161160
{
162-
if (!strcmp(var, "submodule.fetchjobs")) {
163-
parallel_jobs = git_config_int(var, value);
164-
if (parallel_jobs < 0)
165-
die(_("negative values not allowed for submodule.fetchJobs"));
166-
return 0;
167-
} else if (starts_with(var, "submodule."))
161+
if (starts_with(var, "submodule."))
168162
return parse_submodule_config_option(var, value);
169163
else if (!strcmp(var, "fetch.recursesubmodules")) {
170164
config_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
@@ -1303,9 +1297,6 @@ int fetch_populated_submodules(const struct argv_array *options,
13031297
argv_array_push(&spf.args, "--recurse-submodules-default");
13041298
/* default value, "--submodule-prefix" and its value are added later */
13051299

1306-
if (max_parallel_jobs < 0)
1307-
max_parallel_jobs = parallel_jobs;
1308-
13091300
calculate_changed_submodule_paths();
13101301
run_processes_parallel(max_parallel_jobs,
13111302
get_next_submodule,
@@ -1825,11 +1816,6 @@ int merge_submodule(struct object_id *result, const char *path,
18251816
return 0;
18261817
}
18271818

1828-
int parallel_submodules(void)
1829-
{
1830-
return parallel_jobs;
1831-
}
1832-
18331819
/*
18341820
* Embeds a single submodules git directory into the superprojects git dir,
18351821
* non recursively.

submodule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ extern int push_unpushed_submodules(struct oid_array *commits,
112112
const struct string_list *push_options,
113113
int dry_run);
114114
extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
115-
extern int parallel_submodules(void);
116115
/*
117116
* Given a submodule path (as in the index), return the repository
118117
* path of that submodule in 'buf'. Return -1 on error or when the

0 commit comments

Comments
 (0)