3 c8c71e6e 2020-03-21 stsp # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 c8c71e6e 2020-03-21 stsp # Permission to use, copy, modify, and distribute this software for any
6 c8c71e6e 2020-03-21 stsp # purpose with or without fee is hereby granted, provided that the above
7 c8c71e6e 2020-03-21 stsp # copyright notice and this permission notice appear in all copies.
9 c8c71e6e 2020-03-21 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c8c71e6e 2020-03-21 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c8c71e6e 2020-03-21 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c8c71e6e 2020-03-21 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c8c71e6e 2020-03-21 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c8c71e6e 2020-03-21 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c8c71e6e 2020-03-21 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 c8c71e6e 2020-03-21 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_clone_basic() {
20 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_basic`
21 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
22 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
24 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
26 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
27 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
28 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
32 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo
33 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
34 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
35 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
38 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
39 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
40 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
41 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
44 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
46 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
47 c8c71e6e 2020-03-21 stsp echo "log -p output of cloned repository differs" >&2
48 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
52 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo > $testroot/stdout
53 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
54 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
55 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
59 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
60 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
62 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
64 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
65 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
66 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
70 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
71 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
72 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
73 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
77 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
78 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
79 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
80 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
81 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
82 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
84 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
86 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
87 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
88 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
92 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
93 a9c2d4c2 2020-09-24 stsp remote "origin" {
94 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
95 a9c2d4c2 2020-09-24 stsp protocol ssh
96 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
99 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
101 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
102 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
103 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
104 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
108 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
110 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
111 a9c2d4c2 2020-09-24 stsp filemode = true
112 a9c2d4c2 2020-09-24 stsp bare = true
114 a9c2d4c2 2020-09-24 stsp [remote "origin"]
115 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
116 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
118 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
120 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
121 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
122 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
124 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
127 f6cae3ed 2020-09-13 naddy test_clone_list() {
128 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_list`
129 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
130 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
132 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
133 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
134 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
136 c8c71e6e 2020-03-21 stsp got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
138 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
139 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
140 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
144 d7c4e80d 2020-04-19 stsp echo "Connecting to 127.0.0.1" > $testroot/stdout.expected
145 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
147 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
149 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
150 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
152 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
155 f6cae3ed 2020-09-13 naddy test_clone_branch() {
156 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_branch`
157 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
158 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
160 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
161 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
162 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
163 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
164 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
166 c8c71e6e 2020-03-21 stsp got clone -q -b foo $testurl/repo $testroot/repo-clone
168 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
169 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
170 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
174 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
176 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
177 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
178 c8c71e6e 2020-03-21 stsp # refs/heads/master is missing because it wasn't passed via -b
179 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
180 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
181 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
183 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
185 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
186 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
187 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
191 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
192 a9c2d4c2 2020-09-24 stsp remote "origin" {
193 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
194 a9c2d4c2 2020-09-24 stsp protocol ssh
195 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
198 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
200 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
201 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
202 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
203 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
207 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
209 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
210 a9c2d4c2 2020-09-24 stsp filemode = true
211 a9c2d4c2 2020-09-24 stsp bare = true
213 a9c2d4c2 2020-09-24 stsp [remote "origin"]
214 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
215 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
217 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
219 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
220 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
221 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
223 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
226 f6cae3ed 2020-09-13 naddy test_clone_all() {
227 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_all`
228 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
229 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
231 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
232 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
233 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
234 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
235 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
237 c8c71e6e 2020-03-21 stsp got clone -q -a $testurl/repo $testroot/repo-clone
239 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
240 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
241 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
245 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
247 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
248 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
249 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
250 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
251 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
254 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
255 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
256 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
258 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
260 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
261 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
266 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
267 a9c2d4c2 2020-09-24 stsp remote "origin" {
268 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
269 a9c2d4c2 2020-09-24 stsp protocol ssh
270 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
273 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
275 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
276 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
277 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
278 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
282 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
284 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
285 a9c2d4c2 2020-09-24 stsp filemode = true
286 a9c2d4c2 2020-09-24 stsp bare = true
288 a9c2d4c2 2020-09-24 stsp [remote "origin"]
289 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
290 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/*:refs/remotes/origin/*
292 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
294 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
295 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
296 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
298 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
301 f6cae3ed 2020-09-13 naddy test_clone_mirror() {
302 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror`
303 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
304 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
306 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
307 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
308 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
309 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
310 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
312 c8c71e6e 2020-03-21 stsp got clone -q -m $testurl/repo $testroot/repo-clone
314 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
315 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
316 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
320 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
322 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
323 c8c71e6e 2020-03-21 stsp # refs/heads/foo is missing because we're not fetching all branches
324 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
325 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
326 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
328 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
330 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
331 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
336 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
337 a9c2d4c2 2020-09-24 stsp remote "origin" {
338 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
339 a9c2d4c2 2020-09-24 stsp protocol ssh
340 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
341 a9c2d4c2 2020-09-24 stsp mirror-references yes
344 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
346 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
347 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
348 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
349 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
353 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
355 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
356 a9c2d4c2 2020-09-24 stsp filemode = true
357 a9c2d4c2 2020-09-24 stsp bare = true
359 a9c2d4c2 2020-09-24 stsp [remote "origin"]
360 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
361 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
362 a9c2d4c2 2020-09-24 stsp mirror = true
364 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
366 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
367 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
368 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
370 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
373 f6cae3ed 2020-09-13 naddy test_clone_mirror_all() {
374 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror_all`
375 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
376 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
378 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
379 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
380 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
381 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
382 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
384 c8c71e6e 2020-03-21 stsp got clone -q -m -a $testurl/repo $testroot/repo-clone
386 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
387 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
388 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
392 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
394 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
395 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
396 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
397 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
398 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
400 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
402 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
403 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
408 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
409 a9c2d4c2 2020-09-24 stsp remote "origin" {
410 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
411 a9c2d4c2 2020-09-24 stsp protocol ssh
412 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
413 a9c2d4c2 2020-09-24 stsp mirror-references yes
416 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
418 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
419 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
420 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
421 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
425 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
427 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
428 a9c2d4c2 2020-09-24 stsp filemode = true
429 a9c2d4c2 2020-09-24 stsp bare = true
431 a9c2d4c2 2020-09-24 stsp [remote "origin"]
432 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
433 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
434 a9c2d4c2 2020-09-24 stsp mirror = true
436 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
438 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
439 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
440 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
442 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
445 f6cae3ed 2020-09-13 naddy test_clone_reference() {
446 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
447 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
448 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
450 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
451 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
452 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
453 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
454 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
456 0e4002ca 2020-03-21 stsp got clone -q -R hoo $testurl/repo $testroot/repo-clone
458 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
459 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
460 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
464 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
466 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
467 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
468 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
469 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
470 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
471 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
472 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
473 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
474 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
476 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
478 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
479 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
484 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
485 a9c2d4c2 2020-09-24 stsp remote "origin" {
486 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
487 a9c2d4c2 2020-09-24 stsp protocol ssh
488 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
491 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
493 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
494 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
495 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
496 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
500 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
502 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
503 a9c2d4c2 2020-09-24 stsp filemode = true
504 a9c2d4c2 2020-09-24 stsp bare = true
506 a9c2d4c2 2020-09-24 stsp [remote "origin"]
507 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
508 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
510 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
512 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
513 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
514 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
516 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
519 f6cae3ed 2020-09-13 naddy test_clone_branch_and_reference() {
520 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
521 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
522 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
524 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
525 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
526 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
527 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
528 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
530 0e4002ca 2020-03-21 stsp got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
532 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
533 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
534 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
538 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
540 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
541 0e4002ca 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
542 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
543 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
544 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
545 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
546 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
548 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
550 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
551 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
552 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
556 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
557 a9c2d4c2 2020-09-24 stsp remote "origin" {
558 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
559 a9c2d4c2 2020-09-24 stsp protocol ssh
560 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
563 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
565 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
566 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
567 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
568 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
572 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
574 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
575 a9c2d4c2 2020-09-24 stsp filemode = true
576 a9c2d4c2 2020-09-24 stsp bare = true
578 a9c2d4c2 2020-09-24 stsp [remote "origin"]
579 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
580 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
582 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
584 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
585 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
586 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
588 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
591 f6cae3ed 2020-09-13 naddy test_clone_reference_mirror() {
592 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference_mirror`
593 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
594 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
596 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
597 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
598 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
599 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
600 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
602 0e4002ca 2020-03-21 stsp got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
604 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
605 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
606 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
610 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
612 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
613 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
614 0e4002ca 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
615 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
617 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
619 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
620 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
625 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
626 a9c2d4c2 2020-09-24 stsp remote "origin" {
627 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
628 a9c2d4c2 2020-09-24 stsp protocol ssh
629 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
630 a9c2d4c2 2020-09-24 stsp mirror-references yes
633 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
635 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
636 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
637 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
638 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
642 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
644 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
645 a9c2d4c2 2020-09-24 stsp filemode = true
646 a9c2d4c2 2020-09-24 stsp bare = true
648 a9c2d4c2 2020-09-24 stsp [remote "origin"]
649 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
650 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
651 a9c2d4c2 2020-09-24 stsp mirror = true
653 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
655 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
656 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
657 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
659 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
662 7fb414ae 2020-08-08 stsp test_parseargs "$@"
663 c8c71e6e 2020-03-21 stsp run_test test_clone_basic
664 c8c71e6e 2020-03-21 stsp run_test test_clone_list
665 c8c71e6e 2020-03-21 stsp run_test test_clone_branch
666 c8c71e6e 2020-03-21 stsp run_test test_clone_all
667 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror
668 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror_all
669 0e4002ca 2020-03-21 stsp run_test test_clone_reference
670 0e4002ca 2020-03-21 stsp run_test test_clone_branch_and_reference
671 0e4002ca 2020-03-21 stsp run_test test_clone_reference_mirror