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 fetch_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 echo "modified alpha" > $testroot/repo/alpha
33 git_commit $testroot/repo -m "modified alpha"
34 local commit_id2=`git_show_head $testroot/repo`
36 got ref -l -r $testroot/repo-clone > $testroot/stdout
38 if [ $ret -ne 0 ]; then
39 echo "got ref command failed unexpectedly" >&2
40 test_done "$testroot" "$ret"
44 got fetch -q -r $testroot/repo-clone > $testroot/stdout \
47 if [ $ret -ne 0 ]; then
48 echo "got fetch command failed unexpectedly" >&2
49 test_done "$testroot" "$ret"
53 echo -n > $testroot/stdout.expected
55 cmp -s $testroot/stdout $testroot/stdout.expected
57 if [ $ret -ne 0 ]; then
58 diff -u $testroot/stdout.expected $testroot/stdout
59 test_done "$testroot" "$ret"
63 got log -l0 -p -r $testroot/repo > $testroot/log-repo
65 if [ $ret -ne 0 ]; then
66 echo "got log command failed unexpectedly" >&2
67 test_done "$testroot" "$ret"
70 got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
72 if [ $ret -ne 0 ]; then
73 echo "got log command failed unexpectedly" >&2
74 test_done "$testroot" "$ret"
77 cmp -s $testroot/log-repo $testroot/log-repo-clone
79 if [ $ret -ne 0 ]; then
80 echo "log -p output of cloned repository differs" >&2
81 test_done "$testroot" "$ret"
85 got ref -l -r $testroot/repo > $testroot/stdout
87 if [ $ret -ne 0 ]; then
88 echo "got ref command failed unexpectedly" >&2
89 test_done "$testroot" "$ret"
93 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
94 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
96 cmp -s $testroot/stdout $testroot/stdout.expected
98 if [ $ret -ne 0 ]; then
99 diff -u $testroot/stdout.expected $testroot/stdout
100 test_done "$testroot" "$ret"
104 got ref -l -r $testroot/repo-clone > $testroot/stdout
106 if [ $ret -ne 0 ]; then
107 echo "got ref command failed unexpectedly" >&2
108 test_done "$testroot" "$ret"
112 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
113 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
114 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
115 >> $testroot/stdout.expected
116 echo "refs/remotes/origin/master: $commit_id2" \
117 >> $testroot/stdout.expected
119 cmp -s $testroot/stdout $testroot/stdout.expected
121 if [ $ret -ne 0 ]; then
122 diff -u $testroot/stdout.expected $testroot/stdout
124 test_done "$testroot" "$ret"
128 local testroot=`test_init fetch_list`
129 local testurl=ssh://127.0.0.1/$testroot
130 local commit_id=`git_show_head $testroot/repo`
132 got branch -r $testroot/repo -c $commit_id foo
133 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
134 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
136 got clone -q $testurl/repo $testroot/repo-clone
138 if [ $ret -ne 0 ]; then
139 echo "got clone command failed unexpectedly" >&2
140 test_done "$testroot" "$ret"
144 (cd $testroot/repo-clone && got fetch -q -l \
145 > $testroot/stdout 2>$testroot/stderr)
147 if [ $ret -ne 0 ]; then
148 echo "got fetch command failed unexpectedly" >&2
149 test_done "$testroot" "$ret"
153 got ref -l -r $testroot/repo > $testroot/stdout.expected
155 cmp -s $testroot/stdout $testroot/stdout.expected
157 if [ $ret -ne 0 ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
160 test_done "$testroot" "$ret"
163 test_fetch_branch() {
164 local testroot=`test_init fetch_branch`
165 local testurl=ssh://127.0.0.1/$testroot
166 local commit_id=`git_show_head $testroot/repo`
168 got clone -q $testurl/repo $testroot/repo-clone
170 if [ $ret -ne 0 ]; then
171 echo "got clone command failed unexpectedly" >&2
172 test_done "$testroot" "$ret"
176 got branch -r $testroot/repo -c $commit_id foo
177 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
178 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
179 local tag_id=`got ref -r $testroot/repo -l \
180 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
182 echo "modified alpha on master" > $testroot/repo/alpha
183 git_commit $testroot/repo -m "modified alpha"
184 local commit_id2=`git_show_head $testroot/repo`
186 (cd $testroot/repo && git checkout -q foo)
187 echo "modified alpha on foo" > $testroot/repo/alpha
188 git_commit $testroot/repo -m "modified alpha"
189 local commit_id3=`git_show_head $testroot/repo`
191 # foo is now the default HEAD branch in $testroot/repo
192 # but got.conf still says to fetch "master"
193 got fetch -q -r $testroot/repo-clone > $testroot/stdout
195 if [ $ret -ne 0 ]; then
196 echo "got fetch command failed unexpectedly" >&2
197 test_done "$testroot" "$ret"
201 echo -n > $testroot/stdout.expected
203 cmp -s $testroot/stdout $testroot/stdout.expected
205 if [ $ret -ne 0 ]; then
206 diff -u $testroot/stdout.expected $testroot/stdout
207 test_done "$testroot" "$ret"
211 got ref -l -r $testroot/repo-clone > $testroot/stdout
213 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
214 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
215 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
216 >> $testroot/stdout.expected
217 echo "refs/remotes/origin/master: $commit_id2" \
218 >> $testroot/stdout.expected
219 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
220 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
222 cmp -s $testroot/stdout $testroot/stdout.expected
224 if [ $ret -ne 0 ]; then
225 diff -u $testroot/stdout.expected $testroot/stdout
226 test_done "$testroot" "$ret"
230 # fetch branch foo via command-line switch
231 got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
233 if [ $ret -ne 0 ]; then
234 echo "got fetch command failed unexpectedly" >&2
235 test_done "$testroot" "$ret"
239 echo -n > $testroot/stdout.expected
241 cmp -s $testroot/stdout $testroot/stdout.expected
243 if [ $ret -ne 0 ]; then
244 diff -u $testroot/stdout.expected $testroot/stdout
245 test_done "$testroot" "$ret"
249 got ref -l -r $testroot/repo-clone > $testroot/stdout
251 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
252 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
253 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
254 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
255 >> $testroot/stdout.expected
256 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
257 echo "refs/remotes/origin/master: $commit_id2" \
258 >> $testroot/stdout.expected
259 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
260 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
262 cmp -s $testroot/stdout $testroot/stdout.expected
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stdout.expected $testroot/stdout
266 test_done "$testroot" "$ret"
270 # got.conf tells us to fetch the 'master' branch by default
271 got fetch -q -r $testroot/repo-clone > $testroot/stdout
273 if [ $ret -ne 0 ]; then
274 echo "got fetch command failed unexpectedly" >&2
275 test_done "$testroot" "$ret"
279 echo -n > $testroot/stdout.expected
281 cmp -s $testroot/stdout $testroot/stdout.expected
283 if [ $ret -ne 0 ]; then
284 diff -u $testroot/stdout.expected $testroot/stdout
285 test_done "$testroot" "$ret"
289 got ref -l -r $testroot/repo-clone > $testroot/stdout
291 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
292 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
293 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
294 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
295 >> $testroot/stdout.expected
296 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
297 echo "refs/remotes/origin/master: $commit_id2" \
298 >> $testroot/stdout.expected
299 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
300 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
302 cmp -s $testroot/stdout $testroot/stdout.expected
304 if [ $ret -ne 0 ]; then
305 diff -u $testroot/stdout.expected $testroot/stdout
306 test_done "$testroot" "$ret"
310 echo "modified beta on foo" > $testroot/repo/beta
311 git_commit $testroot/repo -m "modified beta"
312 local commit_id4=`git_show_head $testroot/repo`
314 # set the default HEAD branch back to master
315 (cd $testroot/repo && git checkout -q master)
317 got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
319 # fetch new commits on branch 'foo', implicitly obtaining the
320 # branch name from a work tree
321 (cd $testroot/wt && got fetch -q > $testroot/stdout)
323 echo -n > $testroot/stdout.expected
325 cmp -s $testroot/stdout $testroot/stdout.expected
327 if [ $ret -ne 0 ]; then
328 diff -u $testroot/stdout.expected $testroot/stdout
329 test_done "$testroot" "$ret"
333 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
334 cut -d ':' -f 2 | tr -d ' ')`
336 got ref -l -r $testroot/repo-clone > $testroot/stdout
338 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
339 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
340 >> $testroot/stdout.expected
341 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
342 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
343 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
344 >> $testroot/stdout.expected
345 echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
346 echo "refs/remotes/origin/master: $commit_id2" \
347 >> $testroot/stdout.expected
348 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
349 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
351 cmp -s $testroot/stdout $testroot/stdout.expected
353 if [ $ret -ne 0 ]; then
354 diff -u $testroot/stdout.expected $testroot/stdout
355 test_done "$testroot" "$ret"
359 # remove default branch information from got.conf
360 sed -i -e "/branch {/d" $testroot/repo-clone/got.conf
362 # make another change on 'foo' and fetch it without got.conf
363 (cd $testroot/repo && git checkout -q foo)
364 echo "modified beta on foo agan" > $testroot/repo/beta
365 git_commit $testroot/repo -m "modified beta"
366 local commit_id5=`git_show_head $testroot/repo`
367 (cd $testroot/repo && git checkout -q master)
369 # fetch new commits on branch 'foo', implicitly obtaining the
370 # branch name from a work tree
371 (cd $testroot/wt && got fetch -q > $testroot/stdout)
373 echo -n > $testroot/stdout.expected
375 cmp -s $testroot/stdout $testroot/stdout.expected
377 if [ $ret -ne 0 ]; then
378 diff -u $testroot/stdout.expected $testroot/stdout
379 test_done "$testroot" "$ret"
383 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
384 cut -d ':' -f 2 | tr -d ' ')`
386 got ref -l -r $testroot/repo-clone > $testroot/stdout
388 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
389 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
390 >> $testroot/stdout.expected
391 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
392 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
393 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
394 >> $testroot/stdout.expected
395 echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
396 echo "refs/remotes/origin/master: $commit_id2" \
397 >> $testroot/stdout.expected
398 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
399 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
401 cmp -s $testroot/stdout $testroot/stdout.expected
403 if [ $ret -ne 0 ]; then
404 diff -u $testroot/stdout.expected $testroot/stdout
406 test_done "$testroot" "$ret"
410 local testroot=`test_init fetch_all`
411 local testurl=ssh://127.0.0.1/$testroot
412 local commit_id=`git_show_head $testroot/repo`
414 got clone -q $testurl/repo $testroot/repo-clone
416 if [ $ret -ne 0 ]; then
417 echo "got clone command failed unexpectedly" >&2
418 test_done "$testroot" "$ret"
422 got branch -r $testroot/repo -c $commit_id foo
423 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
424 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
425 local tag_id=`got ref -r $testroot/repo -l \
426 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
428 got ref -l -r $testroot/repo-clone > $testroot/stdout
430 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
431 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
432 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
433 >> $testroot/stdout.expected
434 echo "refs/remotes/origin/master: $commit_id" \
435 >> $testroot/stdout.expected
436 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
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 got fetch -q -a -r $testroot/repo-clone
448 if [ $ret -ne 0 ]; then
449 echo "got fetch command failed unexpectedly" >&2
450 test_done "$testroot" "$ret"
454 got ref -l -r $testroot/repo-clone > $testroot/stdout
456 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
457 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
458 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
459 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
460 >> $testroot/stdout.expected
461 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
462 echo "refs/remotes/origin/master: $commit_id" \
463 >> $testroot/stdout.expected
464 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
465 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
467 cmp -s $testroot/stdout $testroot/stdout.expected
469 if [ $ret -ne 0 ]; then
470 diff -u $testroot/stdout.expected $testroot/stdout
472 test_done "$testroot" "$ret"
475 test_fetch_empty_packfile() {
476 local testroot=`test_init fetch_empty_packfile`
477 local testurl=ssh://127.0.0.1/$testroot
478 local commit_id=`git_show_head $testroot/repo`
480 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
481 local tag_id=`got ref -r $testroot/repo -l \
482 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
484 got clone -q $testurl/repo $testroot/repo-clone
486 if [ $ret -ne 0 ]; then
487 echo "got clone command failed unexpectedly" >&2
488 test_done "$testroot" "$ret"
492 got branch -r $testroot/repo -c $commit_id foo
493 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
495 got ref -l -r $testroot/repo-clone > $testroot/stdout
497 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
498 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
499 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
500 >> $testroot/stdout.expected
501 echo "refs/remotes/origin/master: $commit_id" \
502 >> $testroot/stdout.expected
503 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
504 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
506 cmp -s $testroot/stdout $testroot/stdout.expected
508 if [ $ret -ne 0 ]; then
509 diff -u $testroot/stdout.expected $testroot/stdout
510 test_done "$testroot" "$ret"
514 got fetch -q -a -r $testroot/repo-clone
516 if [ $ret -ne 0 ]; then
517 echo "got fetch command failed unexpectedly" >&2
518 test_done "$testroot" "$ret"
522 got ref -l -r $testroot/repo-clone > $testroot/stdout
524 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
525 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
526 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
527 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
528 >> $testroot/stdout.expected
529 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
530 echo "refs/remotes/origin/master: $commit_id" \
531 >> $testroot/stdout.expected
532 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
533 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
535 cmp -s $testroot/stdout $testroot/stdout.expected
537 if [ $ret -ne 0 ]; then
538 diff -u $testroot/stdout.expected $testroot/stdout
540 test_done "$testroot" "$ret"
543 test_fetch_delete_branch() {
544 local testroot=`test_init fetch_delete_branch`
545 local testurl=ssh://127.0.0.1/$testroot
546 local commit_id=`git_show_head $testroot/repo`
549 got branch -r $testroot/repo -c $commit_id foo
550 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
551 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
552 local tag_id=`got ref -r $testroot/repo -l \
553 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
555 got clone -a -q $testurl/repo $testroot/repo-clone
557 if [ $ret -ne 0 ]; then
558 echo "got clone command failed unexpectedly" >&2
559 test_done "$testroot" "$ret"
563 got ref -l -r $testroot/repo-clone > $testroot/stdout
565 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
566 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
567 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
568 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
569 >> $testroot/stdout.expected
570 echo "refs/remotes/origin/foo: $commit_id" \
571 >> $testroot/stdout.expected
572 echo "refs/remotes/origin/master: $commit_id" \
573 >> $testroot/stdout.expected
574 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
575 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
577 cmp -s $testroot/stdout $testroot/stdout.expected
579 if [ $ret -ne 0 ]; then
580 diff -u $testroot/stdout.expected $testroot/stdout
581 test_done "$testroot" "$ret"
585 got branch -r $testroot/repo -d foo >/dev/null
587 got fetch -q -r $testroot/repo-clone
589 if [ $ret -ne 0 ]; then
590 echo "got fetch command failed unexpectedly" >&2
591 test_done "$testroot" "$ret"
595 got ref -l -r $testroot/repo-clone > $testroot/stdout
597 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
598 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
599 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
600 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
601 >> $testroot/stdout.expected
602 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
603 echo "refs/remotes/origin/master: $commit_id" \
604 >> $testroot/stdout.expected
605 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
606 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
608 cmp -s $testroot/stdout $testroot/stdout.expected
610 if [ $ret -ne 0 ]; then
611 diff -u $testroot/stdout.expected $testroot/stdout
612 test_done "$testroot" "$ret"
616 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
618 if [ $ret -ne 0 ]; then
619 echo "got fetch command failed unexpectedly" >&2
620 test_done "$testroot" "$ret"
624 echo -n > $testroot/stdout.expected
626 cmp -s $testroot/stdout $testroot/stdout.expected
628 if [ $ret -ne 0 ]; then
629 diff -u $testroot/stdout.expected $testroot/stdout
630 test_done "$testroot" "$ret"
634 got ref -l -r $testroot/repo-clone > $testroot/stdout
636 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
637 # refs/heads/foo is now deleted
638 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
639 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
640 >> $testroot/stdout.expected
641 # refs/remotes/origin/foo is now deleted
642 echo "refs/remotes/origin/master: $commit_id" \
643 >> $testroot/stdout.expected
644 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
645 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
647 cmp -s $testroot/stdout $testroot/stdout.expected
649 if [ $ret -ne 0 ]; then
650 diff -u $testroot/stdout.expected $testroot/stdout
652 test_done "$testroot" "$ret"
656 test_fetch_delete_branch_mirror() {
657 local testroot=`test_init fetch_delete_branch_mirror`
658 local testurl=ssh://127.0.0.1/$testroot
659 local commit_id=`git_show_head $testroot/repo`
661 got branch -r $testroot/repo -c $commit_id foo
662 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
663 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
664 local tag_id=`got ref -r $testroot/repo -l \
665 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
667 got clone -a -m -q $testurl/repo $testroot/repo-clone
669 if [ $ret -ne 0 ]; then
670 echo "got clone command failed unexpectedly" >&2
671 test_done "$testroot" "$ret"
675 got ref -l -r $testroot/repo-clone > $testroot/stdout
677 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
678 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
679 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
680 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
681 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
683 cmp -s $testroot/stdout $testroot/stdout.expected
685 if [ $ret -ne 0 ]; then
686 diff -u $testroot/stdout.expected $testroot/stdout
687 test_done "$testroot" "$ret"
691 got branch -r $testroot/repo -d foo >/dev/null
693 got fetch -q -r $testroot/repo-clone
695 if [ $ret -ne 0 ]; then
696 echo "got fetch command failed unexpectedly" >&2
697 test_done "$testroot" "$ret"
701 got ref -l -r $testroot/repo-clone > $testroot/stdout
703 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
704 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
705 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
706 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
707 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
709 cmp -s $testroot/stdout $testroot/stdout.expected
711 if [ $ret -ne 0 ]; then
712 diff -u $testroot/stdout.expected $testroot/stdout
713 test_done "$testroot" "$ret"
717 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
719 if [ $ret -ne 0 ]; then
720 echo "got fetch command failed unexpectedly" >&2
721 test_done "$testroot" "$ret"
725 echo -n > $testroot/stdout.expected
727 cmp -s $testroot/stdout $testroot/stdout.expected
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/stdout.expected $testroot/stdout
731 test_done "$testroot" "$ret"
735 got ref -l -r $testroot/repo-clone > $testroot/stdout
737 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
738 # refs/heads/foo is now deleted
739 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
740 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
741 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
743 cmp -s $testroot/stdout $testroot/stdout.expected
745 if [ $ret -ne 0 ]; then
746 diff -u $testroot/stdout.expected $testroot/stdout
748 test_done "$testroot" "$ret"
752 test_fetch_update_tag() {
753 local testroot=`test_init fetch_update_tag`
754 local testurl=ssh://127.0.0.1/$testroot
755 local commit_id=`git_show_head $testroot/repo`
758 got branch -r $testroot/repo -c $commit_id foo
759 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
760 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
761 local tag_id=`got ref -r $testroot/repo -l \
762 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
764 got clone -a -q $testurl/repo $testroot/repo-clone
766 if [ $ret -ne 0 ]; then
767 echo "got clone command failed unexpectedly" >&2
768 test_done "$testroot" "$ret"
772 echo "modified alpha on master" > $testroot/repo/alpha
773 git_commit $testroot/repo -m "modified alpha"
774 local commit_id2=`git_show_head $testroot/repo`
776 got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
777 got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
778 local tag_id2=`got ref -r $testroot/repo -l \
779 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
781 got ref -l -r $testroot/repo-clone > $testroot/stdout
783 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
784 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
785 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
786 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
787 >> $testroot/stdout.expected
788 echo "refs/remotes/origin/foo: $commit_id" \
789 >> $testroot/stdout.expected
790 echo "refs/remotes/origin/master: $commit_id" \
791 >> $testroot/stdout.expected
792 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
793 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
795 cmp -s $testroot/stdout $testroot/stdout.expected
797 if [ $ret -ne 0 ]; then
798 diff -u $testroot/stdout.expected $testroot/stdout
799 test_done "$testroot" "$ret"
803 got fetch -a -q -r $testroot/repo-clone
805 if [ $ret -ne 0 ]; then
806 echo "got fetch command failed unexpectedly" >&2
807 test_done "$testroot" "$ret"
811 got ref -l -r $testroot/repo-clone > $testroot/stdout
813 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
814 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
815 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
816 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
817 >> $testroot/stdout.expected
818 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
819 echo "refs/remotes/origin/master: $commit_id2" \
820 >> $testroot/stdout.expected
821 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
822 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
824 cmp -s $testroot/stdout $testroot/stdout.expected
826 if [ $ret -ne 0 ]; then
827 diff -u $testroot/stdout.expected $testroot/stdout
828 test_done "$testroot" "$ret"
832 got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
833 tail -n 1 > $testroot/stdout
835 if [ $ret -ne 0 ]; then
836 echo "got fetch command failed unexpectedly" >&2
837 test_done "$testroot" "$ret"
841 echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
842 > $testroot/stdout.expected
844 cmp -s $testroot/stdout $testroot/stdout.expected
846 if [ $ret -ne 0 ]; then
847 diff -u $testroot/stdout.expected $testroot/stdout
848 test_done "$testroot" "$ret"
852 got ref -l -r $testroot/repo-clone > $testroot/stdout
854 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
855 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
856 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
857 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
858 >> $testroot/stdout.expected
859 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
860 echo "refs/remotes/origin/master: $commit_id2" \
861 >> $testroot/stdout.expected
862 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
863 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
865 cmp -s $testroot/stdout $testroot/stdout.expected
867 if [ $ret -ne 0 ]; then
868 diff -u $testroot/stdout.expected $testroot/stdout
869 test_done "$testroot" "$ret"
873 got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
875 if [ $ret -ne 0 ]; then
876 echo "got fetch command failed unexpectedly" >&2
877 test_done "$testroot" "$ret"
881 echo -n > $testroot/stdout.expected
883 cmp -s $testroot/stdout $testroot/stdout.expected
885 if [ $ret -ne 0 ]; then
886 diff -u $testroot/stdout.expected $testroot/stdout
887 test_done "$testroot" "$ret"
891 got ref -l -r $testroot/repo-clone > $testroot/stdout
893 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
894 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
895 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
896 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
897 >> $testroot/stdout.expected
898 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
899 echo "refs/remotes/origin/master: $commit_id2" \
900 >> $testroot/stdout.expected
901 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
902 echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
904 cmp -s $testroot/stdout $testroot/stdout.expected
906 if [ $ret -ne 0 ]; then
907 diff -u $testroot/stdout.expected $testroot/stdout
909 test_done "$testroot" "$ret"
912 test_fetch_reference() {
913 local testroot=`test_init fetch_reference`
914 local testurl=ssh://127.0.0.1/$testroot
915 local commit_id=`git_show_head $testroot/repo`
917 got clone -q $testurl/repo $testroot/repo-clone
919 if [ $ret -ne 0 ]; then
920 echo "got clone command failed unexpectedly" >&2
921 test_done "$testroot" "$ret"
925 got branch -r $testroot/repo -c $commit_id foo
926 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
927 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
928 local tag_id=`got ref -r $testroot/repo -l \
929 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
931 echo "modified alpha on master" > $testroot/repo/alpha
932 git_commit $testroot/repo -m "modified alpha"
933 local commit_id2=`git_show_head $testroot/repo`
935 (cd $testroot/repo && git checkout -q foo)
936 echo "modified alpha on foo" > $testroot/repo/alpha
937 git_commit $testroot/repo -m "modified alpha"
938 local commit_id3=`git_show_head $testroot/repo`
939 (cd $testroot/repo && git checkout -q master)
941 got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
942 > $testroot/stdout 2> $testroot/stderr
944 if [ $ret -eq 0 ]; then
945 echo "got fetch command succeeded unexpectedly" >&2
946 test_done "$testroot" "1"
950 echo -n > $testroot/stdout.expected
952 cmp -s $testroot/stdout $testroot/stdout.expected
954 if [ $ret -ne 0 ]; then
955 diff -u $testroot/stdout.expected $testroot/stdout
956 test_done "$testroot" "$ret"
960 echo "got: refs/remotes/origin/main: reference cannot be fetched" \
961 > $testroot/stderr.expected
963 cmp -s $testroot/stderr $testroot/stderr.expected
965 if [ $ret -ne 0 ]; then
966 diff -u $testroot/stderr.expected $testroot/stderr
967 test_done "$testroot" "$ret"
971 got fetch -q -r $testroot/repo-clone -R refs/hoo
973 if [ $ret -ne 0 ]; then
974 echo "got fetch command failed unexpectedly" >&2
975 test_done "$testroot" "$ret"
979 got ref -l -r $testroot/repo-clone > $testroot/stdout
981 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
982 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
983 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
984 >> $testroot/stdout.expected
985 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
986 >> $testroot/stdout.expected
987 echo "refs/remotes/origin/master: $commit_id2" \
988 >> $testroot/stdout.expected
989 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
991 cmp -s $testroot/stdout $testroot/stdout.expected
993 if [ $ret -ne 0 ]; then
994 diff -u $testroot/stdout.expected $testroot/stdout
996 test_done "$testroot" "$ret"
1000 test_fetch_replace_symref() {
1001 local testroot=`test_init fetch_replace_symref`
1002 local testurl=ssh://127.0.0.1/$testroot
1003 local commit_id=`git_show_head $testroot/repo`
1005 got clone -m -q $testurl/repo $testroot/repo-clone
1007 if [ $ret -ne 0 ]; then
1008 echo "got clone command failed unexpectedly" >&2
1009 test_done "$testroot" "$ret"
1013 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1014 got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1016 got ref -l -r $testroot/repo-clone > $testroot/stdout
1018 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1019 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1020 echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1022 cmp -s $testroot/stdout $testroot/stdout.expected
1024 if [ $ret -ne 0 ]; then
1025 diff -u $testroot/stdout.expected $testroot/stdout
1026 test_done "$testroot" "$ret"
1030 got fetch -r $testroot/repo-clone -R refs/hoo \
1031 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1033 if [ $ret -ne 0 ]; then
1034 echo "got fetch command failed unexpectedly" >&2
1035 test_done "$testroot" "$ret"
1039 echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1040 > $testroot/stdout.expected
1042 cmp -s $testroot/stdout $testroot/stdout.expected
1044 if [ $ret -ne 0 ]; then
1045 diff -u $testroot/stdout.expected $testroot/stdout
1046 test_done "$testroot" "$ret"
1050 got ref -l -r $testroot/repo-clone > $testroot/stdout
1052 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1053 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1054 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1056 cmp -s $testroot/stdout $testroot/stdout.expected
1058 if [ $ret -ne 0 ]; then
1059 diff -u $testroot/stdout.expected $testroot/stdout
1061 test_done "$testroot" "$ret"
1065 test_fetch_update_headref() {
1066 local testroot=`test_init fetch_update_headref`
1067 local testurl=ssh://127.0.0.1/$testroot
1068 local commit_id=`git_show_head $testroot/repo`
1070 got clone -q $testurl/repo $testroot/repo-clone
1072 if [ $ret -ne 0 ]; then
1073 echo "got clone command failed unexpectedly" >&2
1074 test_done "$testroot" "$ret"
1078 got ref -l -r $testroot/repo-clone > $testroot/stdout
1080 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1081 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1082 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1083 >> $testroot/stdout.expected
1084 echo "refs/remotes/origin/master: $commit_id" \
1085 >> $testroot/stdout.expected
1087 cmp -s $testroot/stdout $testroot/stdout.expected
1089 if [ $ret -ne 0 ]; then
1090 diff -u $testroot/stdout.expected $testroot/stdout
1091 test_done "$testroot" "$ret"
1095 got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1096 got ref -r $testroot/repo -s refs/heads/foo HEAD
1097 got ref -l -r $testroot/repo > $testroot/stdout
1099 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1100 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1101 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1103 cmp -s $testroot/stdout $testroot/stdout.expected
1105 if [ $ret -ne 0 ]; then
1106 diff -u $testroot/stdout.expected $testroot/stdout
1107 test_done "$testroot" "$ret"
1111 got fetch -q -r $testroot/repo-clone
1113 got ref -l -r $testroot/repo-clone > $testroot/stdout
1115 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1116 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1117 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1118 >> $testroot/stdout.expected
1119 echo "refs/remotes/origin/master: $commit_id" \
1120 >> $testroot/stdout.expected
1122 cmp -s $testroot/stdout $testroot/stdout.expected
1124 if [ $ret -ne 0 ]; then
1125 diff -u $testroot/stdout.expected $testroot/stdout
1126 test_done "$testroot" "$ret"
1130 got fetch -q -r $testroot/repo-clone -a
1132 got ref -l -r $testroot/repo-clone > $testroot/stdout
1134 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1135 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1136 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1137 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1138 >> $testroot/stdout.expected
1139 echo "refs/remotes/origin/foo: $commit_id" \
1140 >> $testroot/stdout.expected
1141 echo "refs/remotes/origin/master: $commit_id" \
1142 >> $testroot/stdout.expected
1144 cmp -s $testroot/stdout $testroot/stdout.expected
1146 if [ $ret -ne 0 ]; then
1147 diff -u $testroot/stdout.expected $testroot/stdout
1149 test_done "$testroot" "$ret"
1152 test_fetch_headref_deleted_locally() {
1153 local testroot=`test_init fetch_headref_deleted_locally`
1154 local testurl=ssh://127.0.0.1/$testroot
1155 local commit_id=`git_show_head $testroot/repo`
1157 got clone -q $testurl/repo $testroot/repo-clone
1159 if [ $ret -ne 0 ]; then
1160 echo "got clone command failed unexpectedly" >&2
1161 test_done "$testroot" "$ret"
1165 got ref -l -r $testroot/repo-clone > $testroot/stdout
1167 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1168 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1169 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1170 >> $testroot/stdout.expected
1171 echo "refs/remotes/origin/master: $commit_id" \
1172 >> $testroot/stdout.expected
1174 cmp -s $testroot/stdout $testroot/stdout.expected
1176 if [ $ret -ne 0 ]; then
1177 diff -u $testroot/stdout.expected $testroot/stdout
1178 test_done "$testroot" "$ret"
1182 got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1184 got fetch -q -r $testroot/repo-clone
1186 if [ $ret -ne 0 ]; then
1187 echo "got fetch command failed unexpectedly" >&2
1188 test_done "$testroot" "$ret"
1191 got ref -l -r $testroot/repo-clone > $testroot/stdout
1193 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1194 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1195 # refs/remotes/origin/HEAD has been restored:
1196 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1197 >> $testroot/stdout.expected
1198 echo "refs/remotes/origin/master: $commit_id" \
1199 >> $testroot/stdout.expected
1201 cmp -s $testroot/stdout $testroot/stdout.expected
1203 if [ $ret -ne 0 ]; then
1204 diff -u $testroot/stdout.expected $testroot/stdout
1206 test_done "$testroot" "$ret"
1209 test_fetch_gotconfig_remote_repo() {
1210 local testroot=`test_init fetch_gotconfig_remote_repo`
1211 local testurl=ssh://127.0.0.1/$testroot
1212 local commit_id=`git_show_head $testroot/repo`
1214 got branch -r $testroot/repo -c $commit_id foo
1215 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1216 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1218 got clone -q $testurl/repo $testroot/repo-clone
1220 if [ $ret -ne 0 ]; then
1221 echo "got clone command failed unexpectedly" >&2
1222 test_done "$testroot" "$ret"
1226 cat > $testroot/repo-clone/got.conf <<EOF
1230 repository "$testroot/repo"
1236 repository "$testroot/does-not-exist"
1239 echo "got: nonexistent: remote repository not found" \
1240 > $testroot/stderr.expected
1241 (cd $testroot/repo-clone && got fetch -q nonexistent \
1242 > $testroot/stdout 2> $testroot/stderr)
1244 if [ $ret -eq 0 ]; then
1245 echo "got fetch command succeeded unexpectedly" >&2
1246 diff -u $testroot/stderr.expected $testroot/stderr
1247 test_done "$testroot" "1"
1251 (cd $testroot/repo-clone && got fetch -q -l foobar \
1254 if [ $ret -ne 0 ]; then
1255 echo "got fetch command failed unexpectedly" >&2
1256 test_done "$testroot" "$ret"
1260 got ref -l -r $testroot/repo > $testroot/stdout.expected
1262 cmp -s $testroot/stdout $testroot/stdout.expected
1264 if [ $ret -ne 0 ]; then
1265 diff -u $testroot/stdout.expected $testroot/stdout
1266 test_done "$testroot" "$ret"
1270 got checkout $testroot/repo $testroot/wt > /dev/null
1272 cat > $testroot/wt/.got/got.conf <<EOF
1276 repository "$testroot/repo"
1279 (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1281 if [ $ret -ne 0 ]; then
1282 echo "got fetch command failed unexpectedly" >&2
1283 test_done "$testroot" "$ret"
1287 got ref -l -r $testroot/repo > $testroot/stdout.expected
1289 cmp -s $testroot/stdout $testroot/stdout.expected
1291 if [ $ret -ne 0 ]; then
1292 diff -u $testroot/stdout.expected $testroot/stdout
1293 test_done "$testroot" "$ret"
1297 cat > $testroot/repo-clone/got.conf <<EOF
1301 repository "$testroot/repo"
1303 reference { "hoo/boo/zoo" }
1306 (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1308 local tag_id=`got ref -r $testroot/repo -l \
1309 | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1310 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1311 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1312 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1313 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1314 >> $testroot/stdout.expected
1315 echo "refs/remotes/origin/foo: $commit_id" \
1316 >> $testroot/stdout.expected
1317 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1318 >> $testroot/stdout.expected
1319 echo "refs/remotes/origin/master: $commit_id" \
1320 >> $testroot/stdout.expected
1321 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1323 got ref -l -r $testroot/repo-clone > $testroot/stdout
1325 cmp -s $testroot/stdout $testroot/stdout.expected
1327 if [ $ret -ne 0 ]; then
1328 diff -u $testroot/stdout.expected $testroot/stdout
1330 test_done "$testroot" "$ret"
1333 test_fetch_delete_remote_refs() {
1334 local testroot=`test_init fetch_delete_remote_refs`
1335 local testurl=ssh://127.0.0.1/$testroot
1336 local commit_id=`git_show_head $testroot/repo`
1338 got clone -q $testurl/repo $testroot/repo-clone
1340 if [ $ret -ne 0 ]; then
1341 echo "got clone command failed unexpectedly" >&2
1342 test_done "$testroot" "$ret"
1346 got ref -l -r $testroot/repo-clone > $testroot/stdout
1348 if [ $ret -ne 0 ]; then
1349 echo "got ref command failed unexpectedly" >&2
1350 test_done "$testroot" "$ret"
1354 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1355 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1356 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1357 >> $testroot/stdout.expected
1358 echo "refs/remotes/origin/master: $commit_id" \
1359 >> $testroot/stdout.expected
1361 cmp -s $testroot/stdout $testroot/stdout.expected
1363 if [ $ret -ne 0 ]; then
1364 diff -u $testroot/stdout.expected $testroot/stdout
1365 test_done "$testroot" "$ret"
1369 got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1372 if [ $ret -eq 0 ]; then
1373 echo "got fetch command succeeded unexpectedly" >&2
1374 test_done "$testroot" "$ret"
1378 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1379 cmp -s $testroot/stderr $testroot/stderr.expected
1381 if [ $ret -ne 0 ]; then
1382 diff -u $testroot/stderr.expected $testroot/stderr
1383 test_done "$testroot" "$ret"
1387 got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1390 if [ $ret -ne 0 ]; then
1391 echo "got fetch command failed unexpectedly" >&2
1392 test_done "$testroot" "$ret"
1396 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1397 echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1398 echo "Deleted refs/remotes/origin/master: $commit_id" \
1399 >> $testroot/stdout.expected
1401 cmp -s $testroot/stdout $testroot/stdout.expected
1403 if [ $ret -ne 0 ]; then
1404 diff -u $testroot/stdout.expected $testroot/stdout
1405 test_done "$testroot" "$ret"
1409 got ref -l -r $testroot/repo-clone > $testroot/stdout
1411 if [ $ret -ne 0 ]; then
1412 echo "got ref command failed unexpectedly" >&2
1413 test_done "$testroot" "$ret"
1417 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1418 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1420 cmp -s $testroot/stdout $testroot/stdout.expected
1422 if [ $ret -ne 0 ]; then
1423 diff -u $testroot/stdout.expected $testroot/stdout
1425 test_done "$testroot" "$ret"
1430 run_test test_fetch_basic
1431 run_test test_fetch_list
1432 run_test test_fetch_branch
1433 run_test test_fetch_all
1434 run_test test_fetch_empty_packfile
1435 run_test test_fetch_delete_branch
1436 run_test test_fetch_delete_branch_mirror
1437 run_test test_fetch_update_tag
1438 run_test test_fetch_reference
1439 run_test test_fetch_replace_symref
1440 run_test test_fetch_update_headref
1441 run_test test_fetch_headref_deleted_locally
1442 run_test test_fetch_gotconfig_remote_repo
1443 run_test test_fetch_delete_remote_refs