git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2] pull: honor submodule.recurse config option

From
Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Date
Sep 4, 2017, 06:31 UTC
Message-ID
<40ecf559-0348-b838-72f7-0ad7746a7072@morey-chaisemartin.com>

"git pull" supports a --recurse-submodules option but does not parse the submodule.recurse configuration item to set the default for that option. Meanwhile "git fetch" does support submodule.recurse, producing confusing behavior: when submodule.recurse is enabled, "git pull" recursively fetches submodules but does not update them after fetch.

Handle submodule.recurse in "git pull" to fix this.
Reported-by: Magnus Homann <magnus@homann.se>
Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
Changes since v1:
 * Cleanup commit message
 * Add test
 * Remove extra var in code and fallthrough to git_default_config
 builtin/pull.c            |  4 ++++
 t/t5572-pull-submodule.sh | 10 ++++++++++
 2 files changed, 14 insertions(+)
diff --git a/builtin/pull.c b/builtin/pull.c
index 7fe281414..ce8ccb15b 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -325,6 +325,10 @@ static int git_pull_config(const char *var, const char *value, void *cb)
 	if (!strcmp(var, "rebase.autostash")) {
 		config_autostash = git_config_bool(var, value);
 		return 0;
+	} else if (!strcmp(var, "submodule.recurse")) {
+		recurse_submodules = git_config_bool(var, value) ?
+			RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
+		return 0;
 	}
 	return git_default_config(var, value, cb);
 }
diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh
index 077eb07e1..1b3a3f445 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -65,6 +65,16 @@ test_expect_success 'recursive pull updates working tree' '
 	test_path_is_file super/sub/merge_strategy.t
 '
 
+test_expect_success "submodule.recurse option triggers recursive pull" '
+	test_commit -C child merge_strategy_2 &&
+	git -C parent submodule update --remote &&
+	git -C parent add sub &&
+	git -C parent commit -m "update submodule" &&
+
+	git -C super -c submodule.recurse pull --no-rebase &&
+	test_path_is_file super/sub/merge_strategy_2.t
+'
+
 test_expect_success 'recursive rebasing pull' '
 	# change upstream
 	test_commit -C child rebase_strategy &&
-- 
2.14.1.460.g695108176
Next: Junio C Hamano
Message 1 of 4 in “[PATCHv2] pull: honor submodule.recurse config option”
  1. Nicolas Morey-ChaisemartinSep 4, 2017
  2. Junio C HamanoSep 6, 2017
  3. Nicolas Morey-ChaisemartinSep 6, 2017
  4. Junio C HamanoSep 7, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.