Skip to content

Commit

Permalink
Add tests for submodule sync --recursive
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Hord <hordp@cisco.com>
Acked-By: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
Phil Hord authored and Jeff King committed Oct 29, 2012
1 parent 82f49f2 commit 44fa0ef
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions t/t7403-submodule-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@ test_expect_success setup '
git commit -m upstream &&
git clone . super &&
git clone super submodule &&
(cd submodule &&
git submodule add ../submodule sub-submodule &&
test_tick &&
git commit -m "sub-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) &&
(cd super-clone && git submodule update --init --recursive) &&
git clone super empty-clone &&
(cd empty-clone && git submodule init) &&
git clone super top-only-clone &&
git clone super relative-clone &&
(cd relative-clone && git submodule update --init)
(cd relative-clone && git submodule update --init --recursive) &&
git clone super recursive-clone &&
(cd recursive-clone && git submodule update --init --recursive)
'

test_expect_success 'change submodule' '
Expand All @@ -46,6 +53,11 @@ test_expect_success 'change submodule url' '
git pull
) &&
mv submodule moved-submodule &&
(cd moved-submodule &&
git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
test_tick &&
git commit -a -m moved-sub-submodule
) &&
(cd super &&
git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
test_tick &&
Expand All @@ -61,6 +73,9 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
test -d "$(cd super-clone/submodule &&
git config remote.origin.url
)" &&
test ! -d "$(cd super-clone/submodule/sub-submodule &&
git config remote.origin.url
)" &&
(cd super-clone/submodule &&
git checkout master &&
git pull
Expand All @@ -70,6 +85,25 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
)
'

test_expect_success '"git submodule sync --recursive" should update all submodule URLs' '
(cd super-clone &&
(cd submodule &&
git pull --no-recurse-submodules
) &&
git submodule sync --recursive
) &&
test -d "$(cd super-clone/submodule &&
git config remote.origin.url
)" &&
test -d "$(cd super-clone/submodule/sub-submodule &&
git config remote.origin.url
)" &&
(cd super-clone/submodule/sub-submodule &&
git checkout master &&
git pull
)
'

test_expect_success '"git submodule sync" should update known submodule URLs' '
(cd empty-clone &&
git pull &&
Expand Down Expand Up @@ -107,6 +141,23 @@ test_expect_success '"git submodule sync" handles origin URL of the form foo/bar
#actual foo/submodule
test "$(git config remote.origin.url)" = "../foo/submodule"
)
(cd submodule/sub-submodule &&
test "$(git config remote.origin.url)" != "../../foo/submodule"
)
)
'

test_expect_success '"git submodule sync --recursive" propagates changes in origin' '
(cd recursive-clone &&
git remote set-url origin foo/bar &&
git submodule sync --recursive &&
(cd submodule &&
#actual foo/submodule
test "$(git config remote.origin.url)" = "../foo/submodule"
)
(cd submodule/sub-submodule &&
test "$(git config remote.origin.url)" = "../../foo/submodule"
)
)
'

Expand Down

0 comments on commit 44fa0ef

Please sign in to comment.