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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jun 23, 2017 at 12:13 UTC 8c69832d137042a4368248a995bebcc5b964a87b
1 file changed +10 -9
builtin/fetch.c
+10 -9
@@ -36,7 +36,7 @@ static int prune = -1; /* unspecified */
36 #define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
37
38 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;
40 static int tags = TAGS_DEFAULT, unshallow, update_shallow, deepen;
41 static int max_children = -1;
42 static enum transport_family family;
@@ -48,7 +48,8 @@ static struct strbuf default_rla = STRBUF_INIT;
48 static struct transport *gtransport;
49 static struct transport *gsecondary;
50 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;
53 static int shown_url = 0;
54 static int refmap_alloc, refmap_nr;
55 static const char **refmap_array;
@@ -123,9 +124,11 @@ static struct option builtin_fetch_options[] = {
124 PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 },
125 { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
126 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 },
132 OPT_BOOL(0, "update-shallow", &update_shallow,
133 N_("accept refs that update .git/shallow")),
134 { OPTION_CALLBACK, 0, "refmap", NULL, N_("refmap"),
@@ -1333,10 +1336,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1336 deepen = 1;
1337
1338 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);
1341 gitmodules_config();
1342 git_config(submodule_config, NULL);
1343 }