silence git gc --auto --quiet output
[git/mjg.git] / t / t7403-submodule-sync.sh
blob524d5c1b21a507c5ed16edc52fb9353792b83f28
1 #!/bin/sh
3 # Copyright (c) 2008 David Aguilar
6 test_description='git submodule sync
8 These tests exercise the "git submodule sync" subcommand.
11 . ./test-lib.sh
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 git clone super empty-clone &&
28 (cd empty-clone && git submodule init) &&
29 git clone super top-only-clone &&
30 git clone super relative-clone &&
31 (cd relative-clone && git submodule update --init)
34 test_expect_success 'change submodule' '
35 (cd submodule &&
36 echo second line >> file &&
37 test_tick &&
38 git commit -a -m "change submodule"
42 test_expect_success 'change submodule url' '
43 (cd super &&
44 cd submodule &&
45 git checkout master &&
46 git pull
47 ) &&
48 mv submodule moved-submodule &&
49 (cd super &&
50 git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
51 test_tick &&
52 git commit -a -m moved-submodule
56 test_expect_success '"git submodule sync" should update submodule URLs' '
57 (cd super-clone &&
58 git pull --no-recurse-submodules &&
59 git submodule sync
60 ) &&
61 test -d "$(cd super-clone/submodule &&
62 git config remote.origin.url
63 )" &&
64 (cd super-clone/submodule &&
65 git checkout master &&
66 git pull
67 ) &&
68 (cd super-clone &&
69 test -d "$(git config submodule.submodule.url)"
73 test_expect_success '"git submodule sync" should update known submodule URLs' '
74 (cd empty-clone &&
75 git pull &&
76 git submodule sync &&
77 test -d "$(git config submodule.submodule.url)"
81 test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
82 (cd top-only-clone &&
83 git pull &&
84 git submodule sync &&
85 test -z "$(git config submodule.submodule.url)" &&
86 git submodule sync submodule &&
87 test -z "$(git config submodule.submodule.url)"
91 test_expect_success '"git submodule sync" handles origin URL of the form foo' '
92 (cd relative-clone &&
93 git remote set-url origin foo &&
94 git submodule sync &&
95 (cd submodule &&
96 #actual fails with: "cannot strip off url foo
97 test "$(git config remote.origin.url)" = "../submodule"
102 test_expect_success '"git submodule sync" handles origin URL of the form foo/bar' '
103 (cd relative-clone &&
104 git remote set-url origin foo/bar &&
105 git submodule sync &&
106 (cd submodule &&
107 #actual foo/submodule
108 test "$(git config remote.origin.url)" = "../foo/submodule"
113 test_expect_success '"git submodule sync" handles origin URL of the form ./foo' '
114 (cd relative-clone &&
115 git remote set-url origin ./foo &&
116 git submodule sync &&
117 (cd submodule &&
118 #actual ./submodule
119 test "$(git config remote.origin.url)" = "../submodule"
124 test_expect_success '"git submodule sync" handles origin URL of the form ./foo/bar' '
125 (cd relative-clone &&
126 git remote set-url origin ./foo/bar &&
127 git submodule sync &&
128 (cd submodule &&
129 #actual ./foo/submodule
130 test "$(git config remote.origin.url)" = "../foo/submodule"
135 test_expect_success '"git submodule sync" handles origin URL of the form ../foo' '
136 (cd relative-clone &&
137 git remote set-url origin ../foo &&
138 git submodule sync &&
139 (cd submodule &&
140 #actual ../submodule
141 test "$(git config remote.origin.url)" = "../../submodule"
146 test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar' '
147 (cd relative-clone &&
148 git remote set-url origin ../foo/bar &&
149 git submodule sync &&
150 (cd submodule &&
151 #actual ../foo/submodule
152 test "$(git config remote.origin.url)" = "../../foo/submodule"
157 test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' '
158 (cd relative-clone &&
159 git remote set-url origin ../foo/bar &&
160 mkdir -p a/b/c &&
161 ( cd a/b/c &&
162 git init &&
163 :> .gitignore &&
164 git add .gitignore &&
165 test_tick &&
166 git commit -m "initial commit" ) &&
167 git submodule add ../bar/a/b/c ./a/b/c &&
168 git submodule sync &&
169 (cd a/b/c &&
170 #actual ../foo/bar/a/b/c
171 test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
177 test_done