Skip to content

Commit 8c69832

Browse files
stefanbellergitster
authored andcommitted
builtin/fetch: parse recurse-submodules-default at default options parsing
Instead of just storing the string and then later calling our own parsing function 'parse_fetch_recurse_submodules_arg', make use of the function callback 'option_fetch_parse_recurse_submodules' that was introduced in the last patch. Also move all submodule recursing variables in one spot at the top of the file. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 886dc15 commit 8c69832

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

builtin/fetch.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int prune = -1; /* unspecified */
3636
#define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
3737

3838
static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity, deepen_relative;
39-
static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
39+
static int progress = -1;
4040
static int tags = TAGS_DEFAULT, unshallow, update_shallow, deepen;
4141
static int max_children = -1;
4242
static enum transport_family family;
@@ -48,7 +48,8 @@ static struct strbuf default_rla = STRBUF_INIT;
4848
static struct transport *gtransport;
4949
static struct transport *gsecondary;
5050
static const char *submodule_prefix = "";
51-
static const char *recurse_submodules_default;
51+
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
52+
static int recurse_submodules_default = RECURSE_SUBMODULES_DEFAULT;
5253
static int shown_url = 0;
5354
static int refmap_alloc, refmap_nr;
5455
static const char **refmap_array;
@@ -123,9 +124,11 @@ static struct option builtin_fetch_options[] = {
123124
PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 },
124125
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
125126
N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN },
126-
{ OPTION_STRING, 0, "recurse-submodules-default",
127-
&recurse_submodules_default, NULL,
128-
N_("default mode for recursion"), PARSE_OPT_HIDDEN },
127+
{ OPTION_CALLBACK, 0, "recurse-submodules-default",
128+
&recurse_submodules_default, N_("on-demand"),
129+
N_("default for recursive fetching of submodules "
130+
"(lower priority than config files)"),
131+
PARSE_OPT_HIDDEN, option_fetch_parse_recurse_submodules },
129132
OPT_BOOL(0, "update-shallow", &update_shallow,
130133
N_("accept refs that update .git/shallow")),
131134
{ OPTION_CALLBACK, 0, "refmap", NULL, N_("refmap"),
@@ -1333,10 +1336,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13331336
deepen = 1;
13341337

13351338
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
1336-
if (recurse_submodules_default) {
1337-
int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);
1338-
set_config_fetch_recurse_submodules(arg);
1339-
}
1339+
if (recurse_submodules_default != RECURSE_SUBMODULES_DEFAULT)
1340+
set_config_fetch_recurse_submodules(recurse_submodules_default);
13401341
gitmodules_config();
13411342
git_config(submodule_config, NULL);
13421343
}

0 commit comments

Comments
 (0)