Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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.
17 . ./common.sh
19 test_fetch_basic() {
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
25 ret=$?
26 if [ $ret -ne 0 ]; then
27 echo "got clone command failed unexpectedly" >&2
28 test_done "$testroot" "$ret"
29 return 1
30 fi
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
37 ret=$?
38 if [ $ret -ne 0 ]; then
39 echo "got ref command failed unexpectedly" >&2
40 test_done "$testroot" "$ret"
41 return 1
42 fi
44 got fetch -q -r $testroot/repo-clone > $testroot/stdout \
45 2> $testroot/stderr
46 ret=$?
47 if [ $ret -ne 0 ]; then
48 echo "got fetch command failed unexpectedly" >&2
49 test_done "$testroot" "$ret"
50 return 1
51 fi
53 echo -n > $testroot/stdout.expected
55 cmp -s $testroot/stdout $testroot/stdout.expected
56 ret=$?
57 if [ $ret -ne 0 ]; then
58 diff -u $testroot/stdout.expected $testroot/stdout
59 test_done "$testroot" "$ret"
60 return 1
61 fi
63 got log -l0 -p -r $testroot/repo > $testroot/log-repo
64 ret=$?
65 if [ $ret -ne 0 ]; then
66 echo "got log command failed unexpectedly" >&2
67 test_done "$testroot" "$ret"
68 return 1
69 fi
70 got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
71 ret=$?
72 if [ $ret -ne 0 ]; then
73 echo "got log command failed unexpectedly" >&2
74 test_done "$testroot" "$ret"
75 return 1
76 fi
77 cmp -s $testroot/log-repo $testroot/log-repo-clone
78 ret=$?
79 if [ $ret -ne 0 ]; then
80 echo "log -p output of cloned repository differs" >&2
81 test_done "$testroot" "$ret"
82 return 1
83 fi
85 got ref -l -r $testroot/repo > $testroot/stdout
86 ret=$?
87 if [ $ret -ne 0 ]; then
88 echo "got ref command failed unexpectedly" >&2
89 test_done "$testroot" "$ret"
90 return 1
91 fi
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
97 ret=$?
98 if [ $ret -ne 0 ]; then
99 diff -u $testroot/stdout.expected $testroot/stdout
100 test_done "$testroot" "$ret"
101 return 1
102 fi
104 got ref -l -r $testroot/repo-clone > $testroot/stdout
105 ret=$?
106 if [ $ret -ne 0 ]; then
107 echo "got ref command failed unexpectedly" >&2
108 test_done "$testroot" "$ret"
109 return 1
110 fi
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
120 ret=$?
121 if [ $ret -ne 0 ]; then
122 diff -u $testroot/stdout.expected $testroot/stdout
123 fi
124 test_done "$testroot" "$ret"
127 test_fetch_list() {
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
137 ret=$?
138 if [ $ret -ne 0 ]; then
139 echo "got clone command failed unexpectedly" >&2
140 test_done "$testroot" "$ret"
141 return 1
142 fi
144 (cd $testroot/repo-clone && got fetch -q -l \
145 > $testroot/stdout 2>$testroot/stderr)
146 ret=$?
147 if [ $ret -ne 0 ]; then
148 echo "got fetch command failed unexpectedly" >&2
149 test_done "$testroot" "$ret"
150 return 1
151 fi
153 got ref -l -r $testroot/repo > $testroot/stdout.expected
155 cmp -s $testroot/stdout $testroot/stdout.expected
156 ret=$?
157 if [ $ret -ne 0 ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
159 fi
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
169 ret=$?
170 if [ $ret -ne 0 ]; then
171 echo "got clone command failed unexpectedly" >&2
172 test_done "$testroot" "$ret"
173 return 1
174 fi
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 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
194 ret=$?
195 if [ $ret -ne 0 ]; then
196 echo "got fetch command failed unexpectedly" >&2
197 test_done "$testroot" "$ret"
198 return 1
199 fi
201 echo -n > $testroot/stdout.expected
203 cmp -s $testroot/stdout $testroot/stdout.expected
204 ret=$?
205 if [ $ret -ne 0 ]; then
206 diff -u $testroot/stdout.expected $testroot/stdout
207 test_done "$testroot" "$ret"
208 return 1
209 fi
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
226 ret=$?
227 if [ $ret -ne 0 ]; then
228 diff -u $testroot/stdout.expected $testroot/stdout
229 test_done "$testroot" "$ret"
230 return 1
231 fi
233 # fetch branch foo via command-line switch
234 got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
235 ret=$?
236 if [ $ret -ne 0 ]; then
237 echo "got fetch command failed unexpectedly" >&2
238 test_done "$testroot" "$ret"
239 return 1
240 fi
242 echo -n > $testroot/stdout.expected
244 cmp -s $testroot/stdout $testroot/stdout.expected
245 ret=$?
246 if [ $ret -ne 0 ]; then
247 diff -u $testroot/stdout.expected $testroot/stdout
248 test_done "$testroot" "$ret"
249 return 1
250 fi
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
266 ret=$?
267 if [ $ret -ne 0 ]; then
268 diff -u $testroot/stdout.expected $testroot/stdout
269 test_done "$testroot" "$ret"
270 return 1
271 fi
273 # got.conf tells us to fetch the 'master' branch by default
274 got fetch -q -r $testroot/repo-clone > $testroot/stdout
275 ret=$?
276 if [ $ret -ne 0 ]; then
277 echo "got fetch command failed unexpectedly" >&2
278 test_done "$testroot" "$ret"
279 return 1
280 fi
282 echo -n > $testroot/stdout.expected
284 cmp -s $testroot/stdout $testroot/stdout.expected
285 ret=$?
286 if [ $ret -ne 0 ]; then
287 diff -u $testroot/stdout.expected $testroot/stdout
288 test_done "$testroot" "$ret"
289 return 1
290 fi
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
306 ret=$?
307 if [ $ret -ne 0 ]; then
308 diff -u $testroot/stdout.expected $testroot/stdout
309 test_done "$testroot" "$ret"
310 return 1
311 fi
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 (cd $testroot/repo && git 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
329 ret=$?
330 if [ $ret -ne 0 ]; then
331 diff -u $testroot/stdout.expected $testroot/stdout
332 test_done "$testroot" "$ret"
333 return 1
334 fi
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
355 ret=$?
356 if [ $ret -ne 0 ]; then
357 diff -u $testroot/stdout.expected $testroot/stdout
358 test_done "$testroot" "$ret"
359 return 1
360 fi
362 # remove default branch information from got.conf
363 sed -i -e "/branch {/d" $testroot/repo-clone/got.conf
365 # make another change on 'foo' and fetch it without got.conf
366 (cd $testroot/repo && git checkout -q foo)
367 echo "modified beta on foo agan" > $testroot/repo/beta
368 git_commit $testroot/repo -m "modified beta"
369 local commit_id5=`git_show_head $testroot/repo`
370 (cd $testroot/repo && git checkout -q master)
372 # fetch new commits on branch 'foo', implicitly obtaining the
373 # branch name from a work tree
374 (cd $testroot/wt && got fetch -q > $testroot/stdout)
376 echo -n > $testroot/stdout.expected
378 cmp -s $testroot/stdout $testroot/stdout.expected
379 ret=$?
380 if [ $ret -ne 0 ]; then
381 diff -u $testroot/stdout.expected $testroot/stdout
382 test_done "$testroot" "$ret"
383 return 1
384 fi
386 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
387 cut -d ':' -f 2 | tr -d ' ')`
389 got ref -l -r $testroot/repo-clone > $testroot/stdout
391 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
392 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
393 >> $testroot/stdout.expected
394 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
395 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
396 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
397 >> $testroot/stdout.expected
398 echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
399 echo "refs/remotes/origin/master: $commit_id2" \
400 >> $testroot/stdout.expected
401 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
402 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
404 cmp -s $testroot/stdout $testroot/stdout.expected
405 ret=$?
406 if [ $ret -ne 0 ]; then
407 diff -u $testroot/stdout.expected $testroot/stdout
408 fi
409 test_done "$testroot" "$ret"
412 test_fetch_all() {
413 local testroot=`test_init fetch_all`
414 local testurl=ssh://127.0.0.1/$testroot
415 local commit_id=`git_show_head $testroot/repo`
417 got clone -q $testurl/repo $testroot/repo-clone
418 ret=$?
419 if [ $ret -ne 0 ]; then
420 echo "got clone command failed unexpectedly" >&2
421 test_done "$testroot" "$ret"
422 return 1
423 fi
425 got branch -r $testroot/repo -c $commit_id foo
426 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
427 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
428 local tag_id=`got ref -r $testroot/repo -l \
429 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
431 got ref -l -r $testroot/repo-clone > $testroot/stdout
433 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
434 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
435 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
436 >> $testroot/stdout.expected
437 echo "refs/remotes/origin/master: $commit_id" \
438 >> $testroot/stdout.expected
439 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
441 cmp -s $testroot/stdout $testroot/stdout.expected
442 ret=$?
443 if [ $ret -ne 0 ]; then
444 diff -u $testroot/stdout.expected $testroot/stdout
445 test_done "$testroot" "$ret"
446 return 1
447 fi
449 got fetch -q -a -r $testroot/repo-clone
450 ret=$?
451 if [ $ret -ne 0 ]; then
452 echo "got fetch command failed unexpectedly" >&2
453 test_done "$testroot" "$ret"
454 return 1
455 fi
457 got ref -l -r $testroot/repo-clone > $testroot/stdout
459 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
460 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
461 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
462 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
463 >> $testroot/stdout.expected
464 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
465 echo "refs/remotes/origin/master: $commit_id" \
466 >> $testroot/stdout.expected
467 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
468 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
470 cmp -s $testroot/stdout $testroot/stdout.expected
471 ret=$?
472 if [ $ret -ne 0 ]; then
473 diff -u $testroot/stdout.expected $testroot/stdout
474 fi
475 test_done "$testroot" "$ret"
478 test_fetch_empty_packfile() {
479 local testroot=`test_init fetch_empty_packfile`
480 local testurl=ssh://127.0.0.1/$testroot
481 local commit_id=`git_show_head $testroot/repo`
483 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
484 local tag_id=`got ref -r $testroot/repo -l \
485 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
487 got clone -q $testurl/repo $testroot/repo-clone
488 ret=$?
489 if [ $ret -ne 0 ]; then
490 echo "got clone command failed unexpectedly" >&2
491 test_done "$testroot" "$ret"
492 return 1
493 fi
495 got branch -r $testroot/repo -c $commit_id foo
496 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
498 got ref -l -r $testroot/repo-clone > $testroot/stdout
500 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
501 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
502 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
503 >> $testroot/stdout.expected
504 echo "refs/remotes/origin/master: $commit_id" \
505 >> $testroot/stdout.expected
506 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
507 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
509 cmp -s $testroot/stdout $testroot/stdout.expected
510 ret=$?
511 if [ $ret -ne 0 ]; then
512 diff -u $testroot/stdout.expected $testroot/stdout
513 test_done "$testroot" "$ret"
514 return 1
515 fi
517 got fetch -q -a -r $testroot/repo-clone
518 ret=$?
519 if [ $ret -ne 0 ]; then
520 echo "got fetch command failed unexpectedly" >&2
521 test_done "$testroot" "$ret"
522 return 1
523 fi
525 got ref -l -r $testroot/repo-clone > $testroot/stdout
527 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
529 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
530 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
531 >> $testroot/stdout.expected
532 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
533 echo "refs/remotes/origin/master: $commit_id" \
534 >> $testroot/stdout.expected
535 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
536 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
538 cmp -s $testroot/stdout $testroot/stdout.expected
539 ret=$?
540 if [ $ret -ne 0 ]; then
541 diff -u $testroot/stdout.expected $testroot/stdout
542 fi
543 test_done "$testroot" "$ret"
546 test_fetch_delete_branch() {
547 local testroot=`test_init fetch_delete_branch`
548 local testurl=ssh://127.0.0.1/$testroot
549 local commit_id=`git_show_head $testroot/repo`
552 got branch -r $testroot/repo -c $commit_id foo
553 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
554 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
555 local tag_id=`got ref -r $testroot/repo -l \
556 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
558 got clone -a -q $testurl/repo $testroot/repo-clone
559 ret=$?
560 if [ $ret -ne 0 ]; then
561 echo "got clone command failed unexpectedly" >&2
562 test_done "$testroot" "$ret"
563 return 1
564 fi
566 got ref -l -r $testroot/repo-clone > $testroot/stdout
568 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
569 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
570 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
571 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
572 >> $testroot/stdout.expected
573 echo "refs/remotes/origin/foo: $commit_id" \
574 >> $testroot/stdout.expected
575 echo "refs/remotes/origin/master: $commit_id" \
576 >> $testroot/stdout.expected
577 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
578 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
580 cmp -s $testroot/stdout $testroot/stdout.expected
581 ret=$?
582 if [ $ret -ne 0 ]; then
583 diff -u $testroot/stdout.expected $testroot/stdout
584 test_done "$testroot" "$ret"
585 return 1
586 fi
588 got branch -r $testroot/repo -d foo >/dev/null
590 got fetch -q -r $testroot/repo-clone
591 ret=$?
592 if [ $ret -ne 0 ]; then
593 echo "got fetch command failed unexpectedly" >&2
594 test_done "$testroot" "$ret"
595 return 1
596 fi
598 got ref -l -r $testroot/repo-clone > $testroot/stdout
600 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
601 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
602 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
603 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
604 >> $testroot/stdout.expected
605 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
606 echo "refs/remotes/origin/master: $commit_id" \
607 >> $testroot/stdout.expected
608 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
609 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
611 cmp -s $testroot/stdout $testroot/stdout.expected
612 ret=$?
613 if [ $ret -ne 0 ]; then
614 diff -u $testroot/stdout.expected $testroot/stdout
615 test_done "$testroot" "$ret"
616 return 1
617 fi
619 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
620 ret=$?
621 if [ $ret -ne 0 ]; then
622 echo "got fetch command failed unexpectedly" >&2
623 test_done "$testroot" "$ret"
624 return 1
625 fi
627 echo -n > $testroot/stdout.expected
629 cmp -s $testroot/stdout $testroot/stdout.expected
630 ret=$?
631 if [ $ret -ne 0 ]; then
632 diff -u $testroot/stdout.expected $testroot/stdout
633 test_done "$testroot" "$ret"
634 return 1
635 fi
637 got ref -l -r $testroot/repo-clone > $testroot/stdout
639 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
640 # refs/heads/foo is now deleted
641 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
642 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
643 >> $testroot/stdout.expected
644 # refs/remotes/origin/foo is now deleted
645 echo "refs/remotes/origin/master: $commit_id" \
646 >> $testroot/stdout.expected
647 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
648 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
650 cmp -s $testroot/stdout $testroot/stdout.expected
651 ret=$?
652 if [ $ret -ne 0 ]; then
653 diff -u $testroot/stdout.expected $testroot/stdout
654 fi
655 test_done "$testroot" "$ret"
659 test_fetch_delete_branch_mirror() {
660 local testroot=`test_init fetch_delete_branch_mirror`
661 local testurl=ssh://127.0.0.1/$testroot
662 local commit_id=`git_show_head $testroot/repo`
664 got branch -r $testroot/repo -c $commit_id foo
665 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
666 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
667 local tag_id=`got ref -r $testroot/repo -l \
668 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
670 got clone -a -m -q $testurl/repo $testroot/repo-clone
671 ret=$?
672 if [ $ret -ne 0 ]; then
673 echo "got clone command failed unexpectedly" >&2
674 test_done "$testroot" "$ret"
675 return 1
676 fi
678 got ref -l -r $testroot/repo-clone > $testroot/stdout
680 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
681 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
682 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
683 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
684 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
686 cmp -s $testroot/stdout $testroot/stdout.expected
687 ret=$?
688 if [ $ret -ne 0 ]; then
689 diff -u $testroot/stdout.expected $testroot/stdout
690 test_done "$testroot" "$ret"
691 return 1
692 fi
694 got branch -r $testroot/repo -d foo >/dev/null
696 got fetch -q -r $testroot/repo-clone
697 ret=$?
698 if [ $ret -ne 0 ]; then
699 echo "got fetch command failed unexpectedly" >&2
700 test_done "$testroot" "$ret"
701 return 1
702 fi
704 got ref -l -r $testroot/repo-clone > $testroot/stdout
706 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
707 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
708 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
709 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
710 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
712 cmp -s $testroot/stdout $testroot/stdout.expected
713 ret=$?
714 if [ $ret -ne 0 ]; then
715 diff -u $testroot/stdout.expected $testroot/stdout
716 test_done "$testroot" "$ret"
717 return 1
718 fi
720 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
721 ret=$?
722 if [ $ret -ne 0 ]; then
723 echo "got fetch command failed unexpectedly" >&2
724 test_done "$testroot" "$ret"
725 return 1
726 fi
728 echo -n > $testroot/stdout.expected
730 cmp -s $testroot/stdout $testroot/stdout.expected
731 ret=$?
732 if [ $ret -ne 0 ]; then
733 diff -u $testroot/stdout.expected $testroot/stdout
734 test_done "$testroot" "$ret"
735 return 1
736 fi
738 got ref -l -r $testroot/repo-clone > $testroot/stdout
740 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
741 # refs/heads/foo is now deleted
742 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
743 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
744 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
746 cmp -s $testroot/stdout $testroot/stdout.expected
747 ret=$?
748 if [ $ret -ne 0 ]; then
749 diff -u $testroot/stdout.expected $testroot/stdout
750 fi
751 test_done "$testroot" "$ret"
755 test_fetch_update_tag() {
756 local testroot=`test_init fetch_update_tag`
757 local testurl=ssh://127.0.0.1/$testroot
758 local commit_id=`git_show_head $testroot/repo`
761 got branch -r $testroot/repo -c $commit_id foo
762 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
763 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
764 local tag_id=`got ref -r $testroot/repo -l \
765 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
767 got clone -a -q $testurl/repo $testroot/repo-clone
768 ret=$?
769 if [ $ret -ne 0 ]; then
770 echo "got clone command failed unexpectedly" >&2
771 test_done "$testroot" "$ret"
772 return 1
773 fi
775 echo "modified alpha on master" > $testroot/repo/alpha
776 git_commit $testroot/repo -m "modified alpha"
777 local commit_id2=`git_show_head $testroot/repo`
779 got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
780 got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
781 local tag_id2=`got ref -r $testroot/repo -l \
782 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
784 got ref -l -r $testroot/repo-clone > $testroot/stdout
786 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
787 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
788 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
789 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
790 >> $testroot/stdout.expected
791 echo "refs/remotes/origin/foo: $commit_id" \
792 >> $testroot/stdout.expected
793 echo "refs/remotes/origin/master: $commit_id" \
794 >> $testroot/stdout.expected
795 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
796 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
798 cmp -s $testroot/stdout $testroot/stdout.expected
799 ret=$?
800 if [ $ret -ne 0 ]; then
801 diff -u $testroot/stdout.expected $testroot/stdout
802 test_done "$testroot" "$ret"
803 return 1
804 fi
806 got fetch -a -q -r $testroot/repo-clone
807 ret=$?
808 if [ $ret -ne 0 ]; then
809 echo "got fetch command failed unexpectedly" >&2
810 test_done "$testroot" "$ret"
811 return 1
812 fi
814 got ref -l -r $testroot/repo-clone > $testroot/stdout
816 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
817 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
818 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
819 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
820 >> $testroot/stdout.expected
821 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
822 echo "refs/remotes/origin/master: $commit_id2" \
823 >> $testroot/stdout.expected
824 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
825 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
827 cmp -s $testroot/stdout $testroot/stdout.expected
828 ret=$?
829 if [ $ret -ne 0 ]; then
830 diff -u $testroot/stdout.expected $testroot/stdout
831 test_done "$testroot" "$ret"
832 return 1
833 fi
835 got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
836 tail -n 1 > $testroot/stdout
837 ret=$?
838 if [ $ret -ne 0 ]; then
839 echo "got fetch command failed unexpectedly" >&2
840 test_done "$testroot" "$ret"
841 return 1
842 fi
844 echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
845 > $testroot/stdout.expected
847 cmp -s $testroot/stdout $testroot/stdout.expected
848 ret=$?
849 if [ $ret -ne 0 ]; then
850 diff -u $testroot/stdout.expected $testroot/stdout
851 test_done "$testroot" "$ret"
852 return 1
853 fi
855 got ref -l -r $testroot/repo-clone > $testroot/stdout
857 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
858 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
859 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
860 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
861 >> $testroot/stdout.expected
862 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
863 echo "refs/remotes/origin/master: $commit_id2" \
864 >> $testroot/stdout.expected
865 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
866 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
868 cmp -s $testroot/stdout $testroot/stdout.expected
869 ret=$?
870 if [ $ret -ne 0 ]; then
871 diff -u $testroot/stdout.expected $testroot/stdout
872 test_done "$testroot" "$ret"
873 return 1
874 fi
876 got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
877 ret=$?
878 if [ $ret -ne 0 ]; then
879 echo "got fetch command failed unexpectedly" >&2
880 test_done "$testroot" "$ret"
881 return 1
882 fi
884 echo -n > $testroot/stdout.expected
886 cmp -s $testroot/stdout $testroot/stdout.expected
887 ret=$?
888 if [ $ret -ne 0 ]; then
889 diff -u $testroot/stdout.expected $testroot/stdout
890 test_done "$testroot" "$ret"
891 return 1
892 fi
894 got ref -l -r $testroot/repo-clone > $testroot/stdout
896 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
897 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
898 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
899 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
900 >> $testroot/stdout.expected
901 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
902 echo "refs/remotes/origin/master: $commit_id2" \
903 >> $testroot/stdout.expected
904 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
905 echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
907 cmp -s $testroot/stdout $testroot/stdout.expected
908 ret=$?
909 if [ $ret -ne 0 ]; then
910 diff -u $testroot/stdout.expected $testroot/stdout
911 fi
912 test_done "$testroot" "$ret"
915 test_fetch_reference() {
916 local testroot=`test_init fetch_reference`
917 local testurl=ssh://127.0.0.1/$testroot
918 local commit_id=`git_show_head $testroot/repo`
920 got clone -q $testurl/repo $testroot/repo-clone
921 ret=$?
922 if [ $ret -ne 0 ]; then
923 echo "got clone command failed unexpectedly" >&2
924 test_done "$testroot" "$ret"
925 return 1
926 fi
928 got branch -r $testroot/repo -c $commit_id foo
929 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
930 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
931 local tag_id=`got ref -r $testroot/repo -l \
932 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
934 echo "modified alpha on master" > $testroot/repo/alpha
935 git_commit $testroot/repo -m "modified alpha"
936 local commit_id2=`git_show_head $testroot/repo`
938 (cd $testroot/repo && git checkout -q foo)
939 echo "modified alpha on foo" > $testroot/repo/alpha
940 git_commit $testroot/repo -m "modified alpha"
941 local commit_id3=`git_show_head $testroot/repo`
942 (cd $testroot/repo && git checkout -q master)
944 got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
945 > $testroot/stdout 2> $testroot/stderr
946 ret=$?
947 if [ $ret -eq 0 ]; then
948 echo "got fetch command succeeded unexpectedly" >&2
949 test_done "$testroot" "1"
950 return 1
951 fi
953 echo -n > $testroot/stdout.expected
955 cmp -s $testroot/stdout $testroot/stdout.expected
956 ret=$?
957 if [ $ret -ne 0 ]; then
958 diff -u $testroot/stdout.expected $testroot/stdout
959 test_done "$testroot" "$ret"
960 return 1
961 fi
963 echo "got: refs/remotes/origin/main: reference cannot be fetched" \
964 > $testroot/stderr.expected
966 cmp -s $testroot/stderr $testroot/stderr.expected
967 ret=$?
968 if [ $ret -ne 0 ]; then
969 diff -u $testroot/stderr.expected $testroot/stderr
970 test_done "$testroot" "$ret"
971 return 1
972 fi
974 got fetch -q -r $testroot/repo-clone -R refs/hoo
975 ret=$?
976 if [ $ret -ne 0 ]; then
977 echo "got fetch command failed unexpectedly" >&2
978 test_done "$testroot" "$ret"
979 return 1
980 fi
982 got ref -l -r $testroot/repo-clone > $testroot/stdout
984 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
985 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
986 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
987 >> $testroot/stdout.expected
988 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
989 >> $testroot/stdout.expected
990 echo "refs/remotes/origin/master: $commit_id2" \
991 >> $testroot/stdout.expected
992 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
994 cmp -s $testroot/stdout $testroot/stdout.expected
995 ret=$?
996 if [ $ret -ne 0 ]; then
997 diff -u $testroot/stdout.expected $testroot/stdout
998 fi
999 test_done "$testroot" "$ret"
1003 test_fetch_replace_symref() {
1004 local testroot=`test_init fetch_replace_symref`
1005 local testurl=ssh://127.0.0.1/$testroot
1006 local commit_id=`git_show_head $testroot/repo`
1008 got clone -m -q $testurl/repo $testroot/repo-clone
1009 ret=$?
1010 if [ $ret -ne 0 ]; then
1011 echo "got clone command failed unexpectedly" >&2
1012 test_done "$testroot" "$ret"
1013 return 1
1016 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1017 got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1019 got ref -l -r $testroot/repo-clone > $testroot/stdout
1021 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1022 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1023 echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1025 cmp -s $testroot/stdout $testroot/stdout.expected
1026 ret=$?
1027 if [ $ret -ne 0 ]; then
1028 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1030 return 1
1033 got fetch -r $testroot/repo-clone -R refs/hoo \
1034 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1035 ret=$?
1036 if [ $ret -ne 0 ]; then
1037 echo "got fetch command failed unexpectedly" >&2
1038 test_done "$testroot" "$ret"
1039 return 1
1042 echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1043 > $testroot/stdout.expected
1045 cmp -s $testroot/stdout $testroot/stdout.expected
1046 ret=$?
1047 if [ $ret -ne 0 ]; then
1048 diff -u $testroot/stdout.expected $testroot/stdout
1049 test_done "$testroot" "$ret"
1050 return 1
1053 got ref -l -r $testroot/repo-clone > $testroot/stdout
1055 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1056 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1057 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1059 cmp -s $testroot/stdout $testroot/stdout.expected
1060 ret=$?
1061 if [ $ret -ne 0 ]; then
1062 diff -u $testroot/stdout.expected $testroot/stdout
1064 test_done "$testroot" "$ret"
1068 test_fetch_update_headref() {
1069 local testroot=`test_init fetch_update_headref`
1070 local testurl=ssh://127.0.0.1/$testroot
1071 local commit_id=`git_show_head $testroot/repo`
1073 got clone -q $testurl/repo $testroot/repo-clone
1074 ret=$?
1075 if [ $ret -ne 0 ]; then
1076 echo "got clone command failed unexpectedly" >&2
1077 test_done "$testroot" "$ret"
1078 return 1
1081 got ref -l -r $testroot/repo-clone > $testroot/stdout
1083 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1084 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1085 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1086 >> $testroot/stdout.expected
1087 echo "refs/remotes/origin/master: $commit_id" \
1088 >> $testroot/stdout.expected
1090 cmp -s $testroot/stdout $testroot/stdout.expected
1091 ret=$?
1092 if [ $ret -ne 0 ]; then
1093 diff -u $testroot/stdout.expected $testroot/stdout
1094 test_done "$testroot" "$ret"
1095 return 1
1098 got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1099 got ref -r $testroot/repo -s refs/heads/foo HEAD
1100 got ref -l -r $testroot/repo > $testroot/stdout
1102 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1103 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1104 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1106 cmp -s $testroot/stdout $testroot/stdout.expected
1107 ret=$?
1108 if [ $ret -ne 0 ]; then
1109 diff -u $testroot/stdout.expected $testroot/stdout
1110 test_done "$testroot" "$ret"
1111 return 1
1114 got fetch -q -r $testroot/repo-clone
1116 got ref -l -r $testroot/repo-clone > $testroot/stdout
1118 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1119 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1120 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1121 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1122 >> $testroot/stdout.expected
1123 echo "refs/remotes/origin/foo: $commit_id" \
1124 >> $testroot/stdout.expected
1125 echo "refs/remotes/origin/master: $commit_id" \
1126 >> $testroot/stdout.expected
1128 cmp -s $testroot/stdout $testroot/stdout.expected
1129 ret=$?
1130 if [ $ret -ne 0 ]; then
1131 diff -u $testroot/stdout.expected $testroot/stdout
1132 test_done "$testroot" "$ret"
1133 return 1
1136 got fetch -q -r $testroot/repo-clone -a
1138 got ref -l -r $testroot/repo-clone > $testroot/stdout
1140 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1141 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1142 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1143 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1144 >> $testroot/stdout.expected
1145 echo "refs/remotes/origin/foo: $commit_id" \
1146 >> $testroot/stdout.expected
1147 echo "refs/remotes/origin/master: $commit_id" \
1148 >> $testroot/stdout.expected
1150 cmp -s $testroot/stdout $testroot/stdout.expected
1151 ret=$?
1152 if [ $ret -ne 0 ]; then
1153 diff -u $testroot/stdout.expected $testroot/stdout
1155 test_done "$testroot" "$ret"
1158 test_fetch_headref_deleted_locally() {
1159 local testroot=`test_init fetch_headref_deleted_locally`
1160 local testurl=ssh://127.0.0.1/$testroot
1161 local commit_id=`git_show_head $testroot/repo`
1163 got clone -q $testurl/repo $testroot/repo-clone
1164 ret=$?
1165 if [ $ret -ne 0 ]; then
1166 echo "got clone command failed unexpectedly" >&2
1167 test_done "$testroot" "$ret"
1168 return 1
1171 got ref -l -r $testroot/repo-clone > $testroot/stdout
1173 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1174 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1175 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1176 >> $testroot/stdout.expected
1177 echo "refs/remotes/origin/master: $commit_id" \
1178 >> $testroot/stdout.expected
1180 cmp -s $testroot/stdout $testroot/stdout.expected
1181 ret=$?
1182 if [ $ret -ne 0 ]; then
1183 diff -u $testroot/stdout.expected $testroot/stdout
1184 test_done "$testroot" "$ret"
1185 return 1
1188 got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1190 got fetch -q -r $testroot/repo-clone
1191 ret=$?
1192 if [ $ret -ne 0 ]; then
1193 echo "got fetch command failed unexpectedly" >&2
1194 test_done "$testroot" "$ret"
1195 return 1
1197 got ref -l -r $testroot/repo-clone > $testroot/stdout
1199 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1200 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1201 # refs/remotes/origin/HEAD has been restored:
1202 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1203 >> $testroot/stdout.expected
1204 echo "refs/remotes/origin/master: $commit_id" \
1205 >> $testroot/stdout.expected
1207 cmp -s $testroot/stdout $testroot/stdout.expected
1208 ret=$?
1209 if [ $ret -ne 0 ]; then
1210 diff -u $testroot/stdout.expected $testroot/stdout
1212 test_done "$testroot" "$ret"
1215 test_fetch_gotconfig_remote_repo() {
1216 local testroot=`test_init fetch_gotconfig_remote_repo`
1217 local testurl=ssh://127.0.0.1/$testroot
1218 local commit_id=`git_show_head $testroot/repo`
1220 got branch -r $testroot/repo -c $commit_id foo
1221 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1222 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1224 got clone -q $testurl/repo $testroot/repo-clone
1225 ret=$?
1226 if [ $ret -ne 0 ]; then
1227 echo "got clone command failed unexpectedly" >&2
1228 test_done "$testroot" "$ret"
1229 return 1
1232 cat > $testroot/repo-clone/got.conf <<EOF
1233 remote "foobar" {
1234 protocol ssh
1235 server 127.0.0.1
1236 repository "$testroot/repo"
1239 remote "barbaz" {
1240 protocol ssh
1241 server 127.0.0.1
1242 repository "$testroot/does-not-exist"
1244 EOF
1245 echo "got: nonexistent: remote repository not found" \
1246 > $testroot/stderr.expected
1247 (cd $testroot/repo-clone && got fetch -q nonexistent \
1248 > $testroot/stdout 2> $testroot/stderr)
1249 ret=$?
1250 if [ $ret -eq 0 ]; then
1251 echo "got fetch command succeeded unexpectedly" >&2
1252 diff -u $testroot/stderr.expected $testroot/stderr
1253 test_done "$testroot" "1"
1254 return 1
1257 (cd $testroot/repo-clone && got fetch -q -l foobar \
1258 > $testroot/stdout)
1259 ret=$?
1260 if [ $ret -ne 0 ]; then
1261 echo "got fetch command failed unexpectedly" >&2
1262 test_done "$testroot" "$ret"
1263 return 1
1266 got ref -l -r $testroot/repo > $testroot/stdout.expected
1268 cmp -s $testroot/stdout $testroot/stdout.expected
1269 ret=$?
1270 if [ $ret -ne 0 ]; then
1271 diff -u $testroot/stdout.expected $testroot/stdout
1272 test_done "$testroot" "$ret"
1273 return 1
1276 got checkout $testroot/repo $testroot/wt > /dev/null
1278 cat > $testroot/wt/.got/got.conf <<EOF
1279 remote "barbaz" {
1280 protocol ssh
1281 server 127.0.0.1
1282 repository "$testroot/repo"
1284 EOF
1285 (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1286 ret=$?
1287 if [ $ret -ne 0 ]; then
1288 echo "got fetch command failed unexpectedly" >&2
1289 test_done "$testroot" "$ret"
1290 return 1
1293 got ref -l -r $testroot/repo > $testroot/stdout.expected
1295 cmp -s $testroot/stdout $testroot/stdout.expected
1296 ret=$?
1297 if [ $ret -ne 0 ]; then
1298 diff -u $testroot/stdout.expected $testroot/stdout
1299 test_done "$testroot" "$ret"
1300 return 1
1303 cat > $testroot/repo-clone/got.conf <<EOF
1304 remote "origin" {
1305 protocol ssh
1306 server 127.0.0.1
1307 repository "$testroot/repo"
1308 branch { "foo" }
1309 reference { "hoo/boo/zoo" }
1311 EOF
1312 (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1314 local tag_id=`got ref -r $testroot/repo -l \
1315 | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1316 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1317 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1318 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1319 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1320 >> $testroot/stdout.expected
1321 echo "refs/remotes/origin/foo: $commit_id" \
1322 >> $testroot/stdout.expected
1323 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1324 >> $testroot/stdout.expected
1325 echo "refs/remotes/origin/master: $commit_id" \
1326 >> $testroot/stdout.expected
1327 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1329 got ref -l -r $testroot/repo-clone > $testroot/stdout
1331 cmp -s $testroot/stdout $testroot/stdout.expected
1332 ret=$?
1333 if [ $ret -ne 0 ]; then
1334 diff -u $testroot/stdout.expected $testroot/stdout
1336 test_done "$testroot" "$ret"
1339 test_fetch_delete_remote_refs() {
1340 local testroot=`test_init fetch_delete_remote_refs`
1341 local testurl=ssh://127.0.0.1/$testroot
1342 local commit_id=`git_show_head $testroot/repo`
1344 got clone -q $testurl/repo $testroot/repo-clone
1345 ret=$?
1346 if [ $ret -ne 0 ]; then
1347 echo "got clone command failed unexpectedly" >&2
1348 test_done "$testroot" "$ret"
1349 return 1
1352 got ref -l -r $testroot/repo-clone > $testroot/stdout
1353 ret=$?
1354 if [ $ret -ne 0 ]; then
1355 echo "got ref command failed unexpectedly" >&2
1356 test_done "$testroot" "$ret"
1357 return 1
1360 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1361 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1362 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1363 >> $testroot/stdout.expected
1364 echo "refs/remotes/origin/master: $commit_id" \
1365 >> $testroot/stdout.expected
1367 cmp -s $testroot/stdout $testroot/stdout.expected
1368 ret=$?
1369 if [ $ret -ne 0 ]; then
1370 diff -u $testroot/stdout.expected $testroot/stdout
1371 test_done "$testroot" "$ret"
1372 return 1
1375 got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1376 2> $testroot/stderr
1377 ret=$?
1378 if [ $ret -eq 0 ]; then
1379 echo "got fetch command succeeded unexpectedly" >&2
1380 test_done "$testroot" "$ret"
1381 return 1
1384 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1385 cmp -s $testroot/stderr $testroot/stderr.expected
1386 ret=$?
1387 if [ $ret -ne 0 ]; then
1388 diff -u $testroot/stderr.expected $testroot/stderr
1389 test_done "$testroot" "$ret"
1390 return 1
1393 got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1394 2> $testroot/stderr
1395 ret=$?
1396 if [ $ret -ne 0 ]; then
1397 echo "got fetch command failed unexpectedly" >&2
1398 test_done "$testroot" "$ret"
1399 return 1
1402 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1403 echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1404 echo "Deleted refs/remotes/origin/master: $commit_id" \
1405 >> $testroot/stdout.expected
1407 cmp -s $testroot/stdout $testroot/stdout.expected
1408 ret=$?
1409 if [ $ret -ne 0 ]; then
1410 diff -u $testroot/stdout.expected $testroot/stdout
1411 test_done "$testroot" "$ret"
1412 return 1
1415 got ref -l -r $testroot/repo-clone > $testroot/stdout
1416 ret=$?
1417 if [ $ret -ne 0 ]; then
1418 echo "got ref command failed unexpectedly" >&2
1419 test_done "$testroot" "$ret"
1420 return 1
1423 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1424 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1426 cmp -s $testroot/stdout $testroot/stdout.expected
1427 ret=$?
1428 if [ $ret -ne 0 ]; then
1429 diff -u $testroot/stdout.expected $testroot/stdout
1431 test_done "$testroot" "$ret"
1434 test_fetch_honor_wt_conf_bflag() {
1435 local testroot=`test_init fetch_honor_wt_conf_bflag`
1436 local testurl=ssh://127.0.0.1/$testroot
1438 # server will have 'boo', 'hoo', and 'master'
1439 echo "modified alpha on master" > $testroot/repo/alpha
1440 git_commit $testroot/repo -m "modified alpha"
1441 local commit_id=`git_show_head $testroot/repo`
1443 got branch -r $testroot/repo -c $commit_id boo
1444 (cd $testroot/repo && git checkout -q boo)
1445 echo "modified beta on boo" > $testroot/repo/beta
1446 git_commit $testroot/repo -m "modified beta"
1447 local commit_id2=`git_show_head $testroot/repo`
1449 got branch -r $testroot/repo -c $commit_id2 hoo
1450 (cd $testroot/repo && git checkout -q hoo)
1451 echo "modified delta on hoo" > $testroot/repo/gamma/delta
1452 git_commit $testroot/repo -m "modified delta"
1453 local commit_id3=`git_show_head $testroot/repo`
1455 (cd $testroot/repo && git checkout -q master)
1456 got clone -q $testurl/repo $testroot/repo-clone
1457 ret=$?
1458 if [ $ret -ne 0 ]; then
1459 echo "got clone command failed unexpectedly" >&2
1460 test_done "$testroot" "$ret"
1461 return 1
1464 # only clone will have foo and bar
1465 got branch -r $testroot/repo-clone -c $commit_id foo
1466 got branch -r $testroot/repo-clone -c $commit_id bar
1468 got fetch -q -r $testroot/repo-clone > $testroot/stdout
1469 ret=$?
1470 if [ $ret -ne 0 ]; then
1471 echo "got fetch command failed unexpectedly" >&2
1472 test_done "$testroot" "$ret"
1473 return 1
1476 echo -n > $testroot/stdout.expected
1478 cmp -s $testroot/stdout $testroot/stdout.expected
1479 ret=$?
1480 if [ $ret -ne 0 ]; then
1481 diff -u $testroot/stdout.expected $testroot/stdout
1482 test_done "$testroot" "$ret"
1483 return 1
1486 got ref -l -r $testroot/repo-clone > $testroot/stdout
1488 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1489 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1490 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1491 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1492 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1493 >> $testroot/stdout.expected
1494 echo "refs/remotes/origin/master: $commit_id" \
1495 >> $testroot/stdout.expected
1497 cmp -s $testroot/stdout $testroot/stdout.expected
1498 ret=$?
1499 if [ $ret -ne 0 ]; then
1500 diff -u $testroot/stdout.expected $testroot/stdout
1501 test_done "$testroot" "$ret"
1502 return 1
1505 (cd $testroot/repo && git checkout -q boo)
1506 # clone has remote/origin/HEAD symref with "master" as its target
1507 # but the repo has changed HEAD to "boo", so we should fetch "boo"
1508 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1509 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1510 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1511 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1512 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1513 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1514 >> $testroot/stdout.expected
1515 echo "refs/remotes/origin/boo: $commit_id2" \
1516 >> $testroot/stdout.expected
1517 echo "refs/remotes/origin/master: $commit_id" \
1518 >> $testroot/stdout.expected
1520 got fetch -q -r $testroot/repo-clone > $testroot/stdout
1521 ret=$?
1522 if [ $ret -ne 0 ]; then
1523 echo "got fetch command failed unexpectedly" >&2
1524 test_done "$testroot" "$ret"
1525 return 1
1528 got ref -l -r $testroot/repo-clone > $testroot/stdout
1530 cmp -s $testroot/stdout $testroot/stdout.expected
1531 ret=$?
1532 if [ $ret -ne 0 ]; then
1533 diff -u $testroot/stdout.expected $testroot/stdout
1534 test_done "$testroot" "$ret"
1535 return 1
1538 # from repo: fetch -b hoo
1539 got fetch -q -r $testroot/repo-clone -b hoo > $testroot/stdout
1540 ret=$?
1541 if [ $ret -ne 0 ]; then
1542 echo "got fetch command failed unexpectedly" >&2
1543 test_done "$testroot" "$ret"
1544 return 1
1547 echo -n > $testroot/stdout.expected
1549 cmp -s $testroot/stdout $testroot/stdout.expected
1550 ret=$?
1551 if [ $ret -ne 0 ]; then
1552 diff -u $testroot/stdout.expected $testroot/stdout
1553 test_done "$testroot" "$ret"
1554 return 1
1557 got ref -l -r $testroot/repo-clone > $testroot/stdout
1559 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1560 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1561 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1562 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1563 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1564 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1565 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1566 >> $testroot/stdout.expected
1567 echo "refs/remotes/origin/boo: $commit_id2" \
1568 >> $testroot/stdout.expected
1569 echo "refs/remotes/origin/hoo: $commit_id3" \
1570 >> $testroot/stdout.expected
1571 echo "refs/remotes/origin/master: $commit_id" \
1572 >> $testroot/stdout.expected
1574 cmp -s $testroot/stdout $testroot/stdout.expected
1575 ret=$?
1576 if [ $ret -ne 0 ]; then
1577 diff -u $testroot/stdout.expected $testroot/stdout
1578 test_done "$testroot" "$ret"
1579 return 1
1582 # from repo: fetch -b foo which doesn't exist on the server but
1583 # do not fallback to repo HEAD "boo" because we used the -b flag
1584 got fetch -r $testroot/repo-clone -b foo > $testroot/stdout \
1585 2> $testroot/stderr
1587 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1588 > $testroot/stdout.expected
1589 echo "got-fetch-pack: branch \"foo\" not found on server" \
1590 > $testroot/stderr.expected
1591 echo "got: could not find any branches to fetch" \
1592 >> $testroot/stderr.expected
1594 cmp -s $testroot/stdout $testroot/stdout.expected
1595 ret=$?
1596 if [ $ret -ne 0 ]; then
1597 diff -u $testroot/stdout.expected $testroot/stdout
1598 test_done "$testroot" "$ret"
1599 return 1
1602 cmp -s $testroot/stderr $testroot/stderr.expected
1603 ret=$?
1604 if [ $ret -ne 0 ]; then
1605 diff -u $testroot/stderr.expected $testroot/stderr
1606 test_done "$testroot" "$ret"
1607 return 1
1610 # from repo: fetch got.conf branch which doesn't exist, so fallback
1611 # to repo HEAD "boo"
1612 # change default branch in got.conf from "master" to "foo"
1613 sed -i "s/master/foo/" $testroot/repo-clone/got.conf
1615 got fetch -q -r $testroot/repo-clone > $testroot/stdout
1616 ret=$?
1617 if [ $ret -ne 0 ]; then
1618 echo "got fetch command failed unexpectedly" >&2
1619 test_done "$testroot" "$ret"
1620 return 1
1623 echo -n > $testroot/stdout.expected
1625 cmp -s $testroot/stdout $testroot/stdout.expected
1626 ret=$?
1627 if [ $ret -ne 0 ]; then
1628 diff -u $testroot/stdout.expected $testroot/stdout
1629 test_done "$testroot" "$ret"
1630 return 1
1633 got ref -l -r $testroot/repo-clone > $testroot/stdout
1635 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1636 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1637 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1638 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1639 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1640 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1641 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1642 >> $testroot/stdout.expected
1643 echo "refs/remotes/origin/boo: $commit_id2" \
1644 >> $testroot/stdout.expected
1645 echo "refs/remotes/origin/hoo: $commit_id3" \
1646 >> $testroot/stdout.expected
1647 echo "refs/remotes/origin/master: $commit_id" \
1648 >> $testroot/stdout.expected
1650 cmp -s $testroot/stdout $testroot/stdout.expected
1651 ret=$?
1652 if [ $ret -ne 0 ]; then
1653 diff -u $testroot/stdout.expected $testroot/stdout
1654 test_done "$testroot" "$ret"
1655 return 1
1658 # from wt: fetch got.conf "foo", which doesn't exist on the server,
1659 # and implicit wt branch "boo", not repo HEAD "master"
1660 echo "modified delta on boo" > $testroot/repo/gamma/delta
1661 git_commit $testroot/repo -m "modified delta"
1662 local commit_id4=`git_show_head $testroot/repo`
1664 (cd $testroot/repo && git checkout -q master)
1666 got checkout -b boo $testroot/repo-clone $testroot/wt > /dev/null
1667 (cd $testroot/wt && got fetch -q > $testroot/stdout)
1669 echo -n > $testroot/stdout.expected
1671 cmp -s $testroot/stdout $testroot/stdout.expected
1672 ret=$?
1673 if [ $ret -ne 0 ]; then
1674 diff -u $testroot/stdout.expected $testroot/stdout
1675 test_done "$testroot" "$ret"
1676 return 1
1679 local wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1680 cut -d ':' -f 2 | tr -d ' ')`
1682 got ref -l -r $testroot/repo-clone > $testroot/stdout
1684 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1685 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1686 >> $testroot/stdout.expected
1687 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1688 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1689 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1690 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1691 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1692 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1693 >> $testroot/stdout.expected
1694 echo "refs/remotes/origin/boo: $commit_id4" \
1695 >> $testroot/stdout.expected
1696 echo "refs/remotes/origin/hoo: $commit_id3" \
1697 >> $testroot/stdout.expected
1698 echo "refs/remotes/origin/master: $commit_id" \
1699 >> $testroot/stdout.expected
1701 cmp -s $testroot/stdout $testroot/stdout.expected
1702 ret=$?
1703 if [ $ret -ne 0 ]; then
1704 diff -u $testroot/stdout.expected $testroot/stdout
1705 test_done "$testroot" "$ret"
1706 return 1
1709 # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD
1710 # "hoo" as it no longer matches our remote HEAD symref target "master"
1711 sed -i "s/foo/master/" $testroot/repo-clone/got.conf
1712 echo "modified delta on master" > $testroot/repo/gamma/delta
1713 git_commit $testroot/repo -m "modified delta on master"
1714 local commit_id5=`git_show_head $testroot/repo`
1716 (cd $testroot/repo && git checkout -q boo)
1717 echo "modified alpha on boo" > $testroot/repo/alpha
1718 git_commit $testroot/repo -m "modified alpha on boo"
1719 local commit_id6=`git_show_head $testroot/repo`
1721 (cd $testroot/repo && git checkout -q hoo)
1722 echo "modified beta on hoo" > $testroot/repo/beta
1723 git_commit $testroot/repo -m "modified beta on hoo"
1724 local commit_id7=`git_show_head $testroot/repo`
1726 (cd $testroot/wt && got fetch -q > $testroot/stdout)
1728 echo -n > $testroot/stdout.expected
1730 cmp -s $testroot/stdout $testroot/stdout.expected
1731 ret=$?
1732 if [ $ret -ne 0 ]; then
1733 diff -u $testroot/stdout.expected $testroot/stdout
1734 test_done "$testroot" "$ret"
1735 return 1
1738 got ref -l -r $testroot/repo-clone > $testroot/stdout
1740 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1741 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1742 >> $testroot/stdout.expected
1743 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1744 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1745 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1746 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1747 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1748 echo "refs/remotes/origin/HEAD: refs/remotes/origin/hoo" \
1749 >> $testroot/stdout.expected
1750 echo "refs/remotes/origin/boo: $commit_id6" \
1751 >> $testroot/stdout.expected
1752 echo "refs/remotes/origin/hoo: $commit_id7" \
1753 >> $testroot/stdout.expected
1754 echo "refs/remotes/origin/master: $commit_id5" \
1755 >> $testroot/stdout.expected
1757 cmp -s $testroot/stdout $testroot/stdout.expected
1758 ret=$?
1759 if [ $ret -ne 0 ]; then
1760 diff -u $testroot/stdout.expected $testroot/stdout
1761 test_done "$testroot" "$ret"
1762 return 1
1765 # from wt: fetch -b hoo not got.conf "master" or wt "boo" or
1766 # repo HEAD "boo"
1767 (cd $testroot/repo && git checkout -q boo)
1768 echo "modified alpha again on boo" > $testroot/repo/alpha
1769 git_commit $testroot/repo -m "modified alpha again on boo"
1770 local commit_id8=`git_show_head $testroot/repo`
1772 (cd $testroot/wt && got fetch -q -b hoo > $testroot/stdout)
1774 echo -n > $testroot/stdout.expected
1776 cmp -s $testroot/stdout $testroot/stdout.expected
1777 ret=$?
1778 if [ $ret -ne 0 ]; then
1779 diff -u $testroot/stdout.expected $testroot/stdout
1780 test_done "$testroot" "$ret"
1781 return 1
1784 got ref -l -r $testroot/repo-clone > $testroot/stdout
1786 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1787 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1788 >> $testroot/stdout.expected
1789 echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1790 echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1791 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1792 echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1793 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1794 echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1795 >> $testroot/stdout.expected
1796 echo "refs/remotes/origin/boo: $commit_id6" \
1797 >> $testroot/stdout.expected
1798 echo "refs/remotes/origin/hoo: $commit_id7" \
1799 >> $testroot/stdout.expected
1800 echo "refs/remotes/origin/master: $commit_id5" \
1801 >> $testroot/stdout.expected
1803 cmp -s $testroot/stdout $testroot/stdout.expected
1804 ret=$?
1805 if [ $ret -ne 0 ]; then
1806 diff -u $testroot/stdout.expected $testroot/stdout
1807 test_done "$testroot" "$ret"
1808 return 1
1811 # from wt: fetch -b bar that doesn't exist on the server but
1812 # do not fetch got.conf "master" or wt "boo" or repo HEAD "boo"
1813 (cd $testroot/wt && got fetch -b bar > $testroot/stdout \
1814 2> $testroot/stderr)
1816 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1817 > $testroot/stdout.expected
1818 echo "got-fetch-pack: branch \"bar\" not found on server" \
1819 > $testroot/stderr.expected
1820 echo "got: could not find any branches to fetch" \
1821 >> $testroot/stderr.expected
1823 cmp -s $testroot/stderr $testroot/stderr.expected
1824 ret=$?
1825 if [ $ret -ne 0 ]; then
1826 diff -u $testroot/stderr.expected $testroot/stderr
1827 test_done "$testroot" "$ret"
1828 return 1
1831 cmp -s $testroot/stdout $testroot/stdout.expected
1832 ret=$?
1833 if [ $ret -ne 0 ]; then
1834 diff -u $testroot/stdout.expected $testroot/stdout
1836 test_done "$testroot" "$ret"
1839 test_fetch_from_out_of_date_remote() {
1840 local testroot=`test_init fetch_from_out_of_date_remote`
1841 local testurl=ssh://127.0.0.1/$testroot
1842 local commit_id=`git_show_head $testroot/repo`
1844 got clone -q $testurl/repo $testroot/repo-clone
1845 ret=$?
1846 if [ $ret -ne 0 ]; then
1847 echo "got clone command failed unexpectedly" >&2
1848 test_done "$testroot" "$ret"
1849 return 1
1852 echo "modified alpha" > $testroot/repo/alpha
1853 git_commit $testroot/repo -m "modified alpha"
1854 local commit_id2=`git_show_head $testroot/repo`
1856 got clone -q $testurl/repo $testroot/repo-clone2 \
1857 > $testroot/stdout 2> $testroot/stderr
1858 ret=$?
1859 if [ $ret -ne 0 ]; then
1860 echo "got clone command failed unexpectedly" >&2
1861 test_done "$testroot" "$ret"
1862 return 1
1865 got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1866 ret=$?
1867 if [ $ret -ne 0 ]; then
1868 echo "got ref command failed unexpectedly" >&2
1869 test_done "$testroot" "$ret"
1870 return 1
1873 cat > $testroot/stdout.expected <<EOF
1874 HEAD: refs/heads/master
1875 refs/heads/master: $commit_id2
1876 refs/remotes/origin/HEAD: refs/remotes/origin/master
1877 refs/remotes/origin/master: $commit_id2
1878 EOF
1879 cmp -s $testroot/stdout $testroot/stdout.expected
1880 ret=$?
1881 if [ $ret -ne 0 ]; then
1882 diff -u $testroot/stdout.expected $testroot/stdout
1883 test_done "$testroot" "$ret"
1884 return 1
1887 cat >> $testroot/repo-clone2/got.conf <<EOF
1888 remote "other" {
1889 server "127.0.0.1"
1890 protocol ssh
1891 repository "$testroot/repo-clone"
1892 branch { "master" }
1894 EOF
1895 got fetch -q -r $testroot/repo-clone2 other \
1896 > $testroot/stdout 2> $testroot/stderr
1897 ret=$?
1898 if [ $ret -ne 0 ]; then
1899 echo "got fetch command failed unexpectedly" >&2
1900 test_done "$testroot" "$ret"
1901 return 1
1904 got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1905 ret=$?
1906 if [ $ret -ne 0 ]; then
1907 echo "got ref command failed unexpectedly" >&2
1908 test_done "$testroot" "$ret"
1909 return 1
1912 cat > $testroot/stdout.expected <<EOF
1913 HEAD: refs/heads/master
1914 refs/heads/master: $commit_id2
1915 refs/remotes/origin/HEAD: refs/remotes/origin/master
1916 refs/remotes/origin/master: $commit_id2
1917 refs/remotes/other/HEAD: refs/remotes/other/master
1918 refs/remotes/other/master: $commit_id
1919 EOF
1920 cmp -s $testroot/stdout $testroot/stdout.expected
1921 ret=$?
1922 if [ $ret -ne 0 ]; then
1923 diff -u $testroot/stdout.expected $testroot/stdout
1925 test_done "$testroot" "$ret"
1929 test_parseargs "$@"
1930 run_test test_fetch_basic
1931 run_test test_fetch_list
1932 run_test test_fetch_branch
1933 run_test test_fetch_all
1934 run_test test_fetch_empty_packfile
1935 run_test test_fetch_delete_branch
1936 run_test test_fetch_delete_branch_mirror
1937 run_test test_fetch_update_tag
1938 run_test test_fetch_reference
1939 run_test test_fetch_replace_symref
1940 run_test test_fetch_update_headref
1941 run_test test_fetch_headref_deleted_locally
1942 run_test test_fetch_gotconfig_remote_repo
1943 run_test test_fetch_delete_remote_refs
1944 run_test test_fetch_honor_wt_conf_bflag
1945 run_test test_fetch_from_out_of_date_remote