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 > $testroot/log-repo-clone
41 if [ $ret -ne 0 ]; then
42 echo "got log command failed unexpectedly" >&2
43 test_done "$testroot" "$ret"
46 cmp -s $testroot/log-repo $testroot/log-repo-clone
48 if [ $ret -ne 0 ]; then
49 echo "log -p output of cloned repository differs" >&2
50 test_done "$testroot" "$ret"
54 got ref -l -r $testroot/repo > $testroot/stdout
56 if [ $ret -ne 0 ]; then
57 echo "got ref command failed unexpectedly" >&2
58 test_done "$testroot" "$ret"
62 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
63 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
65 cmp -s $testroot/stdout $testroot/stdout.expected
67 if [ $ret -ne 0 ]; then
68 diff -u $testroot/stdout.expected $testroot/stdout
69 test_done "$testroot" "$ret"
73 got ref -l -r $testroot/repo-clone > $testroot/stdout
75 if [ $ret -ne 0 ]; then
76 echo "got ref command failed unexpectedly" >&2
77 test_done "$testroot" "$ret"
81 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
82 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
83 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
84 >> $testroot/stdout.expected
85 echo "refs/remotes/origin/master: $commit_id" \
86 >> $testroot/stdout.expected
88 cmp -s $testroot/stdout $testroot/stdout.expected
90 if [ $ret -ne 0 ]; then
91 diff -u $testroot/stdout.expected $testroot/stdout
92 test_done "$testroot" "$ret"
96 cat > $testroot/got.conf.expected <<EOF
100 repository "$testroot/repo"
104 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
106 if [ $ret -ne 0 ]; then
107 diff -u $testroot/got.conf.expected \
108 $testroot/repo-clone/got.conf
109 test_done "$testroot" "$ret"
113 cat > $testroot/config.expected <<EOF
115 repositoryformatversion = 0
120 url = ssh://127.0.0.1$testroot/repo
121 fetch = refs/heads/master:refs/remotes/origin/master
122 fetch = refs/tags/*:refs/tags/*
124 cmp -s $testroot/repo-clone/config $testroot/config.expected
126 if [ $ret -ne 0 ]; then
127 diff -u $testroot/config.expected \
128 $testroot/repo-clone/config
130 test_done "$testroot" "$ret"
134 local testroot=`test_init clone_list`
135 local testurl=ssh://127.0.0.1$testroot
136 local commit_id=`git_show_head $testroot/repo`
138 got branch -r $testroot/repo -c $commit_id foo
139 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
140 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
142 got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
144 if [ $ret -ne 0 ]; then
145 echo "got clone command failed unexpectedly" >&2
146 test_done "$testroot" "$ret"
150 echo "Connecting to $testurl/repo" > $testroot/stdout.expected
151 got ref -l -r $testroot/repo >> $testroot/stdout.expected
153 cmp -s $testroot/stdout $testroot/stdout.expected
155 if [ $ret -ne 0 ]; then
156 diff -u $testroot/stdout.expected $testroot/stdout
158 test_done "$testroot" "$ret"
161 test_clone_branch() {
162 local testroot=`test_init clone_branch`
163 local testurl=ssh://127.0.0.1/$testroot
164 local commit_id=`git_show_head $testroot/repo`
166 got branch -r $testroot/repo -c $commit_id foo
167 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
168 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
169 local tag_id=`got ref -r $testroot/repo -l \
170 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
172 got clone -q -b foo $testurl/repo $testroot/repo-clone
174 if [ $ret -ne 0 ]; then
175 echo "got clone command failed unexpectedly" >&2
176 test_done "$testroot" "$ret"
180 got ref -l -r $testroot/repo-clone > $testroot/stdout
182 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
183 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
184 # refs/heads/master is missing because it wasn't passed via -b
185 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
186 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
187 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
189 cmp -s $testroot/stdout $testroot/stdout.expected
191 if [ $ret -ne 0 ]; then
192 diff -u $testroot/stdout.expected $testroot/stdout
193 test_done "$testroot" "$ret"
197 cat > $testroot/got.conf.expected <<EOF
201 repository "$testroot/repo"
205 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
207 if [ $ret -ne 0 ]; then
208 diff -u $testroot/got.conf.expected \
209 $testroot/repo-clone/got.conf
210 test_done "$testroot" "$ret"
214 cat > $testroot/config.expected <<EOF
216 repositoryformatversion = 0
221 url = ssh://127.0.0.1$testroot/repo
222 fetch = refs/heads/foo:refs/remotes/origin/foo
223 fetch = refs/tags/*:refs/tags/*
225 cmp -s $testroot/repo-clone/config $testroot/config.expected
227 if [ $ret -ne 0 ]; then
228 diff -u $testroot/config.expected \
229 $testroot/repo-clone/config
231 test_done "$testroot" "$ret"
235 local testroot=`test_init clone_all`
236 local testurl=ssh://127.0.0.1/$testroot
237 local commit_id=`git_show_head $testroot/repo`
239 got branch -r $testroot/repo -c $commit_id foo
240 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
241 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
242 local tag_id=`got ref -r $testroot/repo -l \
243 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
245 got clone -q -a $testurl/repo $testroot/repo-clone
247 if [ $ret -ne 0 ]; then
248 echo "got clone command failed unexpectedly" >&2
249 test_done "$testroot" "$ret"
253 got ref -l -r $testroot/repo-clone > $testroot/stdout
255 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
256 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
257 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
258 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
259 >> $testroot/stdout.expected
260 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
261 echo "refs/remotes/origin/master: $commit_id" \
262 >> $testroot/stdout.expected
263 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
264 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
266 cmp -s $testroot/stdout $testroot/stdout.expected
268 if [ $ret -ne 0 ]; then
269 diff -u $testroot/stdout.expected $testroot/stdout
270 test_done "$testroot" "$ret"
274 cat > $testroot/got.conf.expected <<EOF
278 repository "$testroot/repo"
279 fetch_all_branches yes
282 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
284 if [ $ret -ne 0 ]; then
285 diff -u $testroot/got.conf.expected \
286 $testroot/repo-clone/got.conf
287 test_done "$testroot" "$ret"
291 cat > $testroot/config.expected <<EOF
293 repositoryformatversion = 0
298 url = ssh://127.0.0.1$testroot/repo
299 fetch = refs/heads/*:refs/remotes/origin/*
300 fetch = refs/tags/*:refs/tags/*
302 cmp -s $testroot/repo-clone/config $testroot/config.expected
304 if [ $ret -ne 0 ]; then
305 diff -u $testroot/config.expected \
306 $testroot/repo-clone/config
308 test_done "$testroot" "$ret"
311 test_clone_mirror() {
312 local testroot=`test_init clone_mirror`
313 local testurl=ssh://127.0.0.1/$testroot
314 local commit_id=`git_show_head $testroot/repo`
316 got branch -r $testroot/repo -c $commit_id foo
317 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
318 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
319 local tag_id=`got ref -r $testroot/repo -l \
320 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
322 got clone -q -m $testurl/repo $testroot/repo-clone
324 if [ $ret -ne 0 ]; then
325 echo "got clone command failed unexpectedly" >&2
326 test_done "$testroot" "$ret"
330 got ref -l -r $testroot/repo-clone > $testroot/stdout
332 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
333 # refs/heads/foo is missing because we're not fetching all branches
334 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
335 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
336 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
338 cmp -s $testroot/stdout $testroot/stdout.expected
340 if [ $ret -ne 0 ]; then
341 diff -u $testroot/stdout.expected $testroot/stdout
342 test_done "$testroot" "$ret"
346 cat > $testroot/got.conf.expected <<EOF
350 repository "$testroot/repo"
352 mirror_references yes
355 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
357 if [ $ret -ne 0 ]; then
358 diff -u $testroot/got.conf.expected \
359 $testroot/repo-clone/got.conf
360 test_done "$testroot" "$ret"
364 cat > $testroot/config.expected <<EOF
366 repositoryformatversion = 0
371 url = ssh://127.0.0.1$testroot/repo
372 fetch = refs/heads/master:refs/heads/master
373 fetch = refs/tags/*:refs/tags/*
375 cmp -s $testroot/repo-clone/config $testroot/config.expected
377 if [ $ret -ne 0 ]; then
378 diff -u $testroot/config.expected \
379 $testroot/repo-clone/config
381 test_done "$testroot" "$ret"
384 test_clone_mirror_all() {
385 local testroot=`test_init clone_mirror_all`
386 local testurl=ssh://127.0.0.1/$testroot
387 local commit_id=`git_show_head $testroot/repo`
389 got branch -r $testroot/repo -c $commit_id foo
390 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
391 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
392 local tag_id=`got ref -r $testroot/repo -l \
393 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
395 got clone -q -m -a $testurl/repo $testroot/repo-clone
397 if [ $ret -ne 0 ]; then
398 echo "got clone command failed unexpectedly" >&2
399 test_done "$testroot" "$ret"
403 got ref -l -r $testroot/repo-clone > $testroot/stdout
405 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
406 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
407 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
408 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
409 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
411 cmp -s $testroot/stdout $testroot/stdout.expected
413 if [ $ret -ne 0 ]; then
414 diff -u $testroot/stdout.expected $testroot/stdout
415 test_done "$testroot" "$ret"
419 cat > $testroot/got.conf.expected <<EOF
423 repository "$testroot/repo"
424 mirror_references yes
425 fetch_all_branches yes
428 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
430 if [ $ret -ne 0 ]; then
431 diff -u $testroot/got.conf.expected \
432 $testroot/repo-clone/got.conf
433 test_done "$testroot" "$ret"
437 cat > $testroot/config.expected <<EOF
439 repositoryformatversion = 0
444 url = ssh://127.0.0.1$testroot/repo
445 fetch = refs/heads/*:refs/heads/*
446 fetch = refs/tags/*:refs/tags/*
448 cmp -s $testroot/repo-clone/config $testroot/config.expected
450 if [ $ret -ne 0 ]; then
451 diff -u $testroot/config.expected \
452 $testroot/repo-clone/config
454 test_done "$testroot" "$ret"
457 test_clone_reference() {
458 local testroot=`test_init clone_reference`
459 local testurl=ssh://127.0.0.1/$testroot
460 local commit_id=`git_show_head $testroot/repo`
462 got branch -r $testroot/repo -c $commit_id foo
463 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
464 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
465 local tag_id=`got ref -r $testroot/repo -l \
466 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
468 got clone -q -R hoo $testurl/repo $testroot/repo-clone
470 if [ $ret -ne 0 ]; then
471 echo "got clone command failed unexpectedly" >&2
472 test_done "$testroot" "$ret"
476 got ref -l -r $testroot/repo-clone > $testroot/stdout
478 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
479 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
480 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
481 >> $testroot/stdout.expected
482 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
483 >> $testroot/stdout.expected
484 echo "refs/remotes/origin/master: $commit_id" \
485 >> $testroot/stdout.expected
486 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
488 cmp -s $testroot/stdout $testroot/stdout.expected
490 if [ $ret -ne 0 ]; then
491 diff -u $testroot/stdout.expected $testroot/stdout
492 test_done "$testroot" "$ret"
496 cat > $testroot/got.conf.expected <<EOF
500 repository "$testroot/repo"
505 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
507 if [ $ret -ne 0 ]; then
508 diff -u $testroot/got.conf.expected \
509 $testroot/repo-clone/got.conf
510 test_done "$testroot" "$ret"
514 cat > $testroot/config.expected <<EOF
516 repositoryformatversion = 0
521 url = ssh://127.0.0.1$testroot/repo
522 fetch = refs/heads/master:refs/remotes/origin/master
523 fetch = refs/hoo:refs/remotes/origin/hoo
524 fetch = refs/tags/*:refs/tags/*
526 cmp -s $testroot/repo-clone/config $testroot/config.expected
528 if [ $ret -ne 0 ]; then
529 diff -u $testroot/config.expected \
530 $testroot/repo-clone/config
532 test_done "$testroot" "$ret"
535 test_clone_branch_and_reference() {
536 local testroot=`test_init clone_reference`
537 local testurl=ssh://127.0.0.1/$testroot
538 local commit_id=`git_show_head $testroot/repo`
540 got branch -r $testroot/repo -c $commit_id foo
541 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
542 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
543 local tag_id=`got ref -r $testroot/repo -l \
544 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
546 got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
548 if [ $ret -ne 0 ]; then
549 echo "got clone command failed unexpectedly" >&2
550 test_done "$testroot" "$ret"
554 got ref -l -r $testroot/repo-clone > $testroot/stdout
556 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
557 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
558 echo "refs/remotes/origin/foo: $commit_id" \
559 >> $testroot/stdout.expected
560 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
561 >> $testroot/stdout.expected
562 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
564 cmp -s $testroot/stdout $testroot/stdout.expected
566 if [ $ret -ne 0 ]; then
567 diff -u $testroot/stdout.expected $testroot/stdout
568 test_done "$testroot" "$ret"
572 cat > $testroot/got.conf.expected <<EOF
576 repository "$testroot/repo"
578 reference { "hoo/boo/zoo" }
581 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
583 if [ $ret -ne 0 ]; then
584 diff -u $testroot/got.conf.expected \
585 $testroot/repo-clone/got.conf
586 test_done "$testroot" "$ret"
590 cat > $testroot/config.expected <<EOF
592 repositoryformatversion = 0
597 url = ssh://127.0.0.1$testroot/repo
598 fetch = refs/heads/foo:refs/remotes/origin/foo
599 fetch = refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
600 fetch = refs/tags/*:refs/tags/*
602 cmp -s $testroot/repo-clone/config $testroot/config.expected
604 if [ $ret -ne 0 ]; then
605 diff -u $testroot/config.expected \
606 $testroot/repo-clone/config
608 test_done "$testroot" "$ret"
611 test_clone_reference_mirror() {
612 local testroot=`test_init clone_reference_mirror`
613 local testurl=ssh://127.0.0.1/$testroot
614 local commit_id=`git_show_head $testroot/repo`
616 got branch -r $testroot/repo -c $commit_id foo
617 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
618 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
619 local tag_id=`got ref -r $testroot/repo -l \
620 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
622 got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
624 if [ $ret -ne 0 ]; then
625 echo "got clone command failed unexpectedly" >&2
626 test_done "$testroot" "$ret"
630 got ref -l -r $testroot/repo-clone > $testroot/stdout
632 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
633 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
634 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
635 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
637 cmp -s $testroot/stdout $testroot/stdout.expected
639 if [ $ret -ne 0 ]; then
640 diff -u $testroot/stdout.expected $testroot/stdout
641 test_done "$testroot" "$ret"
645 cat > $testroot/got.conf.expected <<EOF
649 repository "$testroot/repo"
652 mirror_references yes
655 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
657 if [ $ret -ne 0 ]; then
658 diff -u $testroot/got.conf.expected \
659 $testroot/repo-clone/got.conf
660 test_done "$testroot" "$ret"
664 cat > $testroot/config.expected <<EOF
666 repositoryformatversion = 0
671 url = ssh://127.0.0.1$testroot/repo
672 fetch = refs/heads/master:refs/heads/master
673 fetch = refs/hoo:refs/hoo
674 fetch = refs/tags/*:refs/tags/*
676 cmp -s $testroot/repo-clone/config $testroot/config.expected
678 if [ $ret -ne 0 ]; then
679 diff -u $testroot/config.expected \
680 $testroot/repo-clone/config
682 test_done "$testroot" "$ret"
685 test_clone_multiple_branches() {
686 local testroot=`test_init clone_multiple_branches`
687 local testurl=ssh://127.0.0.1/$testroot
688 local commit_id=`git_show_head $testroot/repo`
690 got branch -r $testroot/repo -c $commit_id foo
691 got branch -r $testroot/repo -c $commit_id bar
693 got clone -q -b foo -b bar $testurl/repo $testroot/repo-clone
695 if [ $ret -ne 0 ]; then
696 echo "got clone command failed unexpectedly" >&2
697 test_done "$testroot" "$ret"
701 got ref -l -r $testroot/repo-clone > $testroot/stdout
703 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
704 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
705 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
706 echo "refs/remotes/origin/bar: $commit_id" \
707 >> $testroot/stdout.expected
708 echo "refs/remotes/origin/foo: $commit_id" \
709 >> $testroot/stdout.expected
711 cmp -s $testroot/stdout $testroot/stdout.expected
713 if [ $ret -ne 0 ]; then
714 diff -u $testroot/stdout.expected $testroot/stdout
715 test_done "$testroot" "$ret"
719 cat > $testroot/got.conf.expected <<EOF
723 repository "$testroot/repo"
724 branch { "foo" "bar" }
727 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/got.conf.expected \
731 $testroot/repo-clone/got.conf
732 test_done "$testroot" "$ret"
736 cat > $testroot/config.expected <<EOF
738 repositoryformatversion = 0
743 url = ssh://127.0.0.1$testroot/repo
744 fetch = refs/heads/foo:refs/remotes/origin/foo
745 fetch = refs/heads/bar:refs/remotes/origin/bar
746 fetch = refs/tags/*:refs/tags/*
748 cmp -s $testroot/repo-clone/config $testroot/config.expected
750 if [ $ret -ne 0 ]; then
751 diff -u $testroot/config.expected \
752 $testroot/repo-clone/config
754 test_done "$testroot" "$ret"
757 test_clone_dangling_headref() {
758 local testroot=`test_init clone_dangling_headref`
759 local testurl=ssh://127.0.0.1/$testroot
760 local commit_id=`git_show_head $testroot/repo`
762 got branch -r $testroot/repo -d master > /dev/null
763 got branch -r $testroot/repo -c $commit_id foo
765 got ref -l -r $testroot/repo > $testroot/stdout
767 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
768 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
769 # refs/heads/master is missing because it was deleted above
771 cmp -s $testroot/stdout $testroot/stdout.expected
773 if [ $ret -ne 0 ]; then
774 diff -u $testroot/stdout.expected $testroot/stdout
775 test_done "$testroot" "$ret"
779 got clone -q -b foo $testurl/repo $testroot/repo-clone
781 if [ $ret -ne 0 ]; then
782 echo "got clone command failed unexpectedly" >&2
783 test_done "$testroot" "$ret"
787 got ref -l -r $testroot/repo-clone > $testroot/stdout
789 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
790 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
791 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
793 cmp -s $testroot/stdout $testroot/stdout.expected
795 if [ $ret -ne 0 ]; then
796 diff -u $testroot/stdout.expected $testroot/stdout
797 test_done "$testroot" "$ret"
801 cat > $testroot/got.conf.expected <<EOF
805 repository "$testroot/repo"
809 cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
811 if [ $ret -ne 0 ]; then
812 diff -u $testroot/got.conf.expected \
813 $testroot/repo-clone/got.conf
814 test_done "$testroot" "$ret"
818 cat > $testroot/config.expected <<EOF
820 repositoryformatversion = 0
825 url = ssh://127.0.0.1$testroot/repo
826 fetch = refs/heads/foo:refs/remotes/origin/foo
827 fetch = refs/tags/*:refs/tags/*
829 cmp -s $testroot/repo-clone/config $testroot/config.expected
831 if [ $ret -ne 0 ]; then
832 diff -u $testroot/config.expected \
833 $testroot/repo-clone/config
835 test_done "$testroot" "$ret"
839 run_test test_clone_basic
840 run_test test_clone_list
841 run_test test_clone_branch
842 run_test test_clone_all
843 run_test test_clone_mirror
844 run_test test_clone_mirror_all
845 run_test test_clone_reference
846 run_test test_clone_branch_and_reference
847 run_test test_clone_reference_mirror
848 run_test test_clone_multiple_branches
849 run_test test_clone_dangling_headref