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 git
-C $testroot/repo 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 and should be
192 # fetched as the clone's remote HEAD symref target no longer matches
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/foo: $commit_id3" >> $testroot/stdout.expected
215 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
216 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
217 >> $testroot/stdout.expected
218 echo "refs/remotes/origin/foo: $commit_id3" \
219 >> $testroot/stdout.expected
220 echo "refs/remotes/origin/master: $commit_id2" \
221 >> $testroot/stdout.expected
222 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
223 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
225 cmp -s $testroot/stdout
$testroot/stdout.expected
227 if [ $ret -ne 0 ]; then
228 diff -u $testroot/stdout.expected
$testroot/stdout
229 test_done
"$testroot" "$ret"
233 # fetch branch foo via command-line switch
234 got fetch
-q -r $testroot/repo-clone
-b foo
> $testroot/stdout
236 if [ $ret -ne 0 ]; then
237 echo "got fetch command failed unexpectedly" >&2
238 test_done
"$testroot" "$ret"
242 echo -n > $testroot/stdout.expected
244 cmp -s $testroot/stdout
$testroot/stdout.expected
246 if [ $ret -ne 0 ]; then
247 diff -u $testroot/stdout.expected
$testroot/stdout
248 test_done
"$testroot" "$ret"
252 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
254 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
255 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
256 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
257 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
258 >> $testroot/stdout.expected
259 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
260 echo "refs/remotes/origin/master: $commit_id2" \
261 >> $testroot/stdout.expected
262 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
263 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
265 cmp -s $testroot/stdout
$testroot/stdout.expected
267 if [ $ret -ne 0 ]; then
268 diff -u $testroot/stdout.expected
$testroot/stdout
269 test_done
"$testroot" "$ret"
273 # got.conf tells us to fetch the 'master' branch by default
274 got fetch
-q -r $testroot/repo-clone
> $testroot/stdout
276 if [ $ret -ne 0 ]; then
277 echo "got fetch command failed unexpectedly" >&2
278 test_done
"$testroot" "$ret"
282 echo -n > $testroot/stdout.expected
284 cmp -s $testroot/stdout
$testroot/stdout.expected
286 if [ $ret -ne 0 ]; then
287 diff -u $testroot/stdout.expected
$testroot/stdout
288 test_done
"$testroot" "$ret"
292 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
294 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
295 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
296 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
297 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
298 >> $testroot/stdout.expected
299 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
300 echo "refs/remotes/origin/master: $commit_id2" \
301 >> $testroot/stdout.expected
302 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
303 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
305 cmp -s $testroot/stdout
$testroot/stdout.expected
307 if [ $ret -ne 0 ]; then
308 diff -u $testroot/stdout.expected
$testroot/stdout
309 test_done
"$testroot" "$ret"
313 echo "modified beta on foo" > $testroot/repo
/beta
314 git_commit
$testroot/repo
-m "modified beta"
315 local commit_id4
=`git_show_head $testroot/repo`
317 # set the default HEAD branch back to master
318 git
-C $testroot/repo checkout
-q master
320 got checkout
-b foo
$testroot/repo-clone
$testroot/wt
> /dev
/null
322 # fetch new commits on branch 'foo', implicitly obtaining the
323 # branch name from a work tree
324 (cd $testroot/wt
&& got fetch
-q > $testroot/stdout
)
326 echo -n > $testroot/stdout.expected
328 cmp -s $testroot/stdout
$testroot/stdout.expected
330 if [ $ret -ne 0 ]; then
331 diff -u $testroot/stdout.expected
$testroot/stdout
332 test_done
"$testroot" "$ret"
336 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
337 cut -d ':' -f 2 | tr -d ' ')`
339 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
341 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
342 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
343 >> $testroot/stdout.expected
344 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
345 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
346 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
347 >> $testroot/stdout.expected
348 echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
349 echo "refs/remotes/origin/master: $commit_id2" \
350 >> $testroot/stdout.expected
351 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
352 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
354 cmp -s $testroot/stdout
$testroot/stdout.expected
356 if [ $ret -ne 0 ]; then
357 diff -u $testroot/stdout.expected
$testroot/stdout
358 test_done
"$testroot" "$ret"
362 # remove default branch information from got.conf
363 ed
-s $testroot/repo-clone
/got.conf
<<-EOF
368 # make another change on 'foo' and fetch it without got.conf
369 git
-C $testroot/repo checkout
-q foo
370 echo "modified beta on foo agan" > $testroot/repo
/beta
371 git_commit
$testroot/repo
-m "modified beta"
372 local commit_id5
=`git_show_head $testroot/repo`
373 git
-C $testroot/repo checkout
-q master
375 # fetch new commits on branch 'foo', implicitly obtaining the
376 # branch name from a work tree
377 (cd $testroot/wt
&& got fetch
-q > $testroot/stdout
)
379 echo -n > $testroot/stdout.expected
381 cmp -s $testroot/stdout
$testroot/stdout.expected
383 if [ $ret -ne 0 ]; then
384 diff -u $testroot/stdout.expected
$testroot/stdout
385 test_done
"$testroot" "$ret"
389 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
390 cut -d ':' -f 2 | tr -d ' ')`
392 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
394 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
395 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
396 >> $testroot/stdout.expected
397 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
398 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
399 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
400 >> $testroot/stdout.expected
401 echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
402 echo "refs/remotes/origin/master: $commit_id2" \
403 >> $testroot/stdout.expected
404 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
405 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
407 cmp -s $testroot/stdout
$testroot/stdout.expected
409 if [ $ret -ne 0 ]; then
410 diff -u $testroot/stdout.expected
$testroot/stdout
412 test_done
"$testroot" "$ret"
416 local testroot
=`test_init fetch_all`
417 local testurl
=ssh://127.0.0.1/$testroot
418 local commit_id
=`git_show_head $testroot/repo`
420 got clone
-q $testurl/repo
$testroot/repo-clone
422 if [ $ret -ne 0 ]; then
423 echo "got clone command failed unexpectedly" >&2
424 test_done
"$testroot" "$ret"
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
437 cmp -s $testroot/stdout
$testroot/stdout.expected
439 if [ $ret -ne 0 ]; then
440 diff -u $testroot/stdout.expected
$testroot/stdout
441 test_done
"$testroot" "$ret"
445 got branch
-r $testroot/repo
-c $commit_id foo
446 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
447 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
448 local tag_id
=`got ref -r $testroot/repo -l \
449 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
451 got fetch
-q -a -r $testroot/repo-clone
453 if [ $ret -ne 0 ]; then
454 echo "got fetch command failed unexpectedly" >&2
455 test_done
"$testroot" "$ret"
459 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
461 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
462 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
463 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
464 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
465 >> $testroot/stdout.expected
466 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
467 echo "refs/remotes/origin/master: $commit_id" \
468 >> $testroot/stdout.expected
469 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
470 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
472 cmp -s $testroot/stdout
$testroot/stdout.expected
474 if [ $ret -ne 0 ]; then
475 diff -u $testroot/stdout.expected
$testroot/stdout
478 git
-C $testroot/repo checkout
-q foo
479 echo "modified beta on foo" > $testroot/repo
/beta
480 git_commit
$testroot/repo
-m "modified beta"
481 local commit_id2
=`git_show_head $testroot/repo`
483 # set the default HEAD branch back to master
484 git
-C $testroot/repo checkout
-q master
486 # remove default branch from got.conf, fetch all branches
487 ed
-s $testroot/repo-clone
/got.conf
<<-EOF
489 fetch_all_branches yes
494 got fetch
-q -r $testroot/repo-clone
496 if [ $ret -ne 0 ]; then
497 echo "got fetch command failed unexpectedly" >&2
498 test_done
"$testroot" "$ret"
502 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
504 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
505 echo "refs/heads/foo: $commit_id" >> $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/foo: $commit_id2" >> $testroot/stdout.expected
510 echo "refs/remotes/origin/master: $commit_id" \
511 >> $testroot/stdout.expected
512 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
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
520 test_done
"$testroot" "$ret"
523 test_fetch_empty_packfile
() {
524 local testroot
=`test_init fetch_empty_packfile`
525 local testurl
=ssh://127.0.0.1/$testroot
526 local commit_id
=`git_show_head $testroot/repo`
528 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
529 local tag_id
=`got ref -r $testroot/repo -l \
530 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
532 got clone
-q $testurl/repo
$testroot/repo-clone
534 if [ $ret -ne 0 ]; then
535 echo "got clone command failed unexpectedly" >&2
536 test_done
"$testroot" "$ret"
540 got branch
-r $testroot/repo
-c $commit_id foo
541 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
543 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
545 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
546 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
547 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
548 >> $testroot/stdout.expected
549 echo "refs/remotes/origin/master: $commit_id" \
550 >> $testroot/stdout.expected
551 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
552 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
554 cmp -s $testroot/stdout
$testroot/stdout.expected
556 if [ $ret -ne 0 ]; then
557 diff -u $testroot/stdout.expected
$testroot/stdout
558 test_done
"$testroot" "$ret"
562 got fetch
-q -a -r $testroot/repo-clone
564 if [ $ret -ne 0 ]; then
565 echo "got fetch command failed unexpectedly" >&2
566 test_done
"$testroot" "$ret"
570 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
572 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
573 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
574 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
575 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
576 >> $testroot/stdout.expected
577 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
578 echo "refs/remotes/origin/master: $commit_id" \
579 >> $testroot/stdout.expected
580 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
581 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
583 cmp -s $testroot/stdout
$testroot/stdout.expected
585 if [ $ret -ne 0 ]; then
586 diff -u $testroot/stdout.expected
$testroot/stdout
588 test_done
"$testroot" "$ret"
591 test_fetch_delete_branch
() {
592 local testroot
=`test_init fetch_delete_branch`
593 local testurl
=ssh://127.0.0.1/$testroot
594 local commit_id
=`git_show_head $testroot/repo`
597 got branch
-r $testroot/repo
-c $commit_id foo
598 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
599 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
600 local tag_id
=`got ref -r $testroot/repo -l \
601 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
603 got clone
-a -q $testurl/repo
$testroot/repo-clone
605 if [ $ret -ne 0 ]; then
606 echo "got clone command failed unexpectedly" >&2
607 test_done
"$testroot" "$ret"
611 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
613 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
614 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
615 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
616 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
617 >> $testroot/stdout.expected
618 echo "refs/remotes/origin/foo: $commit_id" \
619 >> $testroot/stdout.expected
620 echo "refs/remotes/origin/master: $commit_id" \
621 >> $testroot/stdout.expected
622 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
623 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
625 cmp -s $testroot/stdout
$testroot/stdout.expected
627 if [ $ret -ne 0 ]; then
628 diff -u $testroot/stdout.expected
$testroot/stdout
629 test_done
"$testroot" "$ret"
633 got branch
-r $testroot/repo
-d foo
>/dev
/null
635 got fetch
-q -r $testroot/repo-clone
637 if [ $ret -ne 0 ]; then
638 echo "got fetch command failed unexpectedly" >&2
639 test_done
"$testroot" "$ret"
643 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
645 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
646 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
647 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
648 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
649 >> $testroot/stdout.expected
650 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
651 echo "refs/remotes/origin/master: $commit_id" \
652 >> $testroot/stdout.expected
653 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
654 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
656 cmp -s $testroot/stdout
$testroot/stdout.expected
658 if [ $ret -ne 0 ]; then
659 diff -u $testroot/stdout.expected
$testroot/stdout
660 test_done
"$testroot" "$ret"
664 got fetch
-d -q -r $testroot/repo-clone
> $testroot/stdout
666 if [ $ret -ne 0 ]; then
667 echo "got fetch command failed unexpectedly" >&2
668 test_done
"$testroot" "$ret"
672 echo -n > $testroot/stdout.expected
674 cmp -s $testroot/stdout
$testroot/stdout.expected
676 if [ $ret -ne 0 ]; then
677 diff -u $testroot/stdout.expected
$testroot/stdout
678 test_done
"$testroot" "$ret"
682 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
684 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
685 # refs/heads/foo is now deleted
686 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
687 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
688 >> $testroot/stdout.expected
689 # refs/remotes/origin/foo is now deleted
690 echo "refs/remotes/origin/master: $commit_id" \
691 >> $testroot/stdout.expected
692 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
693 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
695 cmp -s $testroot/stdout
$testroot/stdout.expected
697 if [ $ret -ne 0 ]; then
698 diff -u $testroot/stdout.expected
$testroot/stdout
700 test_done
"$testroot" "$ret"
704 test_fetch_delete_branch_mirror
() {
705 local testroot
=`test_init fetch_delete_branch_mirror`
706 local testurl
=ssh://127.0.0.1/$testroot
707 local commit_id
=`git_show_head $testroot/repo`
709 got branch
-r $testroot/repo
-c $commit_id foo
710 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
711 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
712 local tag_id
=`got ref -r $testroot/repo -l \
713 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
715 got clone
-a -m -q $testurl/repo
$testroot/repo-clone
717 if [ $ret -ne 0 ]; then
718 echo "got clone command failed unexpectedly" >&2
719 test_done
"$testroot" "$ret"
723 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
725 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
726 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
727 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
728 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
729 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
731 cmp -s $testroot/stdout
$testroot/stdout.expected
733 if [ $ret -ne 0 ]; then
734 diff -u $testroot/stdout.expected
$testroot/stdout
735 test_done
"$testroot" "$ret"
739 got branch
-r $testroot/repo
-d foo
>/dev
/null
741 got fetch
-q -r $testroot/repo-clone
743 if [ $ret -ne 0 ]; then
744 echo "got fetch command failed unexpectedly" >&2
745 test_done
"$testroot" "$ret"
749 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
751 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
752 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
753 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
754 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
755 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
757 cmp -s $testroot/stdout
$testroot/stdout.expected
759 if [ $ret -ne 0 ]; then
760 diff -u $testroot/stdout.expected
$testroot/stdout
761 test_done
"$testroot" "$ret"
765 got fetch
-d -q -r $testroot/repo-clone
> $testroot/stdout
767 if [ $ret -ne 0 ]; then
768 echo "got fetch command failed unexpectedly" >&2
769 test_done
"$testroot" "$ret"
773 echo -n > $testroot/stdout.expected
775 cmp -s $testroot/stdout
$testroot/stdout.expected
777 if [ $ret -ne 0 ]; then
778 diff -u $testroot/stdout.expected
$testroot/stdout
779 test_done
"$testroot" "$ret"
783 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
785 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
786 # refs/heads/foo is now deleted
787 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
788 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
789 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
791 cmp -s $testroot/stdout
$testroot/stdout.expected
793 if [ $ret -ne 0 ]; then
794 diff -u $testroot/stdout.expected
$testroot/stdout
796 test_done
"$testroot" "$ret"
800 test_fetch_update_tag
() {
801 local testroot
=`test_init fetch_update_tag`
802 local testurl
=ssh://127.0.0.1/$testroot
803 local commit_id
=`git_show_head $testroot/repo`
806 got branch
-r $testroot/repo
-c $commit_id foo
807 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
808 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
809 local tag_id
=`got ref -r $testroot/repo -l \
810 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
812 got clone
-a -q $testurl/repo
$testroot/repo-clone
814 if [ $ret -ne 0 ]; then
815 echo "got clone command failed unexpectedly" >&2
816 test_done
"$testroot" "$ret"
820 echo "modified alpha on master" > $testroot/repo
/alpha
821 git_commit
$testroot/repo
-m "modified alpha"
822 local commit_id2
=`git_show_head $testroot/repo`
824 got ref
-r $testroot/repo
-d "refs/tags/1.0" >/dev
/null
825 got tag
-r $testroot/repo
-c $commit_id2 -m tag
"1.0" >/dev
/null
826 local tag_id2
=`got ref -r $testroot/repo -l \
827 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
829 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
831 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
832 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
833 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
834 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
835 >> $testroot/stdout.expected
836 echo "refs/remotes/origin/foo: $commit_id" \
837 >> $testroot/stdout.expected
838 echo "refs/remotes/origin/master: $commit_id" \
839 >> $testroot/stdout.expected
840 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
841 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
843 cmp -s $testroot/stdout
$testroot/stdout.expected
845 if [ $ret -ne 0 ]; then
846 diff -u $testroot/stdout.expected
$testroot/stdout
847 test_done
"$testroot" "$ret"
851 got fetch
-a -q -r $testroot/repo-clone
853 if [ $ret -ne 0 ]; then
854 echo "got fetch command failed unexpectedly" >&2
855 test_done
"$testroot" "$ret"
859 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
861 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
862 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
863 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
864 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
865 >> $testroot/stdout.expected
866 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
867 echo "refs/remotes/origin/master: $commit_id2" \
868 >> $testroot/stdout.expected
869 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
870 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
872 cmp -s $testroot/stdout
$testroot/stdout.expected
874 if [ $ret -ne 0 ]; then
875 diff -u $testroot/stdout.expected
$testroot/stdout
876 test_done
"$testroot" "$ret"
880 got fetch
-r $testroot/repo-clone
2> $testroot/stderr | \
881 tail -n 1 > $testroot/stdout
883 if [ $ret -ne 0 ]; then
884 echo "got fetch command failed unexpectedly" >&2
885 test_done
"$testroot" "$ret"
889 echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
890 > $testroot/stdout.expected
892 cmp -s $testroot/stdout
$testroot/stdout.expected
894 if [ $ret -ne 0 ]; then
895 diff -u $testroot/stdout.expected
$testroot/stdout
896 test_done
"$testroot" "$ret"
900 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
902 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
903 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
904 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
905 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
906 >> $testroot/stdout.expected
907 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
908 echo "refs/remotes/origin/master: $commit_id2" \
909 >> $testroot/stdout.expected
910 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
911 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
913 cmp -s $testroot/stdout
$testroot/stdout.expected
915 if [ $ret -ne 0 ]; then
916 diff -u $testroot/stdout.expected
$testroot/stdout
917 test_done
"$testroot" "$ret"
921 got fetch
-q -t -r $testroot/repo-clone
> $testroot/stdout
923 if [ $ret -ne 0 ]; then
924 echo "got fetch command failed unexpectedly" >&2
925 test_done
"$testroot" "$ret"
929 echo -n > $testroot/stdout.expected
931 cmp -s $testroot/stdout
$testroot/stdout.expected
933 if [ $ret -ne 0 ]; then
934 diff -u $testroot/stdout.expected
$testroot/stdout
935 test_done
"$testroot" "$ret"
939 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
941 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
942 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
943 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
944 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
945 >> $testroot/stdout.expected
946 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
947 echo "refs/remotes/origin/master: $commit_id2" \
948 >> $testroot/stdout.expected
949 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
950 echo "refs/tags/1.0: $tag_id2" >> $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
957 test_done
"$testroot" "$ret"
960 test_fetch_reference
() {
961 local testroot
=`test_init fetch_reference`
962 local testurl
=ssh://127.0.0.1/$testroot
963 local commit_id
=`git_show_head $testroot/repo`
965 got clone
-q $testurl/repo
$testroot/repo-clone
967 if [ $ret -ne 0 ]; then
968 echo "got clone command failed unexpectedly" >&2
969 test_done
"$testroot" "$ret"
973 got branch
-r $testroot/repo
-c $commit_id foo
974 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
975 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
976 local tag_id
=`got ref -r $testroot/repo -l \
977 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
979 echo "modified alpha on master" > $testroot/repo
/alpha
980 git_commit
$testroot/repo
-m "modified alpha"
981 local commit_id2
=`git_show_head $testroot/repo`
983 git
-C $testroot/repo checkout
-q foo
984 echo "modified alpha on foo" > $testroot/repo
/alpha
985 git_commit
$testroot/repo
-m "modified alpha"
986 local commit_id3
=`git_show_head $testroot/repo`
987 git
-C $testroot/repo checkout
-q master
989 got fetch
-q -r $testroot/repo-clone
-R refs
/remotes
/origin
/main \
990 > $testroot/stdout
2> $testroot/stderr
992 if [ $ret -eq 0 ]; then
993 echo "got fetch command succeeded unexpectedly" >&2
994 test_done
"$testroot" "1"
998 echo -n > $testroot/stdout.expected
1000 cmp -s $testroot/stdout
$testroot/stdout.expected
1002 if [ $ret -ne 0 ]; then
1003 diff -u $testroot/stdout.expected
$testroot/stdout
1004 test_done
"$testroot" "$ret"
1008 echo "got: refs/remotes/origin/main: reference cannot be fetched" \
1009 > $testroot/stderr.expected
1011 cmp -s $testroot/stderr
$testroot/stderr.expected
1013 if [ $ret -ne 0 ]; then
1014 diff -u $testroot/stderr.expected
$testroot/stderr
1015 test_done
"$testroot" "$ret"
1019 got fetch
-q -r $testroot/repo-clone
-R refs
/hoo
1021 if [ $ret -ne 0 ]; then
1022 echo "got fetch command failed unexpectedly" >&2
1023 test_done
"$testroot" "$ret"
1027 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1029 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1030 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1031 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1032 >> $testroot/stdout.expected
1033 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1034 >> $testroot/stdout.expected
1035 echo "refs/remotes/origin/master: $commit_id2" \
1036 >> $testroot/stdout.expected
1037 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1039 cmp -s $testroot/stdout
$testroot/stdout.expected
1041 if [ $ret -ne 0 ]; then
1042 diff -u $testroot/stdout.expected
$testroot/stdout
1044 test_done
"$testroot" "$ret"
1048 test_fetch_replace_symref
() {
1049 local testroot
=`test_init fetch_replace_symref`
1050 local testurl
=ssh://127.0.0.1/$testroot
1051 local commit_id
=`git_show_head $testroot/repo`
1053 got clone
-m -q $testurl/repo
$testroot/repo-clone
1055 if [ $ret -ne 0 ]; then
1056 echo "got clone command failed unexpectedly" >&2
1057 test_done
"$testroot" "$ret"
1061 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
1062 got ref
-r $testroot/repo-clone
-s refs
/heads
/master refs
/hoo
/boo
/zoo
1064 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1066 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1067 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1068 echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1070 cmp -s $testroot/stdout
$testroot/stdout.expected
1072 if [ $ret -ne 0 ]; then
1073 diff -u $testroot/stdout.expected
$testroot/stdout
1074 test_done
"$testroot" "$ret"
1078 got fetch
-r $testroot/repo-clone
-R refs
/hoo \
1079 2> $testroot/stderr |
grep ^Replacing
> $testroot/stdout
1081 if [ $ret -ne 0 ]; then
1082 echo "got fetch command failed unexpectedly" >&2
1083 test_done
"$testroot" "$ret"
1087 echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1088 > $testroot/stdout.expected
1090 cmp -s $testroot/stdout
$testroot/stdout.expected
1092 if [ $ret -ne 0 ]; then
1093 diff -u $testroot/stdout.expected
$testroot/stdout
1094 test_done
"$testroot" "$ret"
1098 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1100 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1101 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1102 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1104 cmp -s $testroot/stdout
$testroot/stdout.expected
1106 if [ $ret -ne 0 ]; then
1107 diff -u $testroot/stdout.expected
$testroot/stdout
1109 test_done
"$testroot" "$ret"
1113 test_fetch_update_headref
() {
1114 local testroot
=`test_init fetch_update_headref`
1115 local testurl
=ssh://127.0.0.1/$testroot
1116 local commit_id
=`git_show_head $testroot/repo`
1118 got clone
-q $testurl/repo
$testroot/repo-clone
1120 if [ $ret -ne 0 ]; then
1121 echo "got clone command failed unexpectedly" >&2
1122 test_done
"$testroot" "$ret"
1126 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1128 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1129 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1130 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1131 >> $testroot/stdout.expected
1132 echo "refs/remotes/origin/master: $commit_id" \
1133 >> $testroot/stdout.expected
1135 cmp -s $testroot/stdout
$testroot/stdout.expected
1137 if [ $ret -ne 0 ]; then
1138 diff -u $testroot/stdout.expected
$testroot/stdout
1139 test_done
"$testroot" "$ret"
1143 got ref
-r $testroot/repo
-c refs
/heads
/master refs
/heads
/foo
1144 got ref
-r $testroot/repo
-s refs
/heads
/foo HEAD
1145 got ref
-l -r $testroot/repo
> $testroot/stdout
1147 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1148 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1149 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1151 cmp -s $testroot/stdout
$testroot/stdout.expected
1153 if [ $ret -ne 0 ]; then
1154 diff -u $testroot/stdout.expected
$testroot/stdout
1155 test_done
"$testroot" "$ret"
1159 got fetch
-q -r $testroot/repo-clone
1161 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1163 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1164 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1165 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1166 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1167 >> $testroot/stdout.expected
1168 echo "refs/remotes/origin/foo: $commit_id" \
1169 >> $testroot/stdout.expected
1170 echo "refs/remotes/origin/master: $commit_id" \
1171 >> $testroot/stdout.expected
1173 cmp -s $testroot/stdout
$testroot/stdout.expected
1175 if [ $ret -ne 0 ]; then
1176 diff -u $testroot/stdout.expected
$testroot/stdout
1177 test_done
"$testroot" "$ret"
1181 got fetch
-q -r $testroot/repo-clone
-a
1183 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1185 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1186 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1187 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1188 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1189 >> $testroot/stdout.expected
1190 echo "refs/remotes/origin/foo: $commit_id" \
1191 >> $testroot/stdout.expected
1192 echo "refs/remotes/origin/master: $commit_id" \
1193 >> $testroot/stdout.expected
1195 cmp -s $testroot/stdout
$testroot/stdout.expected
1197 if [ $ret -ne 0 ]; then
1198 diff -u $testroot/stdout.expected
$testroot/stdout
1200 test_done
"$testroot" "$ret"
1203 test_fetch_headref_deleted_locally
() {
1204 local testroot
=`test_init fetch_headref_deleted_locally`
1205 local testurl
=ssh://127.0.0.1/$testroot
1206 local commit_id
=`git_show_head $testroot/repo`
1208 got clone
-q $testurl/repo
$testroot/repo-clone
1210 if [ $ret -ne 0 ]; then
1211 echo "got clone command failed unexpectedly" >&2
1212 test_done
"$testroot" "$ret"
1216 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1218 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1219 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1220 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1221 >> $testroot/stdout.expected
1222 echo "refs/remotes/origin/master: $commit_id" \
1223 >> $testroot/stdout.expected
1225 cmp -s $testroot/stdout
$testroot/stdout.expected
1227 if [ $ret -ne 0 ]; then
1228 diff -u $testroot/stdout.expected
$testroot/stdout
1229 test_done
"$testroot" "$ret"
1233 got ref
-r $testroot/repo-clone
-d refs
/remotes
/origin
/HEAD
> /dev
/null
1235 got fetch
-q -r $testroot/repo-clone
1237 if [ $ret -ne 0 ]; then
1238 echo "got fetch command failed unexpectedly" >&2
1239 test_done
"$testroot" "$ret"
1242 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1244 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1245 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1246 # refs/remotes/origin/HEAD has been restored:
1247 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1248 >> $testroot/stdout.expected
1249 echo "refs/remotes/origin/master: $commit_id" \
1250 >> $testroot/stdout.expected
1252 cmp -s $testroot/stdout
$testroot/stdout.expected
1254 if [ $ret -ne 0 ]; then
1255 diff -u $testroot/stdout.expected
$testroot/stdout
1257 test_done
"$testroot" "$ret"
1260 test_fetch_gotconfig_remote_repo
() {
1261 local testroot
=`test_init fetch_gotconfig_remote_repo`
1262 local testurl
=ssh://127.0.0.1/$testroot
1263 local commit_id
=`git_show_head $testroot/repo`
1265 got branch
-r $testroot/repo
-c $commit_id foo
1266 got ref
-r $testroot/repo
-c $commit_id refs
/hoo
/boo
/zoo
1267 got tag
-r $testroot/repo
-c $commit_id -m tag
"1.0" >/dev
/null
1269 got clone
-q $testurl/repo
$testroot/repo-clone
1271 if [ $ret -ne 0 ]; then
1272 echo "got clone command failed unexpectedly" >&2
1273 test_done
"$testroot" "$ret"
1277 cat > $testroot/repo-clone
/got.conf
<<EOF
1281 repository "$testroot/repo"
1287 repository "$testroot/does-not-exist"
1290 echo "got: nonexistent: remote repository not found" \
1291 > $testroot/stderr.expected
1292 (cd $testroot/repo-clone
&& got fetch
-q nonexistent \
1293 > $testroot/stdout
2> $testroot/stderr
)
1295 if [ $ret -eq 0 ]; then
1296 echo "got fetch command succeeded unexpectedly" >&2
1297 diff -u $testroot/stderr.expected
$testroot/stderr
1298 test_done
"$testroot" "1"
1302 (cd $testroot/repo-clone
&& got fetch
-q -l foobar \
1305 if [ $ret -ne 0 ]; then
1306 echo "got fetch command failed unexpectedly" >&2
1307 test_done
"$testroot" "$ret"
1311 got ref
-l -r $testroot/repo
> $testroot/stdout.expected
1313 cmp -s $testroot/stdout
$testroot/stdout.expected
1315 if [ $ret -ne 0 ]; then
1316 diff -u $testroot/stdout.expected
$testroot/stdout
1317 test_done
"$testroot" "$ret"
1321 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1323 cat > $testroot/wt
/.got
/got.conf
<<EOF
1327 repository "$testroot/repo"
1330 (cd $testroot/wt
&& got fetch
-q -l barbaz
> $testroot/stdout
)
1332 if [ $ret -ne 0 ]; then
1333 echo "got fetch command failed unexpectedly" >&2
1334 test_done
"$testroot" "$ret"
1338 got ref
-l -r $testroot/repo
> $testroot/stdout.expected
1340 cmp -s $testroot/stdout
$testroot/stdout.expected
1342 if [ $ret -ne 0 ]; then
1343 diff -u $testroot/stdout.expected
$testroot/stdout
1344 test_done
"$testroot" "$ret"
1348 cat > $testroot/repo-clone
/got.conf
<<EOF
1352 repository "$testroot/repo"
1354 reference { "hoo/boo/zoo" }
1357 (cd $testroot/repo-clone
&& got fetch
-q > $testroot/stdout
)
1359 local tag_id
=`got ref -r $testroot/repo -l \
1360 | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1361 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1362 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1363 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1364 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1365 >> $testroot/stdout.expected
1366 echo "refs/remotes/origin/foo: $commit_id" \
1367 >> $testroot/stdout.expected
1368 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1369 >> $testroot/stdout.expected
1370 echo "refs/remotes/origin/master: $commit_id" \
1371 >> $testroot/stdout.expected
1372 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1374 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1376 cmp -s $testroot/stdout
$testroot/stdout.expected
1378 if [ $ret -ne 0 ]; then
1379 diff -u $testroot/stdout.expected
$testroot/stdout
1381 test_done
"$testroot" "$ret"
1384 test_fetch_gitconfig_remote_repo
() {
1385 local testroot
=`test_init fetch_gotconfig_remote_repo`
1386 local testurl
=ssh://127.0.0.1/$testroot
1387 local commit_id
=`git_show_head $testroot/repo`
1389 make_single_file_repo
$testroot/alternate-repo foo
1390 local alt_commit_id
=`git_show_head $testroot/alternate-repo`
1392 cat >> $testroot/repo
/.git
/config
<<EOF
1396 url = $testurl/alternate-repo
1398 url = $testurl/some-other-repo
1401 # unset in a subshell to avoid affecting our environment
1402 (unset GOT_IGNORE_GITCONFIG
&& cd $testroot/repo
&& got fetch
-q alt
)
1404 if [ $ret -ne 0 ]; then
1405 echo "got fetch command failed unexpectedly" >&2
1406 test_done
"$testroot" "$ret"
1410 got ref
-l -r $testroot/repo
> $testroot/stdout
1412 cat > $testroot/stdout.expected
<<-EOF
1413 HEAD: refs/heads/master
1414 refs/heads/master: $commit_id
1415 refs/remotes/alt/HEAD: refs/remotes/alt/master
1416 refs/remotes/alt/master: $alt_commit_id
1419 cmp -s $testroot/stdout
$testroot/stdout.expected
1421 if [ $ret -ne 0 ]; then
1422 diff -u $testroot/stdout.expected
$testroot/stdout
1424 test_done
"$testroot" "$ret"
1427 test_fetch_delete_remote_refs
() {
1428 local testroot
=`test_init fetch_delete_remote_refs`
1429 local testurl
=ssh://127.0.0.1/$testroot
1430 local commit_id
=`git_show_head $testroot/repo`
1432 got clone
-q $testurl/repo
$testroot/repo-clone
1434 if [ $ret -ne 0 ]; then
1435 echo "got clone command failed unexpectedly" >&2
1436 test_done
"$testroot" "$ret"
1440 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1442 if [ $ret -ne 0 ]; then
1443 echo "got ref command failed unexpectedly" >&2
1444 test_done
"$testroot" "$ret"
1448 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1449 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1450 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1451 >> $testroot/stdout.expected
1452 echo "refs/remotes/origin/master: $commit_id" \
1453 >> $testroot/stdout.expected
1455 cmp -s $testroot/stdout
$testroot/stdout.expected
1457 if [ $ret -ne 0 ]; then
1458 diff -u $testroot/stdout.expected
$testroot/stdout
1459 test_done
"$testroot" "$ret"
1463 got fetch
-q -r $testroot/repo-clone
-X > $testroot/stdout \
1466 if [ $ret -eq 0 ]; then
1467 echo "got fetch command succeeded unexpectedly" >&2
1468 test_done
"$testroot" "1"
1472 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1473 cmp -s $testroot/stderr
$testroot/stderr.expected
1475 if [ $ret -ne 0 ]; then
1476 diff -u $testroot/stderr.expected
$testroot/stderr
1477 test_done
"$testroot" "$ret"
1481 got fetch
-q -r $testroot/repo-clone
-X origin
> $testroot/stdout \
1484 if [ $ret -ne 0 ]; then
1485 echo "got fetch command failed unexpectedly" >&2
1486 test_done
"$testroot" "$ret"
1490 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1491 echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1492 echo "Deleted refs/remotes/origin/master: $commit_id" \
1493 >> $testroot/stdout.expected
1495 cmp -s $testroot/stdout
$testroot/stdout.expected
1497 if [ $ret -ne 0 ]; then
1498 diff -u $testroot/stdout.expected
$testroot/stdout
1499 test_done
"$testroot" "$ret"
1503 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1505 if [ $ret -ne 0 ]; then
1506 echo "got ref command failed unexpectedly" >&2
1507 test_done
"$testroot" "$ret"
1511 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1512 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1514 cmp -s $testroot/stdout
$testroot/stdout.expected
1516 if [ $ret -ne 0 ]; then
1517 diff -u $testroot/stdout.expected
$testroot/stdout
1519 test_done
"$testroot" "$ret"
1522 test_fetch_honor_wt_conf_bflag
() {
1523 local testroot
=`test_init fetch_honor_wt_conf_bflag`
1524 local testurl
=ssh://127.0.0.1/$testroot
1526 # server will have 'boo', 'hoo', and 'master'
1527 echo "modified alpha on master" > $testroot/repo
/alpha
1528 git_commit
$testroot/repo
-m "modified alpha"
1529 local commit_id
=`git_show_head $testroot/repo`
1531 got branch
-r $testroot/repo
-c $commit_id boo
1532 git
-C $testroot/repo checkout
-q boo
1533 echo "modified beta on boo" > $testroot/repo
/beta
1534 git_commit
$testroot/repo
-m "modified beta"
1535 local commit_id2
=`git_show_head $testroot/repo`
1537 got branch
-r $testroot/repo
-c $commit_id2 hoo
1538 git
-C $testroot/repo checkout
-q hoo
1539 echo "modified delta on hoo" > $testroot/repo
/gamma
/delta
1540 git_commit
$testroot/repo
-m "modified delta"
1541 local commit_id3
=`git_show_head $testroot/repo`
1543 git
-C $testroot/repo checkout
-q master
1544 got clone
-q $testurl/repo
$testroot/repo-clone
1546 if [ $ret -ne 0 ]; then
1547 echo "got clone command failed unexpectedly" >&2
1548 test_done
"$testroot" "$ret"
1552 # only clone will have foo and bar
1553 got branch
-r $testroot/repo-clone
-c $commit_id foo
1554 got branch
-r $testroot/repo-clone
-c $commit_id bar
1556 got fetch
-q -r $testroot/repo-clone
> $testroot/stdout
1558 if [ $ret -ne 0 ]; then
1559 echo "got fetch command failed unexpectedly" >&2
1560 test_done
"$testroot" "$ret"
1564 echo -n > $testroot/stdout.expected
1566 cmp -s $testroot/stdout
$testroot/stdout.expected
1568 if [ $ret -ne 0 ]; then
1569 diff -u $testroot/stdout.expected
$testroot/stdout
1570 test_done
"$testroot" "$ret"
1574 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1576 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1577 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1578 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1579 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1580 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1581 >> $testroot/stdout.expected
1582 echo "refs/remotes/origin/master: $commit_id" \
1583 >> $testroot/stdout.expected
1585 cmp -s $testroot/stdout
$testroot/stdout.expected
1587 if [ $ret -ne 0 ]; then
1588 diff -u $testroot/stdout.expected
$testroot/stdout
1589 test_done
"$testroot" "$ret"
1593 git
-C $testroot/repo checkout
-q boo
1594 # clone has remote/origin/HEAD symref with "master" as its target
1595 # but the repo has changed HEAD to "boo", so we should fetch "boo"
1596 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1597 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1598 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1599 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1600 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1601 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1602 >> $testroot/stdout.expected
1603 echo "refs/remotes/origin/boo: $commit_id2" \
1604 >> $testroot/stdout.expected
1605 echo "refs/remotes/origin/master: $commit_id" \
1606 >> $testroot/stdout.expected
1608 got fetch
-q -r $testroot/repo-clone
> $testroot/stdout
1610 if [ $ret -ne 0 ]; then
1611 echo "got fetch command failed unexpectedly" >&2
1612 test_done
"$testroot" "$ret"
1616 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1618 cmp -s $testroot/stdout
$testroot/stdout.expected
1620 if [ $ret -ne 0 ]; then
1621 diff -u $testroot/stdout.expected
$testroot/stdout
1622 test_done
"$testroot" "$ret"
1626 # from repo: fetch -b hoo
1627 got fetch
-q -r $testroot/repo-clone
-b hoo
> $testroot/stdout
1629 if [ $ret -ne 0 ]; then
1630 echo "got fetch command failed unexpectedly" >&2
1631 test_done
"$testroot" "$ret"
1635 echo -n > $testroot/stdout.expected
1637 cmp -s $testroot/stdout
$testroot/stdout.expected
1639 if [ $ret -ne 0 ]; then
1640 diff -u $testroot/stdout.expected
$testroot/stdout
1641 test_done
"$testroot" "$ret"
1645 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1647 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1648 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1649 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1650 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1651 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1652 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1653 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1654 >> $testroot/stdout.expected
1655 echo "refs/remotes/origin/boo: $commit_id2" \
1656 >> $testroot/stdout.expected
1657 echo "refs/remotes/origin/hoo: $commit_id3" \
1658 >> $testroot/stdout.expected
1659 echo "refs/remotes/origin/master: $commit_id" \
1660 >> $testroot/stdout.expected
1662 cmp -s $testroot/stdout
$testroot/stdout.expected
1664 if [ $ret -ne 0 ]; then
1665 diff -u $testroot/stdout.expected
$testroot/stdout
1666 test_done
"$testroot" "$ret"
1670 # from repo: fetch -b foo which doesn't exist on the server but
1671 # do not fallback to repo HEAD "boo" because we used the -b flag
1672 got fetch
-r $testroot/repo-clone
-b foo
> $testroot/stdout \
1675 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1676 > $testroot/stdout.expected
1677 echo "got-fetch-pack: branch \"foo\" not found on server" \
1678 > $testroot/stderr.expected
1679 echo "got: could not find any branches to fetch" \
1680 >> $testroot/stderr.expected
1682 cmp -s $testroot/stdout
$testroot/stdout.expected
1684 if [ $ret -ne 0 ]; then
1685 diff -u $testroot/stdout.expected
$testroot/stdout
1686 test_done
"$testroot" "$ret"
1690 cmp -s $testroot/stderr
$testroot/stderr.expected
1692 if [ $ret -ne 0 ]; then
1693 diff -u $testroot/stderr.expected
$testroot/stderr
1694 test_done
"$testroot" "$ret"
1698 # from repo: fetch got.conf branch which doesn't exist, so fallback
1699 # to repo HEAD "boo"
1700 # change default branch in got.conf from "master" to "foo"
1701 ed
-s $testroot/repo-clone
/got.conf
<<-EOF
1706 got fetch
-q -r $testroot/repo-clone
> $testroot/stdout
1708 if [ $ret -ne 0 ]; then
1709 echo "got fetch command failed unexpectedly" >&2
1710 test_done
"$testroot" "$ret"
1714 echo -n > $testroot/stdout.expected
1716 cmp -s $testroot/stdout
$testroot/stdout.expected
1718 if [ $ret -ne 0 ]; then
1719 diff -u $testroot/stdout.expected
$testroot/stdout
1720 test_done
"$testroot" "$ret"
1724 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1726 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1727 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1728 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1729 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1730 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1731 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1732 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1733 >> $testroot/stdout.expected
1734 echo "refs/remotes/origin/boo: $commit_id2" \
1735 >> $testroot/stdout.expected
1736 echo "refs/remotes/origin/hoo: $commit_id3" \
1737 >> $testroot/stdout.expected
1738 echo "refs/remotes/origin/master: $commit_id" \
1739 >> $testroot/stdout.expected
1741 cmp -s $testroot/stdout
$testroot/stdout.expected
1743 if [ $ret -ne 0 ]; then
1744 diff -u $testroot/stdout.expected
$testroot/stdout
1745 test_done
"$testroot" "$ret"
1749 # from wt: fetch got.conf "foo", which doesn't exist on the server,
1750 # and implicit wt branch "boo", not repo HEAD "master"
1751 echo "modified delta on boo" > $testroot/repo
/gamma
/delta
1752 git_commit
$testroot/repo
-m "modified delta"
1753 local commit_id4
=`git_show_head $testroot/repo`
1755 git
-C $testroot/repo checkout
-q master
1757 got checkout
-b boo
$testroot/repo-clone
$testroot/wt
> /dev
/null
1758 (cd $testroot/wt
&& got fetch
-q > $testroot/stdout
)
1760 echo -n > $testroot/stdout.expected
1762 cmp -s $testroot/stdout
$testroot/stdout.expected
1764 if [ $ret -ne 0 ]; then
1765 diff -u $testroot/stdout.expected
$testroot/stdout
1766 test_done
"$testroot" "$ret"
1770 local wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
1771 cut -d ':' -f 2 | tr -d ' ')`
1773 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1775 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1776 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1777 >> $testroot/stdout.expected
1778 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1779 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1780 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1781 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1782 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1783 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1784 >> $testroot/stdout.expected
1785 echo "refs/remotes/origin/boo: $commit_id4" \
1786 >> $testroot/stdout.expected
1787 echo "refs/remotes/origin/hoo: $commit_id3" \
1788 >> $testroot/stdout.expected
1789 echo "refs/remotes/origin/master: $commit_id" \
1790 >> $testroot/stdout.expected
1792 cmp -s $testroot/stdout
$testroot/stdout.expected
1794 if [ $ret -ne 0 ]; then
1795 diff -u $testroot/stdout.expected
$testroot/stdout
1796 test_done
"$testroot" "$ret"
1800 # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD
1801 # "hoo" as it no longer matches our remote HEAD symref target "master"
1802 ed
-s $testroot/repo-clone
/got.conf
<<-EOF
1806 echo "modified delta on master" > $testroot/repo
/gamma
/delta
1807 git_commit
$testroot/repo
-m "modified delta on master"
1808 local commit_id5
=`git_show_head $testroot/repo`
1810 git
-C $testroot/repo checkout
-q boo
1811 echo "modified alpha on boo" > $testroot/repo
/alpha
1812 git_commit
$testroot/repo
-m "modified alpha on boo"
1813 local commit_id6
=`git_show_head $testroot/repo`
1815 git
-C $testroot/repo checkout
-q hoo
1816 echo "modified beta on hoo" > $testroot/repo
/beta
1817 git_commit
$testroot/repo
-m "modified beta on hoo"
1818 local commit_id7
=`git_show_head $testroot/repo`
1820 (cd $testroot/wt
&& got fetch
-q > $testroot/stdout
)
1822 echo -n > $testroot/stdout.expected
1824 cmp -s $testroot/stdout
$testroot/stdout.expected
1826 if [ $ret -ne 0 ]; then
1827 diff -u $testroot/stdout.expected
$testroot/stdout
1828 test_done
"$testroot" "$ret"
1832 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1834 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1835 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1836 >> $testroot/stdout.expected
1837 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1838 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1839 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1840 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1841 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1842 echo "refs/remotes/origin/HEAD: refs/remotes/origin/hoo" \
1843 >> $testroot/stdout.expected
1844 echo "refs/remotes/origin/boo: $commit_id6" \
1845 >> $testroot/stdout.expected
1846 echo "refs/remotes/origin/hoo: $commit_id7" \
1847 >> $testroot/stdout.expected
1848 echo "refs/remotes/origin/master: $commit_id5" \
1849 >> $testroot/stdout.expected
1851 cmp -s $testroot/stdout
$testroot/stdout.expected
1853 if [ $ret -ne 0 ]; then
1854 diff -u $testroot/stdout.expected
$testroot/stdout
1855 test_done
"$testroot" "$ret"
1859 # from wt: fetch -b hoo not got.conf "master" or wt "boo" or
1861 git
-C $testroot/repo checkout
-q boo
1862 echo "modified alpha again on boo" > $testroot/repo
/alpha
1863 git_commit
$testroot/repo
-m "modified alpha again on boo"
1864 local commit_id8
=`git_show_head $testroot/repo`
1866 (cd $testroot/wt
&& got fetch
-q -b hoo
> $testroot/stdout
)
1868 echo -n > $testroot/stdout.expected
1870 cmp -s $testroot/stdout
$testroot/stdout.expected
1872 if [ $ret -ne 0 ]; then
1873 diff -u $testroot/stdout.expected
$testroot/stdout
1874 test_done
"$testroot" "$ret"
1878 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1880 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1881 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1882 >> $testroot/stdout.expected
1883 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1884 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1885 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1886 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1887 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1888 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1889 >> $testroot/stdout.expected
1890 echo "refs/remotes/origin/boo: $commit_id6" \
1891 >> $testroot/stdout.expected
1892 echo "refs/remotes/origin/hoo: $commit_id7" \
1893 >> $testroot/stdout.expected
1894 echo "refs/remotes/origin/master: $commit_id5" \
1895 >> $testroot/stdout.expected
1897 cmp -s $testroot/stdout
$testroot/stdout.expected
1899 if [ $ret -ne 0 ]; then
1900 diff -u $testroot/stdout.expected
$testroot/stdout
1901 test_done
"$testroot" "$ret"
1905 # from wt: fetch -b bar that doesn't exist on the server but
1906 # do not fetch got.conf "master" or wt "boo" or repo HEAD "boo"
1907 (cd $testroot/wt
&& got fetch
-b bar
> $testroot/stdout \
1908 2> $testroot/stderr
)
1910 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1911 > $testroot/stdout.expected
1912 echo "got-fetch-pack: branch \"bar\" not found on server" \
1913 > $testroot/stderr.expected
1914 echo "got: could not find any branches to fetch" \
1915 >> $testroot/stderr.expected
1917 cmp -s $testroot/stderr
$testroot/stderr.expected
1919 if [ $ret -ne 0 ]; then
1920 diff -u $testroot/stderr.expected
$testroot/stderr
1921 test_done
"$testroot" "$ret"
1925 cmp -s $testroot/stdout
$testroot/stdout.expected
1927 if [ $ret -ne 0 ]; then
1928 diff -u $testroot/stdout.expected
$testroot/stdout
1930 test_done
"$testroot" "$ret"
1933 test_fetch_from_out_of_date_remote
() {
1934 local testroot
=`test_init fetch_from_out_of_date_remote`
1935 local testurl
=ssh://127.0.0.1/$testroot
1936 local commit_id
=`git_show_head $testroot/repo`
1938 got clone
-q $testurl/repo
$testroot/repo-clone
1940 if [ $ret -ne 0 ]; then
1941 echo "got clone command failed unexpectedly" >&2
1942 test_done
"$testroot" "$ret"
1946 echo "modified alpha" > $testroot/repo
/alpha
1947 git_commit
$testroot/repo
-m "modified alpha"
1948 local commit_id2
=`git_show_head $testroot/repo`
1950 got clone
-q $testurl/repo
$testroot/repo-clone2 \
1951 > $testroot/stdout
2> $testroot/stderr
1953 if [ $ret -ne 0 ]; then
1954 echo "got clone command failed unexpectedly" >&2
1955 test_done
"$testroot" "$ret"
1959 got ref
-l -r $testroot/repo-clone2
> $testroot/stdout
1961 if [ $ret -ne 0 ]; then
1962 echo "got ref command failed unexpectedly" >&2
1963 test_done
"$testroot" "$ret"
1967 cat > $testroot/stdout.expected
<<EOF
1968 HEAD: refs/heads/master
1969 refs/heads/master: $commit_id2
1970 refs/remotes/origin/HEAD: refs/remotes/origin/master
1971 refs/remotes/origin/master: $commit_id2
1973 cmp -s $testroot/stdout
$testroot/stdout.expected
1975 if [ $ret -ne 0 ]; then
1976 diff -u $testroot/stdout.expected
$testroot/stdout
1977 test_done
"$testroot" "$ret"
1981 cat >> $testroot/repo-clone
2/got.conf
<<EOF
1985 repository "$testroot/repo-clone"
1989 got fetch
-q -r $testroot/repo-clone2 other \
1990 > $testroot/stdout
2> $testroot/stderr
1992 if [ $ret -ne 0 ]; then
1993 echo "got fetch command failed unexpectedly" >&2
1994 test_done
"$testroot" "$ret"
1998 got ref
-l -r $testroot/repo-clone2
> $testroot/stdout
2000 if [ $ret -ne 0 ]; then
2001 echo "got ref command failed unexpectedly" >&2
2002 test_done
"$testroot" "$ret"
2006 cat > $testroot/stdout.expected
<<EOF
2007 HEAD: refs/heads/master
2008 refs/heads/master: $commit_id2
2009 refs/remotes/origin/HEAD: refs/remotes/origin/master
2010 refs/remotes/origin/master: $commit_id2
2011 refs/remotes/other/HEAD: refs/remotes/other/master
2012 refs/remotes/other/master: $commit_id
2014 cmp -s $testroot/stdout
$testroot/stdout.expected
2016 if [ $ret -ne 0 ]; then
2017 diff -u $testroot/stdout.expected
$testroot/stdout
2019 test_done
"$testroot" "$ret"
2023 test_fetch_basic_http
() {
2024 local testroot
=`test_init fetch_basic_http`
2025 local testurl
=http
://127.0.0.1:$GOT_TEST_HTTP_PORT
2026 local commit_id
=`git_show_head $testroot/repo`
2028 timeout
20 .
/http-server
-p $GOT_TEST_HTTP_PORT $testroot \
2029 > $testroot/http-server.log
&
2030 trap "kill %1" HUP INT QUIT PIPE TERM
2032 while ! grep -q 'ready' $testroot/http-server.log
; do
2033 sleep 1 # server starts up
2036 got clone
-q $testurl/repo
$testroot/repo-clone
2038 if [ $ret -ne 0 ]; then
2039 echo "got clone command failed unexpectedly" >&2
2040 test_done
"$testroot" "$ret"
2044 echo "modified alpha" > $testroot/repo
/alpha
2045 git_commit
$testroot/repo
-m "modified alpha"
2046 local commit_id2
=`git_show_head $testroot/repo`
2048 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
2050 if [ $ret -ne 0 ]; then
2051 echo "got ref command failed unexpectedly" >&2
2052 test_done
"$testroot" "$ret"
2056 got fetch
-q -r $testroot/repo-clone
> $testroot/stdout \
2059 if [ $ret -ne 0 ]; then
2060 echo "got fetch command failed unexpectedly" >&2
2061 test_done
"$testroot" "$ret"
2066 wait %1 # wait for http-server
2068 echo -n > $testroot/stdout.expected
2070 cmp -s $testroot/stdout
$testroot/stdout.expected
2072 if [ $ret -ne 0 ]; then
2073 diff -u $testroot/stdout.expected
$testroot/stdout
2074 test_done
"$testroot" "$ret"
2078 got log
-l0 -p -r $testroot/repo
> $testroot/log-repo
2080 if [ $ret -ne 0 ]; then
2081 echo "got log command failed unexpectedly" >&2
2082 test_done
"$testroot" "$ret"
2085 got log
-l0 -p -r $testroot/repo
> $testroot/log-repo-clone
2087 if [ $ret -ne 0 ]; then
2088 echo "got log command failed unexpectedly" >&2
2089 test_done
"$testroot" "$ret"
2092 cmp -s $testroot/log-repo
$testroot/log-repo-clone
2094 if [ $ret -ne 0 ]; then
2095 echo "log -p output of cloned repository differs" >&2
2096 test_done
"$testroot" "$ret"
2100 got ref
-l -r $testroot/repo
> $testroot/stdout
2102 if [ $ret -ne 0 ]; then
2103 echo "got ref command failed unexpectedly" >&2
2104 test_done
"$testroot" "$ret"
2108 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
2109 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
2111 cmp -s $testroot/stdout
$testroot/stdout.expected
2113 if [ $ret -ne 0 ]; then
2114 diff -u $testroot/stdout.expected
$testroot/stdout
2115 test_done
"$testroot" "$ret"
2119 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
2121 if [ $ret -ne 0 ]; then
2122 echo "got ref command failed unexpectedly" >&2
2123 test_done
"$testroot" "$ret"
2127 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
2128 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
2129 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
2130 >> $testroot/stdout.expected
2131 echo "refs/remotes/origin/master: $commit_id2" \
2132 >> $testroot/stdout.expected
2134 cmp -s $testroot/stdout
$testroot/stdout.expected
2136 if [ $ret -ne 0 ]; then
2137 diff -u $testroot/stdout.expected
$testroot/stdout
2139 test_done
"$testroot" "$ret"
2143 run_test test_fetch_basic no-sha256
2144 run_test test_fetch_list no-sha256
2145 run_test test_fetch_branch no-sha256
2146 run_test test_fetch_all no-sha256
2147 run_test test_fetch_empty_packfile no-sha256
2148 run_test test_fetch_delete_branch no-sha256
2149 run_test test_fetch_delete_branch_mirror no-sha256
2150 run_test test_fetch_update_tag no-sha256
2151 run_test test_fetch_reference no-sha256
2152 run_test test_fetch_replace_symref no-sha256
2153 run_test test_fetch_update_headref no-sha256
2154 run_test test_fetch_headref_deleted_locally no-sha256
2155 run_test test_fetch_gotconfig_remote_repo no-sha256
2156 run_test test_fetch_gitconfig_remote_repo no-sha256
2157 run_test test_fetch_delete_remote_refs no-sha256
2158 run_test test_fetch_honor_wt_conf_bflag no-sha256
2159 run_test test_fetch_from_out_of_date_remote no-sha256
2160 run_test test_fetch_basic_http no-sha256