Skip to content

Commit 52e8370

Browse files
davvidspearce
authored andcommitted
tests: add a testcase for "git submodule sync"
This testcase ensures that upstream changes to submodule properties can be updated using the sync subcommand. This particular test changes the submodule URL upstream and uses the sync command to update an existing checkout. Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent bf8f2ad commit 52e8370

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

t/t7403-submodule-sync.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2008 David Aguilar
4+
#
5+
6+
test_description='git submodule sync
7+
8+
These tests exercise the "git submodule sync" subcommand.
9+
'
10+
11+
. ./test-lib.sh
12+
13+
test_expect_success setup '
14+
echo file > file &&
15+
git add file &&
16+
test_tick &&
17+
git commit -m upstream
18+
git clone . super &&
19+
git clone super submodule &&
20+
(cd super &&
21+
git submodule add ../submodule submodule &&
22+
test_tick &&
23+
git commit -m "submodule"
24+
) &&
25+
git clone super super-clone &&
26+
(cd super-clone && git submodule update --init)
27+
'
28+
29+
test_expect_success 'change submodule' '
30+
(cd submodule &&
31+
echo second line >> file &&
32+
test_tick &&
33+
git commit -a -m "change submodule"
34+
)
35+
'
36+
37+
test_expect_success 'change submodule url' '
38+
(cd super &&
39+
cd submodule &&
40+
git checkout master &&
41+
git pull
42+
) &&
43+
mv submodule moved-submodule &&
44+
(cd super &&
45+
git config -f .gitmodules submodule.submodule.url ../moved-submodule
46+
test_tick &&
47+
git commit -a -m moved-submodule
48+
)
49+
'
50+
51+
test_expect_success '"git submodule sync" should update submodule URLs' '
52+
(cd super-clone &&
53+
git pull &&
54+
git submodule sync
55+
) &&
56+
test -d "$(git config -f super-clone/submodule/.git/config \
57+
remote.origin.url)" &&
58+
(cd super-clone/submodule &&
59+
git checkout master &&
60+
git pull
61+
)
62+
'
63+
64+
test_done

0 commit comments

Comments
 (0)