mirror of
https://github.com/git/git.git
synced 2024-11-12 20:23:02 +01:00
88a21979c5
To be able to access all commits of populated submodules referenced by the superproject it is sufficient to only then let "git fetch" recurse into a submodule when the new commits fetched in the superproject record new commits for it. Having these commits present is extremely useful when using the "--submodule" option to "git diff" (which is what "git gui" and "gitk" do since 1.6.6), as all submodule commits needed for creating a descriptive output can be accessed. Also merging submodule commits (added in 1.7.3) depends on the submodule commits in question being present to work. Last but not least this enables disconnected operation when using submodules, as all commits necessary for a successful "git submodule update -N" will have been fetched automatically. So we choose this mode as the default for fetch and pull. Before a new or changed ref from upstream is updated in update_local_ref() "git rev-list <new-sha1> --not --branches --remotes" is used to determine all newly fetched commits. These are then walked and diffed against their parent(s) to see if a submodule has been changed. If that is the case, its path is stored to be fetched after the superproject fetch is completed. Using the "--recurse-submodules" or the "--no-recurse-submodules" option disables the examination of the fetched refs because the result will be ignored anyway. There is currently no infrastructure for storing deleted and new submodules in the .git directory of the superproject. That's why fetch and pull for now only fetch submodules that are already checked out and are not renamed. In t7403 the "--no-recurse-submodules" argument had to be added to "git pull" to avoid failure because of the moved upstream submodule repo. Thanks-to: Jonathan Nieder <jrnieder@gmail.com> Thanks-to: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
77 lines
1.6 KiB
Bash
Executable file
77 lines
1.6 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2008 David Aguilar
|
|
#
|
|
|
|
test_description='git submodule sync
|
|
|
|
These tests exercise the "git submodule sync" subcommand.
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
echo file > file &&
|
|
git add file &&
|
|
test_tick &&
|
|
git commit -m upstream &&
|
|
git clone . super &&
|
|
git clone super submodule &&
|
|
(cd super &&
|
|
git submodule add ../submodule submodule &&
|
|
test_tick &&
|
|
git commit -m "submodule"
|
|
) &&
|
|
git clone super super-clone &&
|
|
(cd super-clone && git submodule update --init) &&
|
|
git clone super empty-clone &&
|
|
(cd empty-clone && git submodule init)
|
|
'
|
|
|
|
test_expect_success 'change submodule' '
|
|
(cd submodule &&
|
|
echo second line >> file &&
|
|
test_tick &&
|
|
git commit -a -m "change submodule"
|
|
)
|
|
'
|
|
|
|
test_expect_success 'change submodule url' '
|
|
(cd super &&
|
|
cd submodule &&
|
|
git checkout master &&
|
|
git pull
|
|
) &&
|
|
mv submodule moved-submodule &&
|
|
(cd super &&
|
|
git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
|
|
test_tick &&
|
|
git commit -a -m moved-submodule
|
|
)
|
|
'
|
|
|
|
test_expect_success '"git submodule sync" should update submodule URLs' '
|
|
(cd super-clone &&
|
|
git pull --no-recurse-submodules &&
|
|
git submodule sync
|
|
) &&
|
|
test -d "$(git config -f super-clone/submodule/.git/config \
|
|
remote.origin.url)" &&
|
|
(cd super-clone/submodule &&
|
|
git checkout master &&
|
|
git pull
|
|
) &&
|
|
(cd super-clone &&
|
|
test -d "$(git config submodule.submodule.url)"
|
|
)
|
|
'
|
|
|
|
test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' '
|
|
(cd empty-clone &&
|
|
git pull &&
|
|
git submodule sync &&
|
|
test -d "$(git config submodule.submodule.url)"
|
|
)
|
|
'
|
|
|
|
test_done
|