Skip to content

Commit dd9ff30

Browse files
committed
Merge branch 'gc/recursive-fetch-with-unused-submodules'
When "git fetch --recurse-submodules" grabbed submodule commits that would be needed to recursively check out newly fetched commits in the superproject, it only paid attention to submodules that are in the current checkout of the superproject. We now do so for all submodules that have been run "git submodule init" on. * gc/recursive-fetch-with-unused-submodules: submodule: fix latent check_has_commit() bug fetch: fetch unpopulated, changed submodules submodule: move logic into fetch_task_create() submodule: extract get_fetch_task() submodule: store new submodule commits oid_array in a struct submodule: inline submodule_commits() into caller submodule: make static functions read submodules from commits t5526: create superproject commits with test helper t5526: stop asserting on stderr literally t5526: introduce test helper to assert on fetches
2 parents 6e1a895 + 5fff35d commit dd9ff30

File tree

6 files changed

+761
-312
lines changed

6 files changed

+761
-312
lines changed

Documentation/fetch-options.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,23 @@ endif::git-pull[]
186186
ifndef::git-pull[]
187187
--recurse-submodules[=yes|on-demand|no]::
188188
This option controls if and under what conditions new commits of
189-
populated submodules should be fetched too. It can be used as a
190-
boolean option to completely disable recursion when set to 'no' or to
191-
unconditionally recurse into all populated submodules when set to
192-
'yes', which is the default when this option is used without any
193-
value. Use 'on-demand' to only recurse into a populated submodule
194-
when the superproject retrieves a commit that updates the submodule's
195-
reference to a commit that isn't already in the local submodule
196-
clone. By default, 'on-demand' is used, unless
197-
`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
189+
submodules should be fetched too. When recursing through submodules,
190+
`git fetch` always attempts to fetch "changed" submodules, that is, a
191+
submodule that has commits that are referenced by a newly fetched
192+
superproject commit but are missing in the local submodule clone. A
193+
changed submodule can be fetched as long as it is present locally e.g.
194+
in `$GIT_DIR/modules/` (see linkgit:gitsubmodules[7]); if the upstream
195+
adds a new submodule, that submodule cannot be fetched until it is
196+
cloned e.g. by `git submodule update`.
197+
+
198+
When set to 'on-demand', only changed submodules are fetched. When set
199+
to 'yes', all populated submodules are fetched and submodules that are
200+
both unpopulated and changed are fetched. When set to 'no', submodules
201+
are never fetched.
202+
+
203+
When unspecified, this uses the value of `fetch.recurseSubmodules` if it
204+
is set (see linkgit:git-config[1]), defaulting to 'on-demand' if unset.
205+
When this option is used without any value, it defaults to 'yes'.
198206
endif::git-pull[]
199207

200208
-j::

Documentation/git-fetch.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,10 @@ include::transfer-data-leaks.txt[]
287287

288288
BUGS
289289
----
290-
Using --recurse-submodules can only fetch new commits in already checked
291-
out submodules right now. When e.g. upstream added a new submodule in the
292-
just fetched commits of the superproject the submodule itself cannot be
293-
fetched, making it impossible to check out that submodule later without
294-
having to do a fetch again. This is expected to be fixed in a future Git
295-
version.
290+
Using --recurse-submodules can only fetch new commits in submodules that are
291+
present locally e.g. in `$GIT_DIR/modules/`. If the upstream adds a new
292+
submodule, that submodule cannot be fetched until it is cloned e.g. by `git
293+
submodule update`. This is expected to be fixed in a future Git version.
296294

297295
SEE ALSO
298296
--------

builtin/fetch.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,13 +2258,13 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
22582258
max_children = fetch_parallel_config;
22592259

22602260
add_options_to_argv(&options);
2261-
result = fetch_populated_submodules(the_repository,
2262-
&options,
2263-
submodule_prefix,
2264-
recurse_submodules,
2265-
recurse_submodules_default,
2266-
verbosity < 0,
2267-
max_children);
2261+
result = fetch_submodules(the_repository,
2262+
&options,
2263+
submodule_prefix,
2264+
recurse_submodules,
2265+
recurse_submodules_default,
2266+
verbosity < 0,
2267+
max_children);
22682268
strvec_clear(&options);
22692269
}
22702270

0 commit comments

Comments
 (0)