Skip to content

Commit df80c57

Browse files
committed
Merge branch 'nm/pull-submodule-recurse-config'
"git -c submodule.recurse=yes pull" did not work as if the "--recurse-submodules" option was given from the command line. This has been corrected. * nm/pull-submodule-recurse-config: pull: honor submodule.recurse config option pull: fix cli and config option parsing order
2 parents daafb50 + 121e43f commit df80c57

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

builtin/pull.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ static int git_pull_config(const char *var, const char *value, void *cb)
325325
if (!strcmp(var, "rebase.autostash")) {
326326
config_autostash = git_config_bool(var, value);
327327
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;
328332
}
329333
return git_default_config(var, value, cb);
330334
}
@@ -815,6 +819,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
815819
if (!getenv("GIT_REFLOG_ACTION"))
816820
set_reflog_message(argc, argv);
817821

822+
git_config(git_pull_config, NULL);
823+
818824
argc = parse_options(argc, argv, prefix, pull_options, pull_usage, 0);
819825

820826
parse_repo_refspecs(argc, argv, &repo, &refspecs);
@@ -825,8 +831,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
825831
if (opt_rebase < 0)
826832
opt_rebase = config_get_rebase();
827833

828-
git_config(git_pull_config, NULL);
829-
830834
if (read_cache_unmerged())
831835
die_resolve_conflict("pull");
832836

t/t5572-pull-submodule.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,38 @@ test_expect_success 'recursive pull updates working tree' '
6565
test_path_is_file super/sub/merge_strategy.t
6666
'
6767

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+
68100
test_expect_success 'recursive rebasing pull' '
69101
# change upstream
70102
test_commit -C child rebase_strategy &&

0 commit comments

Comments
 (0)