pull: do not let submodule.recurse override fetch.recurseSubmodules
commit58194173652786709ba9dd1f56df6922a92f419f
authorGlen Choo <chooglen@google.com>
Tue, 10 May 2022 19:25:47 +0000 (10 19:25 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 May 2022 22:42:30 +0000 (11 15:42 -0700)
treee87709b05e4fe05a7caed99e09ca2c01a9b5e71a
parent17083c79ae842b51d82518e2efe5281346acea0e
pull: do not let submodule.recurse override fetch.recurseSubmodules

Fix a bug in "git pull" where `submodule.recurse` is preferred over
`fetch.recurseSubmodules` when performing a fetch
(Documentation/config/fetch.txt says that `fetch.recurseSubmodules`
should be preferred.). Do this by passing the value of the
"--recurse-submodules" CLI option to the underlying fetch, instead of
passing a value that combines the CLI option and config variables.

In other words, this bug occurred because builtin/pull.c is conflating
two similar-sounding, but different concepts:

- Whether "git pull" itself should care about submodules e.g. whether it
  should update the submodule worktrees after performing a merge.
- The value of "--recurse-submodules" to pass to the underlying "git
  fetch".

Thus, when `submodule.recurse` is set, the underlying "git fetch" gets
invoked with "--recurse-submodules[=value]", overriding the value of
`fetch.recurseSubmodules`.

An alternative (and more obvious) approach to fix the bug would be to
teach "git pull" to understand `fetch.recurseSubmodules`, but the
proposed solution works better because:

- We don't maintain two identical config-parsing implementions in "git
  pull" and "git fetch".
- It works better with other commands invoked by "git pull" e.g. "git
  merge" won't accidentally respect `fetch.recurseSubmodules`.

Reported-by: Huang Zou <huang.zou@schrodinger.com>
Helped-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pull.c
t/t5572-pull-submodule.sh