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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Aug 2, 2017 at 12:49 UTC
8fa2915971e5032e6a32f5096452db81ab8795eb
3 files changed
+14
-15
builtin/fetch.c
+7
-1
@@ -71,6 +71,9 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
71
if (!strcmp(k, "submodule.fetchjobs")) {
72
max_children = parse_submodule_fetchjobs(k, v);
73
return 0;
74
+ } else if (!strcmp(k, "fetch.recursesubmodules")) {
75
+ recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
76
+ return 0;
77
}
78
79
return git_default_config(k, v, cb);
@@ -81,6 +84,9 @@ static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
84
if (!strcmp(var, "submodule.fetchjobs")) {
85
max_children = parse_submodule_fetchjobs(var, value);
86
return 0;
87
+ } else if (!strcmp(var, "fetch.recursesubmodules")) {
88
+ recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
89
+ return 0;
90
}
91
92
return 0;
@@ -1355,7 +1361,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1361
deepen = 1;
1362
1363
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
1358
- set_config_fetch_recurse_submodules(recurse_submodules_default);
1364
gitmodules_config();
1365
git_config(submodule_config, NULL);
1366
}
@@ -1399,6 +1404,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1404
result = fetch_populated_submodules(&options,
1405
submodule_prefix,
1406
recurse_submodules,
1407
+ recurse_submodules_default,
1408
verbosity < 0,
1409
max_children);
1410
argv_array_clear(&options);
submodule.c
+6
-13
@@ -20,7 +20,6 @@
20
#include "worktree.h"
21
#include "parse-options.h"
22
23
-static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
23
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
24
static struct string_list changed_submodule_paths = STRING_LIST_INIT_DUP;
25
static int initialized_fetch_ref_tips;
@@ -160,10 +159,6 @@ static int git_modules_config(const char *var, const char *value, void *cb)
159
{
160
if (starts_with(var, "submodule."))
161
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
- }
162
return 0;
163
}
164
@@ -714,11 +709,6 @@ done:
709
clear_commit_marks(right, ~0);
710
}
711
717
-void set_config_fetch_recurse_submodules(int value)
718
-{
719
- config_fetch_recurse_submodules = value;
720
-}
721
-
712
int should_update_submodules(void)
713
{
714
return config_update_recurse_submodules == RECURSE_SUBMODULES_ON;
@@ -1164,10 +1154,11 @@ struct submodule_parallel_fetch {
1154
const char *work_tree;
1155
const char *prefix;
1156
int command_line_option;
1157
+ int default_option;
1158
int quiet;
1159
int result;
1160
};
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}
1162
1163
static int get_next_submodule(struct child_process *cp,
1164
struct strbuf *err, void *data, void **task_cb)
@@ -1205,10 +1196,10 @@ static int get_next_submodule(struct child_process *cp,
1196
default_argv = "on-demand";
1197
}
1198
} else {
1208
- if ((config_fetch_recurse_submodules == RECURSE_SUBMODULES_OFF) ||
1199
+ if ((spf->default_option == RECURSE_SUBMODULES_OFF) ||
1200
gitmodules_is_unmerged)
1201
continue;
1211
- if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
1202
+ if (spf->default_option == RECURSE_SUBMODULES_ON_DEMAND) {
1203
if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
1204
continue;
1205
default_argv = "on-demand";
@@ -1275,6 +1266,7 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1266
1267
int fetch_populated_submodules(const struct argv_array *options,
1268
const char *prefix, int command_line_option,
1269
+ int default_option,
1270
int quiet, int max_parallel_jobs)
1271
{
1272
int i;
@@ -1282,6 +1274,7 @@ int fetch_populated_submodules(const struct argv_array *options,
1274
1275
spf.work_tree = get_git_work_tree();
1276
spf.command_line_option = command_line_option;
1277
+ spf.default_option = default_option;
1278
spf.quiet = quiet;
1279
spf.prefix = prefix;
1280
submodule.h
+1
-1
@@ -76,7 +76,6 @@ extern void show_submodule_inline_diff(FILE *f, const char *path,
76
unsigned dirty_submodule, const char *meta,
77
const char *del, const char *add, const char *reset,
78
const struct diff_options *opt);
79
-extern void set_config_fetch_recurse_submodules(int value);
79
/* Check if we want to update any submodule.*/
80
extern int should_update_submodules(void);
81
/*
@@ -87,6 +86,7 @@ extern const struct submodule *submodule_from_ce(const struct cache_entry *ce);
86
extern void check_for_new_submodule_commits(struct object_id *oid);
87
extern int fetch_populated_submodules(const struct argv_array *options,
88
const char *prefix, int command_line_option,
89
+ int default_option,
90
int quiet, int max_parallel_jobs);
91
extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
92
extern int submodule_uses_gitfile(const char *path);