Also document this fact.
Signed-off-by: Marc Branchaud <[email protected]>
---
I ran into this bug when I had both fetch.recurseSubmodules=on-demand and
submodule.recurse=true, and submodule.recurse was set *after*
fetch.recurseSubmodules in my config.
The fix ensures that fetch.recurseSubmodules always overrides
submodule.recurse. If neither is set then fetch still behaves as if
fetch.recurseSubmodules=on-demand (the documented default).
I'm not sure if this is the most elegant implementation, but it gets the job
done.
M.
Documentation/config.txt | 6 ++++--
builtin/fetch.c | 5 ++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index eb66a11975..67b0adc1d4 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1514,7 +1514,8 @@ fetch.recurseSubmodules::
recurse at all when set to false. When set to 'on-demand' (the default
value), fetch and pull will only recurse into a populated submodule
when its superproject retrieves a commit that updates the submodule's
- reference.
+ reference. This option overrides the more general submodule.recurse
+ option, for the `fetch` command.
fetch.fsckObjects::
If it is set to true, git-fetch-pack will check all fetched
@@ -3465,7 +3466,8 @@ submodule.active::
submodule.recurse::
Specifies if commands recurse into submodules by default. This
applies to all commands that have a `--recurse-submodules` option,
- except `clone`.
+ except `clone`. Also, the `fetch` command's behaviour can be specified
+ independently with the fetch.recurseSubmodules option.
Defaults to false.
submodule.fetchJobs::
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 61bec5d213..08b8bf2741 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -60,6 +60,7 @@ static struct transport *gsecondary;
static const char *submodule_prefix = "";
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
+static int recurse_submodules_set_explicitly = 0;
static int shown_url = 0;
static struct refspec refmap = REFSPEC_INIT_FETCH;
static struct list_objects_filter_options filter_options;
@@ -78,7 +79,8 @@ static int git_fetch_config(const char *k, const char *v,
void *cb)
return 0;
}
- if (!strcmp(k, "submodule.recurse")) {
+ if (!strcmp(k, "submodule.recurse") &&
+ !recurse_submodules_set_explicitly) {
int r = git_config_bool(k, v) ?
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
recurse_submodules = r;
@@ -88,6 +90,7 @@ static int git_fetch_config(const char *k, const char *v,
void *cb)
max_children = parse_submodule_fetchjobs(k, v);
return 0;
} else if (!strcmp(k, "fetch.recursesubmodules")) {
+ recurse_submodules_set_explicitly = 1;
recurse_submodules = parse_fetch_recurse_submodules_arg(k, v);
return 0;
}
--
2.19.0.1.g5109f9487a