git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] fetch: Ensure that fetch.recurseSubmodules overrides submodule.recurse.
@ 2018-09-21 18:51 Marc Branchaud
  2018-09-21 19:22 ` Stefan Beller
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Branchaud @ 2018-09-21 18:51 UTC (permalink / raw)
  To: git

Also document this fact.

Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-21 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 18:51 [PATCH] fetch: Ensure that fetch.recurseSubmodules overrides submodule.recurse Marc Branchaud
2018-09-21 19:22 ` Stefan Beller

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).