pull: honor submodule.recurse config option

"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>

Nicolas Morey-Chaisemartin committed Sep 6, 2017 at 08:48 UTC 121e43fa53ca6d874aa3e5a7664c9b769f2cbfa6
2 files changed +36
builtin/pull.c
+4
@@ -325,6 +325,10 @@ static int git_pull_config(const char *var, const char *value, void *cb)
325 if (!strcmp(var, "rebase.autostash")) {
326 config_autostash = git_config_bool(var, value);
327 return 0;
328 + } else if (!strcmp(var, "submodule.recurse")) {
329 + recurse_submodules = git_config_bool(var, value) ?
330 + RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
331 + return 0;
332 }
333 return git_default_config(var, value, cb);
334 }
t/t5572-pull-submodule.sh
+32
@@ -65,6 +65,38 @@ test_expect_success 'recursive pull updates working tree' '
65 test_path_is_file super/sub/merge_strategy.t
66 '
67
68 +test_expect_success "submodule.recurse option triggers recursive pull" '
69 + test_commit -C child merge_strategy_2 &&
70 + git -C parent submodule update --remote &&
71 + git -C parent add sub &&
72 + git -C parent commit -m "update submodule" &&
73 +
74 + git -C super -c submodule.recurse pull --no-rebase &&
75 + test_path_is_file super/sub/merge_strategy_2.t
76 +'
77 +
78 +test_expect_success " --[no-]recurse-submodule and submodule.recurse" '
79 + test_commit -C child merge_strategy_3 &&
80 + git -C parent submodule update --remote &&
81 + git -C parent add sub &&
82 + git -C parent commit -m "update submodule" &&
83 +
84 + git -C super -c submodule.recurse pull --no-recurse-submodules --no-rebase &&
85 + test_path_is_missing super/sub/merge_strategy_3.t &&
86 + git -C super -c submodule.recurse=false pull --recurse-submodules --no-rebase &&
87 + test_path_is_file super/sub/merge_strategy_3.t &&
88 +
89 + test_commit -C child merge_strategy_4 &&
90 + git -C parent submodule update --remote &&
91 + git -C parent add sub &&
92 + git -C parent commit -m "update submodule" &&
93 +
94 + git -C super -c submodule.recurse=false pull --no-recurse-submodules --no-rebase &&
95 + test_path_is_missing super/sub/merge_strategy_4.t &&
96 + git -C super -c submodule.recurse=true pull --recurse-submodules --no-rebase &&
97 + test_path_is_file super/sub/merge_strategy_4.t
98 +'
99 +
100 test_expect_success 'recursive rebasing pull' '
101 # change upstream
102 test_commit -C child rebase_strategy &&