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"
130 test_clone_quoting
() {
131 local testroot
=`test_init clone_basic`
133 got log
-l0 -p -r "$testroot/repo" > $testroot/log-repo
135 (cd "$testroot" && cp -R repo
"rock'n roll.git")
137 got clone
-q "ssh://127.0.0.1/$testroot/rock'n roll.git" \
138 "$testroot/rock-clone"
140 if [ $ret -ne 0 ]; then
141 echo "got clone failed unexpectedly" >&2
142 test_done
"$testroot" "$ret"
146 got log
-l0 -p -r "$testroot/rock-clone" | \
147 sed 's@master, origin/master@master@g' \
148 >$testroot/log-repo-clone
150 cmp -s "$testroot/log-repo" "$testroot/log-repo-clone"
152 if [ $ret -ne 0 ]; then
153 echo "log -p output of cloned repository differs" >&2
154 diff -u "$testroot/log-repo" "$testroot/log-repo-clone"
155 test_done
"$testroot" "$ret"
157 test_done
"$testroot" "$ret"
161 local testroot
=`test_init clone_list`
162 local testurl
=ssh://127.0.0.1$testroot
163 local commit_id
=`git_show_head $testroot/repo`
165 got branch
-r $testroot/repo
-c $commit_id foo
166 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
167 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
169 got clone
-l $testurl/repo
> $testroot/stdout
2>$testroot/stderr
171 if [ $ret -ne 0 ]; then
172 echo "got clone command failed unexpectedly" >&2
173 test_done
"$testroot" "$ret"
177 echo "Connecting to $testurl/repo" > $testroot/stdout.expected
178 got ref
-l -r $testroot/repo
>> $testroot/stdout.expected
180 cmp -s $testroot/stdout
$testroot/stdout.expected
182 if [ $ret -ne 0 ]; then
183 diff -u $testroot/stdout.expected
$testroot/stdout
185 test_done
"$testroot" "$ret"
188 test_clone_branch
() {
189 local testroot
=`test_init clone_branch`
190 local testurl
=ssh://127.0.0.1/$testroot
191 local commit_id
=`git_show_head $testroot/repo`
193 got branch
-r $testroot/repo
-c $commit_id foo
194 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
195 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
196 local tag_id
=`got ref -r $testroot/repo -l \
197 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
199 got clone
-q -b foo
$testurl/repo
$testroot/repo-clone
201 if [ $ret -ne 0 ]; then
202 echo "got clone command failed unexpectedly" >&2
203 test_done
"$testroot" "$ret"
207 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
209 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
210 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
211 # refs/heads/master is missing because it wasn't passed via -b
212 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
213 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
214 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
216 cmp -s $testroot/stdout
$testroot/stdout.expected
218 if [ $ret -ne 0 ]; then
219 diff -u $testroot/stdout.expected
$testroot/stdout
220 test_done
"$testroot" "$ret"
224 cat > $testroot/got.conf.expected
<<EOF
228 repository "$testroot/repo"
232 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
234 if [ $ret -ne 0 ]; then
235 diff -u $testroot/got.conf.expected \
236 $testroot/repo-clone
/got.conf
237 test_done
"$testroot" "$ret"
241 cat > $testroot/config.expected
<<EOF
243 repositoryformatversion = 0
248 url = ssh://127.0.0.1$testroot/repo
249 fetch = refs/heads/foo:refs/remotes/origin/foo
250 fetch = refs/tags/*:refs/tags/*
252 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
254 if [ $ret -ne 0 ]; then
255 diff -u $testroot/config.expected \
256 $testroot/repo-clone
/config
258 test_done
"$testroot" "$ret"
262 local testroot
=`test_init clone_all`
263 local testurl
=ssh://127.0.0.1/$testroot
264 local commit_id
=`git_show_head $testroot/repo`
266 got branch
-r $testroot/repo
-c $commit_id foo
267 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
268 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
269 local tag_id
=`got ref -r $testroot/repo -l \
270 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
272 got clone
-q -a $testurl/repo
$testroot/repo-clone
274 if [ $ret -ne 0 ]; then
275 echo "got clone command failed unexpectedly" >&2
276 test_done
"$testroot" "$ret"
280 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
282 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
283 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
284 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
285 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
286 >> $testroot/stdout.expected
287 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
288 echo "refs/remotes/origin/master: $commit_id" \
289 >> $testroot/stdout.expected
290 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
291 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
293 cmp -s $testroot/stdout
$testroot/stdout.expected
295 if [ $ret -ne 0 ]; then
296 diff -u $testroot/stdout.expected
$testroot/stdout
297 test_done
"$testroot" "$ret"
301 cat > $testroot/got.conf.expected
<<EOF
305 repository "$testroot/repo"
306 fetch_all_branches yes
309 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
311 if [ $ret -ne 0 ]; then
312 diff -u $testroot/got.conf.expected \
313 $testroot/repo-clone
/got.conf
314 test_done
"$testroot" "$ret"
318 cat > $testroot/config.expected
<<EOF
320 repositoryformatversion = 0
325 url = ssh://127.0.0.1$testroot/repo
326 fetch = refs/heads/*:refs/remotes/origin/*
327 fetch = refs/tags/*:refs/tags/*
329 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
331 if [ $ret -ne 0 ]; then
332 diff -u $testroot/config.expected \
333 $testroot/repo-clone
/config
335 test_done
"$testroot" "$ret"
338 test_clone_mirror
() {
339 local testroot
=`test_init clone_mirror`
340 local testurl
=ssh://127.0.0.1/$testroot
341 local commit_id
=`git_show_head $testroot/repo`
343 got branch
-r $testroot/repo
-c $commit_id foo
344 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
345 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
346 local tag_id
=`got ref -r $testroot/repo -l \
347 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
349 got clone
-q -m $testurl/repo
$testroot/repo-clone
351 if [ $ret -ne 0 ]; then
352 echo "got clone command failed unexpectedly" >&2
353 test_done
"$testroot" "$ret"
357 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
359 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
360 # refs/heads/foo is missing because we're not fetching all branches
361 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
362 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
363 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
365 cmp -s $testroot/stdout
$testroot/stdout.expected
367 if [ $ret -ne 0 ]; then
368 diff -u $testroot/stdout.expected
$testroot/stdout
369 test_done
"$testroot" "$ret"
373 cat > $testroot/got.conf.expected
<<EOF
377 repository "$testroot/repo"
379 mirror_references yes
382 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
384 if [ $ret -ne 0 ]; then
385 diff -u $testroot/got.conf.expected \
386 $testroot/repo-clone
/got.conf
387 test_done
"$testroot" "$ret"
391 cat > $testroot/config.expected
<<EOF
393 repositoryformatversion = 0
398 url = ssh://127.0.0.1$testroot/repo
399 fetch = refs/heads/master:refs/heads/master
400 fetch = refs/tags/*:refs/tags/*
402 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
404 if [ $ret -ne 0 ]; then
405 diff -u $testroot/config.expected \
406 $testroot/repo-clone
/config
408 test_done
"$testroot" "$ret"
411 test_clone_mirror_all
() {
412 local testroot
=`test_init clone_mirror_all`
413 local testurl
=ssh://127.0.0.1/$testroot
414 local commit_id
=`git_show_head $testroot/repo`
416 got branch
-r $testroot/repo
-c $commit_id foo
417 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
418 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
419 local tag_id
=`got ref -r $testroot/repo -l \
420 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
422 got clone
-q -m -a $testurl/repo
$testroot/repo-clone
424 if [ $ret -ne 0 ]; then
425 echo "got clone command failed unexpectedly" >&2
426 test_done
"$testroot" "$ret"
430 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
432 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
433 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
434 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
435 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
436 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
438 cmp -s $testroot/stdout
$testroot/stdout.expected
440 if [ $ret -ne 0 ]; then
441 diff -u $testroot/stdout.expected
$testroot/stdout
442 test_done
"$testroot" "$ret"
446 cat > $testroot/got.conf.expected
<<EOF
450 repository "$testroot/repo"
451 mirror_references yes
452 fetch_all_branches yes
455 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
457 if [ $ret -ne 0 ]; then
458 diff -u $testroot/got.conf.expected \
459 $testroot/repo-clone
/got.conf
460 test_done
"$testroot" "$ret"
464 cat > $testroot/config.expected
<<EOF
466 repositoryformatversion = 0
471 url = ssh://127.0.0.1$testroot/repo
472 fetch = refs/heads/*:refs/heads/*
473 fetch = refs/tags/*:refs/tags/*
475 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
477 if [ $ret -ne 0 ]; then
478 diff -u $testroot/config.expected \
479 $testroot/repo-clone
/config
481 test_done
"$testroot" "$ret"
484 test_clone_reference
() {
485 local testroot
=`test_init clone_reference`
486 local testurl
=ssh://127.0.0.1/$testroot
487 local commit_id
=`git_show_head $testroot/repo`
489 got branch
-r $testroot/repo
-c $commit_id foo
490 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
491 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
492 local tag_id
=`got ref -r $testroot/repo -l \
493 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
495 got clone
-q -R hoo
$testurl/repo
$testroot/repo-clone
497 if [ $ret -ne 0 ]; then
498 echo "got clone command failed unexpectedly" >&2
499 test_done
"$testroot" "$ret"
503 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
505 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
506 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
507 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
508 >> $testroot/stdout.expected
509 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
510 >> $testroot/stdout.expected
511 echo "refs/remotes/origin/master: $commit_id" \
512 >> $testroot/stdout.expected
513 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
515 cmp -s $testroot/stdout
$testroot/stdout.expected
517 if [ $ret -ne 0 ]; then
518 diff -u $testroot/stdout.expected
$testroot/stdout
519 test_done
"$testroot" "$ret"
523 cat > $testroot/got.conf.expected
<<EOF
527 repository "$testroot/repo"
532 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
534 if [ $ret -ne 0 ]; then
535 diff -u $testroot/got.conf.expected \
536 $testroot/repo-clone
/got.conf
537 test_done
"$testroot" "$ret"
541 cat > $testroot/config.expected
<<EOF
543 repositoryformatversion = 0
548 url = ssh://127.0.0.1$testroot/repo
549 fetch = refs/heads/master:refs/remotes/origin/master
550 fetch = refs/hoo:refs/remotes/origin/hoo
551 fetch = refs/tags/*:refs/tags/*
553 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
555 if [ $ret -ne 0 ]; then
556 diff -u $testroot/config.expected \
557 $testroot/repo-clone
/config
559 test_done
"$testroot" "$ret"
562 test_clone_branch_and_reference
() {
563 local testroot
=`test_init clone_reference`
564 local testurl
=ssh://127.0.0.1/$testroot
565 local commit_id
=`git_show_head $testroot/repo`
567 got branch
-r $testroot/repo
-c $commit_id foo
568 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
569 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
570 local tag_id
=`got ref -r $testroot/repo -l \
571 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
573 got clone
-q -R hoo
/boo
/zoo
-b foo
$testurl/repo
$testroot/repo-clone
575 if [ $ret -ne 0 ]; then
576 echo "got clone command failed unexpectedly" >&2
577 test_done
"$testroot" "$ret"
581 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
583 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
584 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
585 echo "refs/remotes/origin/foo: $commit_id" \
586 >> $testroot/stdout.expected
587 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
588 >> $testroot/stdout.expected
589 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
591 cmp -s $testroot/stdout
$testroot/stdout.expected
593 if [ $ret -ne 0 ]; then
594 diff -u $testroot/stdout.expected
$testroot/stdout
595 test_done
"$testroot" "$ret"
599 cat > $testroot/got.conf.expected
<<EOF
603 repository "$testroot/repo"
605 reference { "hoo/boo/zoo" }
608 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
610 if [ $ret -ne 0 ]; then
611 diff -u $testroot/got.conf.expected \
612 $testroot/repo-clone
/got.conf
613 test_done
"$testroot" "$ret"
617 cat > $testroot/config.expected
<<EOF
619 repositoryformatversion = 0
624 url = ssh://127.0.0.1$testroot/repo
625 fetch = refs/heads/foo:refs/remotes/origin/foo
626 fetch = refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
627 fetch = refs/tags/*:refs/tags/*
629 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
631 if [ $ret -ne 0 ]; then
632 diff -u $testroot/config.expected \
633 $testroot/repo-clone
/config
635 test_done
"$testroot" "$ret"
638 test_clone_reference_mirror
() {
639 local testroot
=`test_init clone_reference_mirror`
640 local testurl
=ssh://127.0.0.1/$testroot
641 local commit_id
=`git_show_head $testroot/repo`
643 got branch
-r $testroot/repo
-c $commit_id foo
644 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
645 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
646 local tag_id
=`got ref -r $testroot/repo -l \
647 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
649 got clone
-q -R hoo
-m $testurl/repo
$testroot/repo-clone
651 if [ $ret -ne 0 ]; then
652 echo "got clone command failed unexpectedly" >&2
653 test_done
"$testroot" "$ret"
657 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
659 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
660 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
661 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
662 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
664 cmp -s $testroot/stdout
$testroot/stdout.expected
666 if [ $ret -ne 0 ]; then
667 diff -u $testroot/stdout.expected
$testroot/stdout
668 test_done
"$testroot" "$ret"
672 cat > $testroot/got.conf.expected
<<EOF
676 repository "$testroot/repo"
679 mirror_references yes
682 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
684 if [ $ret -ne 0 ]; then
685 diff -u $testroot/got.conf.expected \
686 $testroot/repo-clone
/got.conf
687 test_done
"$testroot" "$ret"
691 cat > $testroot/config.expected
<<EOF
693 repositoryformatversion = 0
698 url = ssh://127.0.0.1$testroot/repo
699 fetch = refs/heads/master:refs/heads/master
700 fetch = refs/hoo:refs/hoo
701 fetch = refs/tags/*:refs/tags/*
703 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
705 if [ $ret -ne 0 ]; then
706 diff -u $testroot/config.expected \
707 $testroot/repo-clone
/config
709 test_done
"$testroot" "$ret"
712 test_clone_multiple_branches
() {
713 local testroot
=`test_init clone_multiple_branches`
714 local testurl
=ssh://127.0.0.1/$testroot
715 local commit_id
=`git_show_head $testroot/repo`
717 got branch
-r $testroot/repo
-c $commit_id foo
718 got branch
-r $testroot/repo
-c $commit_id bar
720 got clone
-q -b foo
-b bar
$testurl/repo
$testroot/repo-clone
722 if [ $ret -ne 0 ]; then
723 echo "got clone command failed unexpectedly" >&2
724 test_done
"$testroot" "$ret"
728 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
730 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
731 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
732 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
733 echo "refs/remotes/origin/bar: $commit_id" \
734 >> $testroot/stdout.expected
735 echo "refs/remotes/origin/foo: $commit_id" \
736 >> $testroot/stdout.expected
738 cmp -s $testroot/stdout
$testroot/stdout.expected
740 if [ $ret -ne 0 ]; then
741 diff -u $testroot/stdout.expected
$testroot/stdout
742 test_done
"$testroot" "$ret"
746 cat > $testroot/got.conf.expected
<<EOF
750 repository "$testroot/repo"
751 branch { "foo" "bar" }
754 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
756 if [ $ret -ne 0 ]; then
757 diff -u $testroot/got.conf.expected \
758 $testroot/repo-clone
/got.conf
759 test_done
"$testroot" "$ret"
763 cat > $testroot/config.expected
<<EOF
765 repositoryformatversion = 0
770 url = ssh://127.0.0.1$testroot/repo
771 fetch = refs/heads/foo:refs/remotes/origin/foo
772 fetch = refs/heads/bar:refs/remotes/origin/bar
773 fetch = refs/tags/*:refs/tags/*
775 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
777 if [ $ret -ne 0 ]; then
778 diff -u $testroot/config.expected \
779 $testroot/repo-clone
/config
781 test_done
"$testroot" "$ret"
784 test_clone_dangling_headref
() {
785 local testroot
=`test_init clone_dangling_headref`
786 local testurl
=ssh://127.0.0.1/$testroot
787 local commit_id
=`git_show_head $testroot/repo`
789 got branch
-r $testroot/repo
-d master
> /dev
/null
790 got branch
-r $testroot/repo
-c $commit_id foo
792 got ref
-l -r $testroot/repo
> $testroot/stdout
794 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
795 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
796 # refs/heads/master is missing because it was deleted above
798 cmp -s $testroot/stdout
$testroot/stdout.expected
800 if [ $ret -ne 0 ]; then
801 diff -u $testroot/stdout.expected
$testroot/stdout
802 test_done
"$testroot" "$ret"
806 got clone
-q -b foo
$testurl/repo
$testroot/repo-clone
808 if [ $ret -ne 0 ]; then
809 echo "got clone command failed unexpectedly" >&2
810 test_done
"$testroot" "$ret"
814 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
816 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
817 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
818 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
820 cmp -s $testroot/stdout
$testroot/stdout.expected
822 if [ $ret -ne 0 ]; then
823 diff -u $testroot/stdout.expected
$testroot/stdout
824 test_done
"$testroot" "$ret"
828 cat > $testroot/got.conf.expected
<<EOF
832 repository "$testroot/repo"
836 cmp -s $testroot/repo-clone
/got.conf
$testroot/got.conf.expected
838 if [ $ret -ne 0 ]; then
839 diff -u $testroot/got.conf.expected \
840 $testroot/repo-clone
/got.conf
841 test_done
"$testroot" "$ret"
845 cat > $testroot/config.expected
<<EOF
847 repositoryformatversion = 0
852 url = ssh://127.0.0.1$testroot/repo
853 fetch = refs/heads/foo:refs/remotes/origin/foo
854 fetch = refs/tags/*:refs/tags/*
856 cmp -s $testroot/repo-clone
/config
$testroot/config.expected
858 if [ $ret -ne 0 ]; then
859 diff -u $testroot/config.expected \
860 $testroot/repo-clone
/config
862 test_done
"$testroot" "$ret"
866 run_test test_clone_basic
867 run_test test_clone_quoting
868 run_test test_clone_list
869 run_test test_clone_branch
870 run_test test_clone_all
871 run_test test_clone_mirror
872 run_test test_clone_mirror_all
873 run_test test_clone_reference
874 run_test test_clone_branch_and_reference
875 run_test test_clone_reference_mirror
876 run_test test_clone_multiple_branches
877 run_test test_clone_dangling_headref