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"
97 15d3c221 2021-01-05 stsp branch { "master" }
100 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
102 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
103 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
104 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
105 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
109 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
111 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
112 a9c2d4c2 2020-09-24 stsp filemode = true
113 a9c2d4c2 2020-09-24 stsp bare = true
115 a9c2d4c2 2020-09-24 stsp [remote "origin"]
116 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
117 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
119 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
121 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
122 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
123 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
125 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
128 f6cae3ed 2020-09-13 naddy test_clone_list() {
129 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_list`
130 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
131 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
133 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
134 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
135 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
137 c8c71e6e 2020-03-21 stsp got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
139 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
140 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
141 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
145 d7c4e80d 2020-04-19 stsp echo "Connecting to 127.0.0.1" > $testroot/stdout.expected
146 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
148 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
150 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
151 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
156 f6cae3ed 2020-09-13 naddy test_clone_branch() {
157 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_branch`
158 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
159 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
161 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
162 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
163 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
164 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
165 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
167 c8c71e6e 2020-03-21 stsp got clone -q -b foo $testurl/repo $testroot/repo-clone
169 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
170 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
171 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
175 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
177 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
178 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
179 c8c71e6e 2020-03-21 stsp # refs/heads/master is missing because it wasn't passed via -b
180 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
181 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
182 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
184 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
186 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
187 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
188 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
192 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
193 a9c2d4c2 2020-09-24 stsp remote "origin" {
194 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
195 a9c2d4c2 2020-09-24 stsp protocol ssh
196 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
197 15d3c221 2021-01-05 stsp branch { "foo" }
200 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
202 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
203 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
204 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
205 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
209 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
211 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
212 a9c2d4c2 2020-09-24 stsp filemode = true
213 a9c2d4c2 2020-09-24 stsp bare = true
215 a9c2d4c2 2020-09-24 stsp [remote "origin"]
216 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
217 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
219 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
221 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
222 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
223 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
225 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
228 f6cae3ed 2020-09-13 naddy test_clone_all() {
229 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_all`
230 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
231 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
233 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
234 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
235 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
236 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
237 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
239 c8c71e6e 2020-03-21 stsp got clone -q -a $testurl/repo $testroot/repo-clone
241 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
242 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
243 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
247 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
249 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
250 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
251 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
252 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
253 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
254 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
255 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
256 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
257 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
258 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
260 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
262 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
263 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
264 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
268 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
269 a9c2d4c2 2020-09-24 stsp remote "origin" {
270 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
271 a9c2d4c2 2020-09-24 stsp protocol ssh
272 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
273 15d3c221 2021-01-05 stsp branch { "master" }
276 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
278 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
279 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
280 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
281 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
285 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
287 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
288 a9c2d4c2 2020-09-24 stsp filemode = true
289 a9c2d4c2 2020-09-24 stsp bare = true
291 a9c2d4c2 2020-09-24 stsp [remote "origin"]
292 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
293 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/*:refs/remotes/origin/*
295 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
297 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
298 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
299 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
301 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
304 f6cae3ed 2020-09-13 naddy test_clone_mirror() {
305 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror`
306 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
307 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
309 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
310 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
311 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
312 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
313 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
315 c8c71e6e 2020-03-21 stsp got clone -q -m $testurl/repo $testroot/repo-clone
317 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
318 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
319 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
323 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
325 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
326 c8c71e6e 2020-03-21 stsp # refs/heads/foo is missing because we're not fetching all branches
327 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
328 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
329 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
331 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
333 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
334 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
335 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
339 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
340 a9c2d4c2 2020-09-24 stsp remote "origin" {
341 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
342 a9c2d4c2 2020-09-24 stsp protocol ssh
343 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
344 15d3c221 2021-01-05 stsp branch { "master" }
345 a9c2d4c2 2020-09-24 stsp mirror-references yes
348 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
350 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
351 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
352 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
353 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
357 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
359 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
360 a9c2d4c2 2020-09-24 stsp filemode = true
361 a9c2d4c2 2020-09-24 stsp bare = true
363 a9c2d4c2 2020-09-24 stsp [remote "origin"]
364 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
365 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
366 a9c2d4c2 2020-09-24 stsp mirror = true
368 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
370 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
371 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
372 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
374 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
377 f6cae3ed 2020-09-13 naddy test_clone_mirror_all() {
378 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror_all`
379 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
380 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
382 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
383 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
384 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
385 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
386 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
388 c8c71e6e 2020-03-21 stsp got clone -q -m -a $testurl/repo $testroot/repo-clone
390 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
391 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
392 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
396 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
398 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
399 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
400 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
401 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
402 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
404 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
406 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
407 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
412 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
413 a9c2d4c2 2020-09-24 stsp remote "origin" {
414 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
415 a9c2d4c2 2020-09-24 stsp protocol ssh
416 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
417 15d3c221 2021-01-05 stsp branch { "master" }
418 a9c2d4c2 2020-09-24 stsp mirror-references yes
421 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
423 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
424 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
425 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
426 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
430 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
432 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
433 a9c2d4c2 2020-09-24 stsp filemode = true
434 a9c2d4c2 2020-09-24 stsp bare = true
436 a9c2d4c2 2020-09-24 stsp [remote "origin"]
437 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
438 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
439 a9c2d4c2 2020-09-24 stsp mirror = true
441 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
443 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
444 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
445 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
447 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
450 f6cae3ed 2020-09-13 naddy test_clone_reference() {
451 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
452 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
453 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
455 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
456 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
457 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
458 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
459 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
461 0e4002ca 2020-03-21 stsp got clone -q -R hoo $testurl/repo $testroot/repo-clone
463 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
464 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
465 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
469 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
471 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
472 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
473 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
474 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
475 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
476 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
477 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
478 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
479 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
481 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
483 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
484 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
485 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
489 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
490 a9c2d4c2 2020-09-24 stsp remote "origin" {
491 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
492 a9c2d4c2 2020-09-24 stsp protocol ssh
493 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
494 15d3c221 2021-01-05 stsp branch { "master" }
497 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
499 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
500 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
501 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
502 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
506 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
508 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
509 a9c2d4c2 2020-09-24 stsp filemode = true
510 a9c2d4c2 2020-09-24 stsp bare = true
512 a9c2d4c2 2020-09-24 stsp [remote "origin"]
513 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
514 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
516 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
518 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
519 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
520 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
522 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
525 f6cae3ed 2020-09-13 naddy test_clone_branch_and_reference() {
526 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
527 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
528 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
530 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
531 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
532 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
533 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
534 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
536 0e4002ca 2020-03-21 stsp got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
538 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
539 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
540 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
544 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
546 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
547 0e4002ca 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
548 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
549 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
550 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
551 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
552 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
554 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
556 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
557 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
558 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
562 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
563 a9c2d4c2 2020-09-24 stsp remote "origin" {
564 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
565 a9c2d4c2 2020-09-24 stsp protocol ssh
566 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
567 15d3c221 2021-01-05 stsp branch { "foo" }
570 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
572 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
573 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
574 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
575 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
579 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
581 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
582 a9c2d4c2 2020-09-24 stsp filemode = true
583 a9c2d4c2 2020-09-24 stsp bare = true
585 a9c2d4c2 2020-09-24 stsp [remote "origin"]
586 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
587 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
589 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
591 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
592 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
593 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
595 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
598 f6cae3ed 2020-09-13 naddy test_clone_reference_mirror() {
599 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference_mirror`
600 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
601 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
603 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
604 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
605 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
606 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
607 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
609 0e4002ca 2020-03-21 stsp got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
611 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
612 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
613 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
617 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
619 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
620 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
621 0e4002ca 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
622 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
624 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
626 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
627 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
628 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
632 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
633 a9c2d4c2 2020-09-24 stsp remote "origin" {
634 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
635 a9c2d4c2 2020-09-24 stsp protocol ssh
636 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
637 15d3c221 2021-01-05 stsp branch { "master" }
638 a9c2d4c2 2020-09-24 stsp mirror-references yes
641 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
643 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
644 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
645 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
646 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
650 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
652 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
653 a9c2d4c2 2020-09-24 stsp filemode = true
654 a9c2d4c2 2020-09-24 stsp bare = true
656 a9c2d4c2 2020-09-24 stsp [remote "origin"]
657 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
658 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
659 a9c2d4c2 2020-09-24 stsp mirror = true
661 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
663 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
664 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
665 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
667 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
670 7fb414ae 2020-08-08 stsp test_parseargs "$@"
671 c8c71e6e 2020-03-21 stsp run_test test_clone_basic
672 c8c71e6e 2020-03-21 stsp run_test test_clone_list
673 c8c71e6e 2020-03-21 stsp run_test test_clone_branch
674 c8c71e6e 2020-03-21 stsp run_test test_clone_all
675 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror
676 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror_all
677 0e4002ca 2020-03-21 stsp run_test test_clone_reference
678 0e4002ca 2020-03-21 stsp run_test test_clone_branch_and_reference
679 0e4002ca 2020-03-21 stsp run_test test_clone_reference_mirror