-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add selftest for 'git submodule foreach'
The selftest verifies that: - only checked out submodules are visited by 'git submodule foreach' - the $path, and $sha1 variables are set correctly for each submodule Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Johan Herland
authored and
Junio C Hamano
committed
Aug 19, 2009
1 parent
1d5bec8
commit d69ecf6
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2009 Johan Herland | ||
# | ||
|
||
test_description='Test "git submodule foreach" | ||
This test verifies that "git submodule foreach" correctly visits all submodules | ||
that are currently checked out. | ||
' | ||
|
||
. ./test-lib.sh | ||
|
||
|
||
test_expect_success 'setup a submodule tree' ' | ||
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 sub1 && | ||
git submodule add ../submodule sub2 && | ||
git submodule add ../submodule sub3 && | ||
git config -f .gitmodules --rename-section \ | ||
submodule.sub1 submodule.foo1 && | ||
git config -f .gitmodules --rename-section \ | ||
submodule.sub2 submodule.foo2 && | ||
git config -f .gitmodules --rename-section \ | ||
submodule.sub3 submodule.foo3 && | ||
git add .gitmodules | ||
test_tick && | ||
git commit -m "submodules" && | ||
git submodule init sub1 && | ||
git submodule init sub2 && | ||
git submodule init sub3 | ||
) && | ||
( | ||
cd submodule && | ||
echo different > file && | ||
git add file && | ||
test_tick && | ||
git commit -m "different" | ||
) && | ||
( | ||
cd super && | ||
( | ||
cd sub3 && | ||
git pull | ||
) && | ||
git add sub3 && | ||
test_tick && | ||
git commit -m "update sub3" | ||
) | ||
' | ||
|
||
sub1sha1=$(cd super/sub1 && git rev-parse HEAD) | ||
sub3sha1=$(cd super/sub3 && git rev-parse HEAD) | ||
|
||
cat > expect <<EOF | ||
Entering 'sub1' | ||
sub1-$sub1sha1 | ||
Entering 'sub3' | ||
sub3-$sub3sha1 | ||
EOF | ||
|
||
test_expect_success 'test basic "submodule foreach" usage' ' | ||
git clone super clone && | ||
( | ||
cd clone && | ||
git submodule update --init -- sub1 sub3 && | ||
git submodule foreach "echo \$path-\$sha1" > ../actual | ||
) && | ||
test_cmp expect actual | ||
' | ||
|
||
test_done |