3 # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot=`test_init clone_basic`
21 local testurl=ssh://127.0.0.1/$testroot
22 local commit_id=`git_show_head $testroot/repo`
24 got clone -q $testurl/repo $testroot/repo-clone
26 if [ $ret -ne 0 ]; then
27 echo "got clone command failed unexpectedly" >&2
28 test_done "$testroot" "$ret"
32 got log -l0 -p -r $testroot/repo > $testroot/log-repo
34 if [ $ret -ne 0 ]; then
35 echo "got log command failed unexpectedly" >&2
36 test_done "$testroot" "$ret"
39 got log -l0 -p -r $testroot/repo-clone | \
40 sed 's@master, origin/master@master@g' \
41 > $testroot/log-repo-clone
43 cmp -s $testroot/log-repo $testroot/log-repo-clone
45 if [ $ret -ne 0 ]; then
46 echo "log -p output of cloned repository differs" >&2
47 test_done "$testroot" "$ret"
51 got ref -l -r $testroot/repo > $testroot/stdout
53 if [ $ret -ne 0 ]; then
54 echo "got ref command failed unexpectedly" >&2
55 test_done "$testroot" "$ret"
59 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
60 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
62 cmp -s $testroot/stdout $testroot/stdout.expected
64 if [ $ret -ne 0 ]; then
65 diff -u $testroot/stdout.expected $testroot/stdout
66 test_done "$testroot" "$ret"
70 got ref -l -r $testroot/repo-clone > $testroot/stdout
72 if [ $ret -ne 0 ]; then
73 echo "got ref command failed unexpectedly" >&2
74 test_done "$testroot" "$ret"
78 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
79 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
80 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
81 >> $testroot/stdout.expected
82 echo "refs/remotes/origin/master: $commit_id" \
83 >> $testroot/stdout.expected
85 cmp -s $testroot/stdout $testroot/stdout.expected
87 if [ $ret -ne 0 ]; then
88 diff -u $testroot/stdout.expected $testroot/stdout
89 test_done "$testroot" "$ret"
93 cat > $testroot/got.conf.expected <<EOF
97 repository "$testroot/repo"
101 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
103 if [ $ret -ne 0 ]; then
104 diff -u $testroot/got.conf.expected \
105 $testroot/repo-clone/got.conf
106 test_done "$testroot" "$ret"
110 cat > $testroot/config.expected <<EOF
112 repositoryformatversion = 0
117 url = ssh://127.0.0.1$testroot/repo
118 fetch = refs/heads/master:refs/remotes/origin/master
119 fetch = refs/tags/*:refs/tags/*
121 cmp -s $testroot/repo-clone/config $testroot/config.expected
123 if [ $ret -ne 0 ]; then
124 diff -u $testroot/config.expected \
125 $testroot/repo-clone/config
127 test_done "$testroot" "$ret"
131 local testroot=`test_init clone_list`
132 local testurl=ssh://127.0.0.1$testroot
133 local commit_id=`git_show_head $testroot/repo`
135 got branch -r $testroot/repo -c $commit_id foo
136 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
137 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
139 got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
141 if [ $ret -ne 0 ]; then
142 echo "got clone command failed unexpectedly" >&2
143 test_done "$testroot" "$ret"
147 echo "Connecting to $testurl/repo" > $testroot/stdout.expected
148 got ref -l -r $testroot/repo >> $testroot/stdout.expected
150 cmp -s $testroot/stdout $testroot/stdout.expected
152 if [ $ret -ne 0 ]; then
153 diff -u $testroot/stdout.expected $testroot/stdout
155 test_done "$testroot" "$ret"
158 test_clone_branch() {
159 local testroot=`test_init clone_branch`
160 local testurl=ssh://127.0.0.1/$testroot
161 local commit_id=`git_show_head $testroot/repo`
163 got branch -r $testroot/repo -c $commit_id foo
164 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
165 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
166 local tag_id=`got ref -r $testroot/repo -l \
167 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
169 got clone -q -b foo $testurl/repo $testroot/repo-clone
171 if [ $ret -ne 0 ]; then
172 echo "got clone command failed unexpectedly" >&2
173 test_done "$testroot" "$ret"
177 got ref -l -r $testroot/repo-clone > $testroot/stdout
179 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
180 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
181 # refs/heads/master is missing because it wasn't passed via -b
182 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
183 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
184 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
186 cmp -s $testroot/stdout $testroot/stdout.expected
188 if [ $ret -ne 0 ]; then
189 diff -u $testroot/stdout.expected $testroot/stdout
190 test_done "$testroot" "$ret"
194 cat > $testroot/got.conf.expected <<EOF
198 repository "$testroot/repo"
202 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
204 if [ $ret -ne 0 ]; then
205 diff -u $testroot/got.conf.expected \
206 $testroot/repo-clone/got.conf
207 test_done "$testroot" "$ret"
211 cat > $testroot/config.expected <<EOF
213 repositoryformatversion = 0
218 url = ssh://127.0.0.1$testroot/repo
219 fetch = refs/heads/foo:refs/remotes/origin/foo
220 fetch = refs/tags/*:refs/tags/*
222 cmp -s $testroot/repo-clone/config $testroot/config.expected
224 if [ $ret -ne 0 ]; then
225 diff -u $testroot/config.expected \
226 $testroot/repo-clone/config
228 test_done "$testroot" "$ret"
232 local testroot=`test_init clone_all`
233 local testurl=ssh://127.0.0.1/$testroot
234 local commit_id=`git_show_head $testroot/repo`
236 got branch -r $testroot/repo -c $commit_id foo
237 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
238 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
239 local tag_id=`got ref -r $testroot/repo -l \
240 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
242 got clone -q -a $testurl/repo $testroot/repo-clone
244 if [ $ret -ne 0 ]; then
245 echo "got clone command failed unexpectedly" >&2
246 test_done "$testroot" "$ret"
250 got ref -l -r $testroot/repo-clone > $testroot/stdout
252 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
253 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
254 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
255 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
256 >> $testroot/stdout.expected
257 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
258 echo "refs/remotes/origin/master: $commit_id" \
259 >> $testroot/stdout.expected
260 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
261 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
263 cmp -s $testroot/stdout $testroot/stdout.expected
265 if [ $ret -ne 0 ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
267 test_done "$testroot" "$ret"
271 cat > $testroot/got.conf.expected <<EOF
275 repository "$testroot/repo"
276 fetch_all_branches yes
279 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
281 if [ $ret -ne 0 ]; then
282 diff -u $testroot/got.conf.expected \
283 $testroot/repo-clone/got.conf
284 test_done "$testroot" "$ret"
288 cat > $testroot/config.expected <<EOF
290 repositoryformatversion = 0
295 url = ssh://127.0.0.1$testroot/repo
296 fetch = refs/heads/*:refs/remotes/origin/*
297 fetch = refs/tags/*:refs/tags/*
299 cmp -s $testroot/repo-clone/config $testroot/config.expected
301 if [ $ret -ne 0 ]; then
302 diff -u $testroot/config.expected \
303 $testroot/repo-clone/config
305 test_done "$testroot" "$ret"
308 test_clone_mirror() {
309 local testroot=`test_init clone_mirror`
310 local testurl=ssh://127.0.0.1/$testroot
311 local commit_id=`git_show_head $testroot/repo`
313 got branch -r $testroot/repo -c $commit_id foo
314 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
315 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
316 local tag_id=`got ref -r $testroot/repo -l \
317 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
319 got clone -q -m $testurl/repo $testroot/repo-clone
321 if [ $ret -ne 0 ]; then
322 echo "got clone command failed unexpectedly" >&2
323 test_done "$testroot" "$ret"
327 got ref -l -r $testroot/repo-clone > $testroot/stdout
329 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
330 # refs/heads/foo is missing because we're not fetching all branches
331 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
332 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
333 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
335 cmp -s $testroot/stdout $testroot/stdout.expected
337 if [ $ret -ne 0 ]; then
338 diff -u $testroot/stdout.expected $testroot/stdout
339 test_done "$testroot" "$ret"
343 cat > $testroot/got.conf.expected <<EOF
347 repository "$testroot/repo"
349 mirror_references yes
352 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
354 if [ $ret -ne 0 ]; then
355 diff -u $testroot/got.conf.expected \
356 $testroot/repo-clone/got.conf
357 test_done "$testroot" "$ret"
361 cat > $testroot/config.expected <<EOF
363 repositoryformatversion = 0
368 url = ssh://127.0.0.1$testroot/repo
369 fetch = refs/heads/master:refs/heads/master
370 fetch = refs/tags/*:refs/tags/*
372 cmp -s $testroot/repo-clone/config $testroot/config.expected
374 if [ $ret -ne 0 ]; then
375 diff -u $testroot/config.expected \
376 $testroot/repo-clone/config
378 test_done "$testroot" "$ret"
381 test_clone_mirror_all() {
382 local testroot=`test_init clone_mirror_all`
383 local testurl=ssh://127.0.0.1/$testroot
384 local commit_id=`git_show_head $testroot/repo`
386 got branch -r $testroot/repo -c $commit_id foo
387 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
388 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
389 local tag_id=`got ref -r $testroot/repo -l \
390 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
392 got clone -q -m -a $testurl/repo $testroot/repo-clone
394 if [ $ret -ne 0 ]; then
395 echo "got clone command failed unexpectedly" >&2
396 test_done "$testroot" "$ret"
400 got ref -l -r $testroot/repo-clone > $testroot/stdout
402 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
403 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
404 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
405 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
406 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
408 cmp -s $testroot/stdout $testroot/stdout.expected
410 if [ $ret -ne 0 ]; then
411 diff -u $testroot/stdout.expected $testroot/stdout
412 test_done "$testroot" "$ret"
416 cat > $testroot/got.conf.expected <<EOF
420 repository "$testroot/repo"
421 mirror_references yes
422 fetch_all_branches yes
425 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
427 if [ $ret -ne 0 ]; then
428 diff -u $testroot/got.conf.expected \
429 $testroot/repo-clone/got.conf
430 test_done "$testroot" "$ret"
434 cat > $testroot/config.expected <<EOF
436 repositoryformatversion = 0
441 url = ssh://127.0.0.1$testroot/repo
442 fetch = refs/heads/*:refs/heads/*
443 fetch = refs/tags/*:refs/tags/*
445 cmp -s $testroot/repo-clone/config $testroot/config.expected
447 if [ $ret -ne 0 ]; then
448 diff -u $testroot/config.expected \
449 $testroot/repo-clone/config
451 test_done "$testroot" "$ret"
454 test_clone_reference() {
455 local testroot=`test_init clone_reference`
456 local testurl=ssh://127.0.0.1/$testroot
457 local commit_id=`git_show_head $testroot/repo`
459 got branch -r $testroot/repo -c $commit_id foo
460 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
461 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
462 local tag_id=`got ref -r $testroot/repo -l \
463 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
465 got clone -q -R hoo $testurl/repo $testroot/repo-clone
467 if [ $ret -ne 0 ]; then
468 echo "got clone command failed unexpectedly" >&2
469 test_done "$testroot" "$ret"
473 got ref -l -r $testroot/repo-clone > $testroot/stdout
475 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
476 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
477 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
478 >> $testroot/stdout.expected
479 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
480 >> $testroot/stdout.expected
481 echo "refs/remotes/origin/master: $commit_id" \
482 >> $testroot/stdout.expected
483 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
485 cmp -s $testroot/stdout $testroot/stdout.expected
487 if [ $ret -ne 0 ]; then
488 diff -u $testroot/stdout.expected $testroot/stdout
489 test_done "$testroot" "$ret"
493 cat > $testroot/got.conf.expected <<EOF
497 repository "$testroot/repo"
502 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
504 if [ $ret -ne 0 ]; then
505 diff -u $testroot/got.conf.expected \
506 $testroot/repo-clone/got.conf
507 test_done "$testroot" "$ret"
511 cat > $testroot/config.expected <<EOF
513 repositoryformatversion = 0
518 url = ssh://127.0.0.1$testroot/repo
519 fetch = refs/heads/master:refs/remotes/origin/master
520 fetch = refs/hoo:refs/remotes/origin/hoo
521 fetch = refs/tags/*:refs/tags/*
523 cmp -s $testroot/repo-clone/config $testroot/config.expected
525 if [ $ret -ne 0 ]; then
526 diff -u $testroot/config.expected \
527 $testroot/repo-clone/config
529 test_done "$testroot" "$ret"
532 test_clone_branch_and_reference() {
533 local testroot=`test_init clone_reference`
534 local testurl=ssh://127.0.0.1/$testroot
535 local commit_id=`git_show_head $testroot/repo`
537 got branch -r $testroot/repo -c $commit_id foo
538 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
539 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
540 local tag_id=`got ref -r $testroot/repo -l \
541 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
543 got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
545 if [ $ret -ne 0 ]; then
546 echo "got clone command failed unexpectedly" >&2
547 test_done "$testroot" "$ret"
551 got ref -l -r $testroot/repo-clone > $testroot/stdout
553 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
554 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
555 echo "refs/remotes/origin/foo: $commit_id" \
556 >> $testroot/stdout.expected
557 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
558 >> $testroot/stdout.expected
559 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
561 cmp -s $testroot/stdout $testroot/stdout.expected
563 if [ $ret -ne 0 ]; then
564 diff -u $testroot/stdout.expected $testroot/stdout
565 test_done "$testroot" "$ret"
569 cat > $testroot/got.conf.expected <<EOF
573 repository "$testroot/repo"
575 reference { "hoo/boo/zoo" }
578 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
580 if [ $ret -ne 0 ]; then
581 diff -u $testroot/got.conf.expected \
582 $testroot/repo-clone/got.conf
583 test_done "$testroot" "$ret"
587 cat > $testroot/config.expected <<EOF
589 repositoryformatversion = 0
594 url = ssh://127.0.0.1$testroot/repo
595 fetch = refs/heads/foo:refs/remotes/origin/foo
596 fetch = refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
597 fetch = refs/tags/*:refs/tags/*
599 cmp -s $testroot/repo-clone/config $testroot/config.expected
601 if [ $ret -ne 0 ]; then
602 diff -u $testroot/config.expected \
603 $testroot/repo-clone/config
605 test_done "$testroot" "$ret"
608 test_clone_reference_mirror() {
609 local testroot=`test_init clone_reference_mirror`
610 local testurl=ssh://127.0.0.1/$testroot
611 local commit_id=`git_show_head $testroot/repo`
613 got branch -r $testroot/repo -c $commit_id foo
614 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
615 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
616 local tag_id=`got ref -r $testroot/repo -l \
617 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
619 got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
621 if [ $ret -ne 0 ]; then
622 echo "got clone command failed unexpectedly" >&2
623 test_done "$testroot" "$ret"
627 got ref -l -r $testroot/repo-clone > $testroot/stdout
629 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
630 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
631 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
632 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
634 cmp -s $testroot/stdout $testroot/stdout.expected
636 if [ $ret -ne 0 ]; then
637 diff -u $testroot/stdout.expected $testroot/stdout
638 test_done "$testroot" "$ret"
642 cat > $testroot/got.conf.expected <<EOF
646 repository "$testroot/repo"
649 mirror_references yes
652 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
654 if [ $ret -ne 0 ]; then
655 diff -u $testroot/got.conf.expected \
656 $testroot/repo-clone/got.conf
657 test_done "$testroot" "$ret"
661 cat > $testroot/config.expected <<EOF
663 repositoryformatversion = 0
668 url = ssh://127.0.0.1$testroot/repo
669 fetch = refs/heads/master:refs/heads/master
670 fetch = refs/hoo:refs/hoo
671 fetch = refs/tags/*:refs/tags/*
673 cmp -s $testroot/repo-clone/config $testroot/config.expected
675 if [ $ret -ne 0 ]; then
676 diff -u $testroot/config.expected \
677 $testroot/repo-clone/config
679 test_done "$testroot" "$ret"
682 test_clone_multiple_branches() {
683 local testroot=`test_init clone_multiple_branches`
684 local testurl=ssh://127.0.0.1/$testroot
685 local commit_id=`git_show_head $testroot/repo`
687 got branch -r $testroot/repo -c $commit_id foo
688 got branch -r $testroot/repo -c $commit_id bar
690 got clone -q -b foo -b bar $testurl/repo $testroot/repo-clone
692 if [ $ret -ne 0 ]; then
693 echo "got clone command failed unexpectedly" >&2
694 test_done "$testroot" "$ret"
698 got ref -l -r $testroot/repo-clone > $testroot/stdout
700 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
701 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
702 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
703 echo "refs/remotes/origin/bar: $commit_id" \
704 >> $testroot/stdout.expected
705 echo "refs/remotes/origin/foo: $commit_id" \
706 >> $testroot/stdout.expected
708 cmp -s $testroot/stdout $testroot/stdout.expected
710 if [ $ret -ne 0 ]; then
711 diff -u $testroot/stdout.expected $testroot/stdout
712 test_done "$testroot" "$ret"
716 cat > $testroot/got.conf.expected <<EOF
720 repository "$testroot/repo"
721 branch { "foo" "bar" }
724 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
726 if [ $ret -ne 0 ]; then
727 diff -u $testroot/got.conf.expected \
728 $testroot/repo-clone/got.conf
729 test_done "$testroot" "$ret"
733 cat > $testroot/config.expected <<EOF
735 repositoryformatversion = 0
740 url = ssh://127.0.0.1$testroot/repo
741 fetch = refs/heads/foo:refs/remotes/origin/foo
742 fetch = refs/heads/bar:refs/remotes/origin/bar
743 fetch = refs/tags/*:refs/tags/*
745 cmp -s $testroot/repo-clone/config $testroot/config.expected
747 if [ $ret -ne 0 ]; then
748 diff -u $testroot/config.expected \
749 $testroot/repo-clone/config
751 test_done "$testroot" "$ret"
754 test_clone_dangling_headref() {
755 local testroot=`test_init clone_dangling_headref`
756 local testurl=ssh://127.0.0.1/$testroot
757 local commit_id=`git_show_head $testroot/repo`
759 got branch -r $testroot/repo -d master > /dev/null
760 got branch -r $testroot/repo -c $commit_id foo
762 got ref -l -r $testroot/repo > $testroot/stdout
764 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
765 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
766 # refs/heads/master is missing because it was deleted above
768 cmp -s $testroot/stdout $testroot/stdout.expected
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/stdout.expected $testroot/stdout
772 test_done "$testroot" "$ret"
776 got clone -q -b foo $testurl/repo $testroot/repo-clone
778 if [ $ret -ne 0 ]; then
779 echo "got clone command failed unexpectedly" >&2
780 test_done "$testroot" "$ret"
784 got ref -l -r $testroot/repo-clone > $testroot/stdout
786 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
787 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
788 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
790 cmp -s $testroot/stdout $testroot/stdout.expected
792 if [ $ret -ne 0 ]; then
793 diff -u $testroot/stdout.expected $testroot/stdout
794 test_done "$testroot" "$ret"
798 cat > $testroot/got.conf.expected <<EOF
802 repository "$testroot/repo"
806 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
808 if [ $ret -ne 0 ]; then
809 diff -u $testroot/got.conf.expected \
810 $testroot/repo-clone/got.conf
811 test_done "$testroot" "$ret"
815 cat > $testroot/config.expected <<EOF
817 repositoryformatversion = 0
822 url = ssh://127.0.0.1$testroot/repo
823 fetch = refs/heads/foo:refs/remotes/origin/foo
824 fetch = refs/tags/*:refs/tags/*
826 cmp -s $testroot/repo-clone/config $testroot/config.expected
828 if [ $ret -ne 0 ]; then
829 diff -u $testroot/config.expected \
830 $testroot/repo-clone/config
832 test_done "$testroot" "$ret"
836 run_test test_clone_basic
837 run_test test_clone_list
838 run_test test_clone_branch
839 run_test test_clone_all
840 run_test test_clone_mirror
841 run_test test_clone_mirror_all
842 run_test test_clone_reference
843 run_test test_clone_branch_and_reference
844 run_test test_clone_reference_mirror
845 run_test test_clone_multiple_branches
846 run_test test_clone_dangling_headref