]> git.ipfire.org Git - thirdparty/git.git/commit - submodule.c
fetch: ensure submodule objects fetched
authorStefan Beller <sbeller@google.com>
Thu, 6 Dec 2018 21:26:55 +0000 (13:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Dec 2018 01:54:19 +0000 (10:54 +0900)
commitbe76c2128234d94b47f7087152ee55d08bb65d88
treecccb0afefb56c39fc03cd633485d5a5e2a05290b
parenta62387b3fc9f5aeeb04a2db278121d33a9caafa7
fetch: ensure submodule objects fetched

Currently when git-fetch is asked to recurse into submodules, it dispatches
a plain "git-fetch -C <submodule-dir>" (with some submodule related options
such as prefix and recusing strategy, but) without any information of the
remote or the tip that should be fetched.

But this default fetch is not sufficient, as a newly fetched commit in
the superproject could point to a commit in the submodule that is not
in the default refspec. This is common in workflows like Gerrit's.
When fetching a Gerrit change under review (from refs/changes/??), the
commits in that change likely point to submodule commits that have not
been merged to a branch yet.

Fetch a submodule object by id if the object that the superproject
points to, cannot be found. For now this object is fetched from the
'origin' remote as we defer getting the default remote to a later patch.

A list of new submodule commits are already generated in certain
conditions (by check_for_new_submodule_commits()); this new feature
invokes that function in more situations.

The submodule checks were done only when a ref in the superproject
changed, these checks were extended to also be performed when fetching
into FETCH_HEAD for completeness, and add a test for that too.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
submodule.c
t/t5526-fetch-submodules.sh