Browse Source
Until now you had to call "git submodule update" (without -N|--no-fetch option) or something like "git submodule foreach git fetch" to fetch new commits in populated submodules from their remote. This could lead to "(commits not present)" messages in the output of "git diff --submodule" (which is used by "git gui" and "gitk") after fetching or pulling new commits in the superproject and is an obstacle for implementing recursive checkout of submodules. Also "git submodule update" cannot fetch changes when disconnected, so it was very easy to forget to fetch the submodule changes before disconnecting only to discover later that they are needed. This patch adds the "--recurse-submodules" option to recursively fetch each populated submodule from the url configured in the .git/config of the submodule at the end of each "git fetch" or during "git pull" in the superproject. The submodule paths are taken from the index. The hidden option "--submodule-prefix" is added to "git fetch" to be able to print out the full paths of nested submodules. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
Jens Lehmann
14 years ago
committed by
Junio C Hamano
6 changed files with 231 additions and 17 deletions
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
#!/bin/sh |
||||
# Copyright (c) 2010, Jens Lehmann |
||||
|
||||
test_description='Recursive "git fetch" for submodules' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
pwd=$(pwd) |
||||
|
||||
add_upstream_commit() { |
||||
( |
||||
cd submodule && |
||||
head1=$(git rev-parse --short HEAD) && |
||||
echo new >> subfile && |
||||
test_tick && |
||||
git add subfile && |
||||
git commit -m new subfile && |
||||
head2=$(git rev-parse --short HEAD) && |
||||
echo "From $pwd/submodule" > ../expect.err && |
||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err |
||||
) && |
||||
( |
||||
cd deepsubmodule && |
||||
head1=$(git rev-parse --short HEAD) && |
||||
echo new >> deepsubfile && |
||||
test_tick && |
||||
git add deepsubfile && |
||||
git commit -m new deepsubfile && |
||||
head2=$(git rev-parse --short HEAD) && |
||||
echo "From $pwd/deepsubmodule" >> ../expect.err && |
||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err |
||||
) |
||||
} |
||||
|
||||
test_expect_success setup ' |
||||
mkdir deepsubmodule && |
||||
( |
||||
cd deepsubmodule && |
||||
git init && |
||||
echo deepsubcontent > deepsubfile && |
||||
git add deepsubfile && |
||||
git commit -m new deepsubfile |
||||
) && |
||||
mkdir submodule && |
||||
( |
||||
cd submodule && |
||||
git init && |
||||
echo subcontent > subfile && |
||||
git add subfile && |
||||
git submodule add "$pwd/deepsubmodule" deepsubmodule && |
||||
git commit -a -m new |
||||
) && |
||||
git submodule add "$pwd/submodule" submodule && |
||||
git commit -am initial && |
||||
git clone . downstream && |
||||
( |
||||
cd downstream && |
||||
git submodule update --init --recursive |
||||
) && |
||||
echo "Fetching submodule submodule" > expect.out && |
||||
echo "Fetching submodule submodule/deepsubmodule" >> expect.out |
||||
' |
||||
|
||||
test_expect_success "fetch --recurse-submodules recurses into submodules" ' |
||||
add_upstream_commit && |
||||
( |
||||
cd downstream && |
||||
git fetch --recurse-submodules >../actual.out 2>../actual.err |
||||
) && |
||||
test_cmp expect.out actual.out && |
||||
test_cmp expect.err actual.err |
||||
' |
||||
|
||||
test_expect_success "fetch alone only fetches superproject" ' |
||||
add_upstream_commit && |
||||
( |
||||
cd downstream && |
||||
git fetch >../actual.out 2>../actual.err |
||||
) && |
||||
! test -s actual.out && |
||||
! test -s actual.err |
||||
' |
||||
|
||||
test_expect_success "--quiet propagates to submodules" ' |
||||
( |
||||
cd downstream && |
||||
git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err |
||||
) && |
||||
! test -s actual.out && |
||||
! test -s actual.err |
||||
' |
||||
|
||||
test_expect_success "--dry-run propagates to submodules" ' |
||||
add_upstream_commit && |
||||
( |
||||
cd downstream && |
||||
git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err |
||||
) && |
||||
test_cmp expect.out actual.out && |
||||
test_cmp expect.err actual.err && |
||||
( |
||||
cd downstream && |
||||
git fetch --recurse-submodules >../actual.out 2>../actual.err |
||||
) && |
||||
test_cmp expect.out actual.out && |
||||
test_cmp expect.err actual.err |
||||
' |
||||
|
||||
test_done |
Loading…
Reference in new issue