Add tests for submodule sync --recursive

Signed-off-by: Phil Hord <hordp@cisco.com> Acked-By: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Jeff King <peff@peff.net>

Phil Hord committed Oct 26, 2012 at 15:44 UTC 44fa0ef58c9e323ab8824cbbc49417e0586de71b
1 file changed +53 -2
t/t7403-submodule-sync.sh
+53 -2
@@ -17,18 +17,25 @@ test_expect_success setup '
17 git commit -m upstream &&
18 git clone . super &&
19 git clone super submodule &&
20 + (cd submodule &&
21 + git submodule add ../submodule sub-submodule &&
22 + test_tick &&
23 + git commit -m "sub-submodule"
24 + ) &&
25 (cd super &&
26 git submodule add ../submodule submodule &&
27 test_tick &&
28 git commit -m "submodule"
29 ) &&
30 git clone super super-clone &&
26 - (cd super-clone && git submodule update --init) &&
31 + (cd super-clone && git submodule update --init --recursive) &&
32 git clone super empty-clone &&
33 (cd empty-clone && git submodule init) &&
34 git clone super top-only-clone &&
35 git clone super relative-clone &&
31 - (cd relative-clone && git submodule update --init)
36 + (cd relative-clone && git submodule update --init --recursive) &&
37 + git clone super recursive-clone &&
38 + (cd recursive-clone && git submodule update --init --recursive)
39 '
40
41 test_expect_success 'change submodule' '
@@ -46,6 +53,11 @@ test_expect_success 'change submodule url' '
53 git pull
54 ) &&
55 mv submodule moved-submodule &&
56 + (cd moved-submodule &&
57 + git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
58 + test_tick &&
59 + git commit -a -m moved-sub-submodule
60 + ) &&
61 (cd super &&
62 git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
63 test_tick &&
@@ -61,6 +73,9 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
73 test -d "$(cd super-clone/submodule &&
74 git config remote.origin.url
75 )" &&
76 + test ! -d "$(cd super-clone/submodule/sub-submodule &&
77 + git config remote.origin.url
78 + )" &&
79 (cd super-clone/submodule &&
80 git checkout master &&
81 git pull
@@ -70,6 +85,25 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
85 )
86 '
87
88 +test_expect_success '"git submodule sync --recursive" should update all submodule URLs' '
89 + (cd super-clone &&
90 + (cd submodule &&
91 + git pull --no-recurse-submodules
92 + ) &&
93 + git submodule sync --recursive
94 + ) &&
95 + test -d "$(cd super-clone/submodule &&
96 + git config remote.origin.url
97 + )" &&
98 + test -d "$(cd super-clone/submodule/sub-submodule &&
99 + git config remote.origin.url
100 + )" &&
101 + (cd super-clone/submodule/sub-submodule &&
102 + git checkout master &&
103 + git pull
104 + )
105 +'
106 +
107 test_expect_success '"git submodule sync" should update known submodule URLs' '
108 (cd empty-clone &&
109 git pull &&
@@ -107,6 +141,23 @@ test_expect_success '"git submodule sync" handles origin URL of the form foo/bar
141 #actual foo/submodule
142 test "$(git config remote.origin.url)" = "../foo/submodule"
143 )
144 + (cd submodule/sub-submodule &&
145 + test "$(git config remote.origin.url)" != "../../foo/submodule"
146 + )
147 + )
148 +'
149 +
150 +test_expect_success '"git submodule sync --recursive" propagates changes in origin' '
151 + (cd recursive-clone &&
152 + git remote set-url origin foo/bar &&
153 + git submodule sync --recursive &&
154 + (cd submodule &&
155 + #actual foo/submodule
156 + test "$(git config remote.origin.url)" = "../foo/submodule"
157 + )
158 + (cd submodule/sub-submodule &&
159 + test "$(git config remote.origin.url)" = "../../foo/submodule"
160 + )
161 )
162 '
163