Skip to content

Commit 8fa2915

Browse files
bmwillgitster
authored andcommitted
submodule: remove fetch.recursesubmodules from submodule-config parsing
Remove the 'fetch.recursesubmodules' configuration option from the general submodule-config parsing and instead rely on using '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 f20e7c1 commit 8fa2915

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

builtin/fetch.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
7171
if (!strcmp(k, "submodule.fetchjobs")) {
7272
max_children = parse_submodule_fetchjobs(k, v);
7373
return 0;
74+
} else if (!strcmp(k, "fetch.recursesubmodules")) {
75+
recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
76+
return 0;
7477
}
7578

7679
return git_default_config(k, v, cb);
@@ -81,6 +84,9 @@ static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
8184
if (!strcmp(var, "submodule.fetchjobs")) {
8285
max_children = parse_submodule_fetchjobs(var, value);
8386
return 0;
87+
} else if (!strcmp(var, "fetch.recursesubmodules")) {
88+
recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
89+
return 0;
8490
}
8591

8692
return 0;
@@ -1355,7 +1361,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13551361
deepen = 1;
13561362

13571363
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
1358-
set_config_fetch_recurse_submodules(recurse_submodules_default);
13591364
gitmodules_config();
13601365
git_config(submodule_config, NULL);
13611366
}
@@ -1399,6 +1404,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13991404
result = fetch_populated_submodules(&options,
14001405
submodule_prefix,
14011406
recurse_submodules,
1407+
recurse_submodules_default,
14021408
verbosity < 0,
14031409
max_children);
14041410
argv_array_clear(&options);

submodule.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "worktree.h"
2121
#include "parse-options.h"
2222

23-
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
2423
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
2524
static struct string_list changed_submodule_paths = STRING_LIST_INIT_DUP;
2625
static int initialized_fetch_ref_tips;
@@ -160,10 +159,6 @@ static int git_modules_config(const char *var, const char *value, void *cb)
160159
{
161160
if (starts_with(var, "submodule."))
162161
return parse_submodule_config_option(var, value);
163-
else if (!strcmp(var, "fetch.recursesubmodules")) {
164-
config_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
165-
return 0;
166-
}
167162
return 0;
168163
}
169164

@@ -714,11 +709,6 @@ void show_submodule_inline_diff(FILE *f, const char *path,
714709
clear_commit_marks(right, ~0);
715710
}
716711

717-
void set_config_fetch_recurse_submodules(int value)
718-
{
719-
config_fetch_recurse_submodules = value;
720-
}
721-
722712
int should_update_submodules(void)
723713
{
724714
return config_update_recurse_submodules == RECURSE_SUBMODULES_ON;
@@ -1164,10 +1154,11 @@ struct submodule_parallel_fetch {
11641154
const char *work_tree;
11651155
const char *prefix;
11661156
int command_line_option;
1157+
int default_option;
11671158
int quiet;
11681159
int result;
11691160
};
1170-
#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0}
1161+
#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0}
11711162

11721163
static int get_next_submodule(struct child_process *cp,
11731164
struct strbuf *err, void *data, void **task_cb)
@@ -1205,10 +1196,10 @@ static int get_next_submodule(struct child_process *cp,
12051196
default_argv = "on-demand";
12061197
}
12071198
} else {
1208-
if ((config_fetch_recurse_submodules == RECURSE_SUBMODULES_OFF) ||
1199+
if ((spf->default_option == RECURSE_SUBMODULES_OFF) ||
12091200
gitmodules_is_unmerged)
12101201
continue;
1211-
if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
1202+
if (spf->default_option == RECURSE_SUBMODULES_ON_DEMAND) {
12121203
if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
12131204
continue;
12141205
default_argv = "on-demand";
@@ -1275,13 +1266,15 @@ static int fetch_finish(int retvalue, struct strbuf *err,
12751266

12761267
int fetch_populated_submodules(const struct argv_array *options,
12771268
const char *prefix, int command_line_option,
1269+
int default_option,
12781270
int quiet, int max_parallel_jobs)
12791271
{
12801272
int i;
12811273
struct submodule_parallel_fetch spf = SPF_INIT;
12821274

12831275
spf.work_tree = get_git_work_tree();
12841276
spf.command_line_option = command_line_option;
1277+
spf.default_option = default_option;
12851278
spf.quiet = quiet;
12861279
spf.prefix = prefix;
12871280

submodule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ extern void show_submodule_inline_diff(FILE *f, const char *path,
7676
unsigned dirty_submodule, const char *meta,
7777
const char *del, const char *add, const char *reset,
7878
const struct diff_options *opt);
79-
extern void set_config_fetch_recurse_submodules(int value);
8079
/* Check if we want to update any submodule.*/
8180
extern int should_update_submodules(void);
8281
/*
@@ -87,6 +86,7 @@ extern const struct submodule *submodule_from_ce(const struct cache_entry *ce);
8786
extern void check_for_new_submodule_commits(struct object_id *oid);
8887
extern int fetch_populated_submodules(const struct argv_array *options,
8988
const char *prefix, int command_line_option,
89+
int default_option,
9090
int quiet, int max_parallel_jobs);
9191
extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
9292
extern int submodule_uses_gitfile(const char *path);

0 commit comments

Comments
 (0)