summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>2017-09-06 08:48:09 +0200
committerJunio C Hamano <gitster@pobox.com>2017-09-07 09:52:18 +0900
commit121e43fa53ca6d874aa3e5a7664c9b769f2cbfa6 (patch)
tree7d58368b0500ddbfcf80d5e188c33e2eee126ebe
parentcad0c6928eae87dc8619b035e4eced5f2c662a12 (diff)
downloadgit-nm/pull-submodule-recurse-config.tar.gz
pull: honor submodule.recurse config optionnm/pull-submodule-recurse-config
"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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/pull.c4
-rwxr-xr-xt/t5572-pull-submodule.sh32
2 files changed, 36 insertions, 0 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 9ef1ab5015..6f772e8a22 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 077eb07e11..321bd37deb 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -65,6 +65,38 @@ 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 " --[no-]recurse-submodule and submodule.recurse" '
+ test_commit -C child merge_strategy_3 &&
+ 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-recurse-submodules --no-rebase &&
+ test_path_is_missing super/sub/merge_strategy_3.t &&
+ git -C super -c submodule.recurse=false pull --recurse-submodules --no-rebase &&
+ test_path_is_file super/sub/merge_strategy_3.t &&
+
+ test_commit -C child merge_strategy_4 &&
+ git -C parent submodule update --remote &&
+ git -C parent add sub &&
+ git -C parent commit -m "update submodule" &&
+
+ git -C super -c submodule.recurse=false pull --no-recurse-submodules --no-rebase &&
+ test_path_is_missing super/sub/merge_strategy_4.t &&
+ git -C super -c submodule.recurse=true pull --recurse-submodules --no-rebase &&
+ test_path_is_file super/sub/merge_strategy_4.t
+'
+
test_expect_success 'recursive rebasing pull' '
# change upstream
test_commit -C child rebase_strategy &&