portable: move tmpl.h to EXTRA_DIST
[got-portable.git] / regress / cmdline / fetch.sh
blob8d6881ec92c2a3aff5b101a606dfd3264744dcca
1 #!/bin/sh
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
192 ret=$?
193 if [ $ret -ne 0 ]; then
194 echo "got fetch command failed unexpectedly" >&2
195 test_done "$testroot" "$ret"
196 return 1
199 echo -n > $testroot/stdout.expected
201 cmp -s $testroot/stdout $testroot/stdout.expected
202 ret=$?
203 if [ $ret -ne 0 ]; then
204 diff -u $testroot/stdout.expected $testroot/stdout
205 test_done "$testroot" "$ret"
206 return 1
209 got ref -l -r $testroot/repo-clone > $testroot/stdout
211 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
212 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
213 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
214 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
215 >> $testroot/stdout.expected
216 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
217 # refs/remotes/origin/master is umodified because it wasn't fetched
218 echo "refs/remotes/origin/master: $commit_id" \
219 >> $testroot/stdout.expected
220 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
221 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
223 cmp -s $testroot/stdout $testroot/stdout.expected
224 ret=$?
225 if [ $ret -ne 0 ]; then
226 diff -u $testroot/stdout.expected $testroot/stdout
227 test_done "$testroot" "$ret"
228 return 1
231 got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
232 ret=$?
233 if [ $ret -ne 0 ]; then
234 echo "got fetch command failed unexpectedly" >&2
235 test_done "$testroot" "$ret"
236 return 1
239 echo -n > $testroot/stdout.expected
241 cmp -s $testroot/stdout $testroot/stdout.expected
242 ret=$?
243 if [ $ret -ne 0 ]; then
244 diff -u $testroot/stdout.expected $testroot/stdout
245 test_done "$testroot" "$ret"
246 return 1
249 got ref -l -r $testroot/repo-clone > $testroot/stdout
251 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
252 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
253 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
254 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
255 >> $testroot/stdout.expected
256 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
257 echo "refs/remotes/origin/master: $commit_id2" \
258 >> $testroot/stdout.expected
259 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
260 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
262 cmp -s $testroot/stdout $testroot/stdout.expected
263 ret=$?
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stdout.expected $testroot/stdout
267 test_done "$testroot" "$ret"
270 test_fetch_all() {
271 local testroot=`test_init fetch_all`
272 local testurl=ssh://127.0.0.1/$testroot
273 local commit_id=`git_show_head $testroot/repo`
275 got clone -q $testurl/repo $testroot/repo-clone
276 ret=$?
277 if [ $ret -ne 0 ]; then
278 echo "got clone command failed unexpectedly" >&2
279 test_done "$testroot" "$ret"
280 return 1
283 got branch -r $testroot/repo -c $commit_id foo
284 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
285 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
286 local tag_id=`got ref -r $testroot/repo -l \
287 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
289 got ref -l -r $testroot/repo-clone > $testroot/stdout
291 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
292 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
293 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
294 >> $testroot/stdout.expected
295 echo "refs/remotes/origin/master: $commit_id" \
296 >> $testroot/stdout.expected
297 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
299 cmp -s $testroot/stdout $testroot/stdout.expected
300 ret=$?
301 if [ $ret -ne 0 ]; then
302 diff -u $testroot/stdout.expected $testroot/stdout
303 test_done "$testroot" "$ret"
304 return 1
307 got fetch -q -a -r $testroot/repo-clone
308 ret=$?
309 if [ $ret -ne 0 ]; then
310 echo "got fetch command failed unexpectedly" >&2
311 test_done "$testroot" "$ret"
312 return 1
315 got ref -l -r $testroot/repo-clone > $testroot/stdout
317 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
318 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
319 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
320 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
321 >> $testroot/stdout.expected
322 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
323 echo "refs/remotes/origin/master: $commit_id" \
324 >> $testroot/stdout.expected
325 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
326 echo "refs/tags/1.0: $tag_id" >> $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
333 test_done "$testroot" "$ret"
336 test_fetch_empty_packfile() {
337 local testroot=`test_init fetch_empty_packfile`
338 local testurl=ssh://127.0.0.1/$testroot
339 local commit_id=`git_show_head $testroot/repo`
341 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
342 local tag_id=`got ref -r $testroot/repo -l \
343 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
345 got clone -q $testurl/repo $testroot/repo-clone
346 ret=$?
347 if [ $ret -ne 0 ]; then
348 echo "got clone command failed unexpectedly" >&2
349 test_done "$testroot" "$ret"
350 return 1
353 got branch -r $testroot/repo -c $commit_id foo
354 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
356 got ref -l -r $testroot/repo-clone > $testroot/stdout
358 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
359 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
360 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
361 >> $testroot/stdout.expected
362 echo "refs/remotes/origin/master: $commit_id" \
363 >> $testroot/stdout.expected
364 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
365 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
367 cmp -s $testroot/stdout $testroot/stdout.expected
368 ret=$?
369 if [ $ret -ne 0 ]; then
370 diff -u $testroot/stdout.expected $testroot/stdout
371 test_done "$testroot" "$ret"
372 return 1
375 got fetch -q -a -r $testroot/repo-clone
376 ret=$?
377 if [ $ret -ne 0 ]; then
378 echo "got fetch command failed unexpectedly" >&2
379 test_done "$testroot" "$ret"
380 return 1
383 got ref -l -r $testroot/repo-clone > $testroot/stdout
385 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
386 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
387 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
388 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
389 >> $testroot/stdout.expected
390 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
391 echo "refs/remotes/origin/master: $commit_id" \
392 >> $testroot/stdout.expected
393 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
394 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
396 cmp -s $testroot/stdout $testroot/stdout.expected
397 ret=$?
398 if [ $ret -ne 0 ]; then
399 diff -u $testroot/stdout.expected $testroot/stdout
401 test_done "$testroot" "$ret"
404 test_fetch_delete_branch() {
405 local testroot=`test_init fetch_delete_branch`
406 local testurl=ssh://127.0.0.1/$testroot
407 local commit_id=`git_show_head $testroot/repo`
410 got branch -r $testroot/repo -c $commit_id foo
411 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
412 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
413 local tag_id=`got ref -r $testroot/repo -l \
414 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
416 got clone -a -q $testurl/repo $testroot/repo-clone
417 ret=$?
418 if [ $ret -ne 0 ]; then
419 echo "got clone command failed unexpectedly" >&2
420 test_done "$testroot" "$ret"
421 return 1
424 got ref -l -r $testroot/repo-clone > $testroot/stdout
426 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
427 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
428 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
429 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
430 >> $testroot/stdout.expected
431 echo "refs/remotes/origin/foo: $commit_id" \
432 >> $testroot/stdout.expected
433 echo "refs/remotes/origin/master: $commit_id" \
434 >> $testroot/stdout.expected
435 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
436 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
438 cmp -s $testroot/stdout $testroot/stdout.expected
439 ret=$?
440 if [ $ret -ne 0 ]; then
441 diff -u $testroot/stdout.expected $testroot/stdout
442 test_done "$testroot" "$ret"
443 return 1
446 got branch -r $testroot/repo -d foo >/dev/null
448 got fetch -q -r $testroot/repo-clone
449 ret=$?
450 if [ $ret -ne 0 ]; then
451 echo "got fetch command failed unexpectedly" >&2
452 test_done "$testroot" "$ret"
453 return 1
456 got ref -l -r $testroot/repo-clone > $testroot/stdout
458 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
459 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
460 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
461 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
462 >> $testroot/stdout.expected
463 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
464 echo "refs/remotes/origin/master: $commit_id" \
465 >> $testroot/stdout.expected
466 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
467 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
469 cmp -s $testroot/stdout $testroot/stdout.expected
470 ret=$?
471 if [ $ret -ne 0 ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
474 return 1
477 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
478 ret=$?
479 if [ $ret -ne 0 ]; then
480 echo "got fetch command failed unexpectedly" >&2
481 test_done "$testroot" "$ret"
482 return 1
485 echo -n > $testroot/stdout.expected
487 cmp -s $testroot/stdout $testroot/stdout.expected
488 ret=$?
489 if [ $ret -ne 0 ]; then
490 diff -u $testroot/stdout.expected $testroot/stdout
491 test_done "$testroot" "$ret"
492 return 1
495 got ref -l -r $testroot/repo-clone > $testroot/stdout
497 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
498 # refs/heads/foo is now deleted
499 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
500 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
501 >> $testroot/stdout.expected
502 # refs/remotes/origin/foo is now deleted
503 echo "refs/remotes/origin/master: $commit_id" \
504 >> $testroot/stdout.expected
505 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
506 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
508 cmp -s $testroot/stdout $testroot/stdout.expected
509 ret=$?
510 if [ $ret -ne 0 ]; then
511 diff -u $testroot/stdout.expected $testroot/stdout
513 test_done "$testroot" "$ret"
517 test_fetch_delete_branch_mirror() {
518 local testroot=`test_init fetch_delete_branch_mirror`
519 local testurl=ssh://127.0.0.1/$testroot
520 local commit_id=`git_show_head $testroot/repo`
522 got branch -r $testroot/repo -c $commit_id foo
523 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
524 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
525 local tag_id=`got ref -r $testroot/repo -l \
526 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
528 got clone -a -m -q $testurl/repo $testroot/repo-clone
529 ret=$?
530 if [ $ret -ne 0 ]; then
531 echo "got clone command failed unexpectedly" >&2
532 test_done "$testroot" "$ret"
533 return 1
536 got ref -l -r $testroot/repo-clone > $testroot/stdout
538 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
539 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
540 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
541 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
542 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
544 cmp -s $testroot/stdout $testroot/stdout.expected
545 ret=$?
546 if [ $ret -ne 0 ]; then
547 diff -u $testroot/stdout.expected $testroot/stdout
548 test_done "$testroot" "$ret"
549 return 1
552 got branch -r $testroot/repo -d foo >/dev/null
554 got fetch -q -r $testroot/repo-clone
555 ret=$?
556 if [ $ret -ne 0 ]; then
557 echo "got fetch command failed unexpectedly" >&2
558 test_done "$testroot" "$ret"
559 return 1
562 got ref -l -r $testroot/repo-clone > $testroot/stdout
564 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
565 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
566 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
567 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
568 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
570 cmp -s $testroot/stdout $testroot/stdout.expected
571 ret=$?
572 if [ $ret -ne 0 ]; then
573 diff -u $testroot/stdout.expected $testroot/stdout
574 test_done "$testroot" "$ret"
575 return 1
578 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
579 ret=$?
580 if [ $ret -ne 0 ]; then
581 echo "got fetch command failed unexpectedly" >&2
582 test_done "$testroot" "$ret"
583 return 1
586 echo -n > $testroot/stdout.expected
588 cmp -s $testroot/stdout $testroot/stdout.expected
589 ret=$?
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stdout.expected $testroot/stdout
592 test_done "$testroot" "$ret"
593 return 1
596 got ref -l -r $testroot/repo-clone > $testroot/stdout
598 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
599 # refs/heads/foo is now deleted
600 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
601 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
602 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
604 cmp -s $testroot/stdout $testroot/stdout.expected
605 ret=$?
606 if [ $ret -ne 0 ]; then
607 diff -u $testroot/stdout.expected $testroot/stdout
609 test_done "$testroot" "$ret"
613 test_fetch_update_tag() {
614 local testroot=`test_init fetch_update_tag`
615 local testurl=ssh://127.0.0.1/$testroot
616 local commit_id=`git_show_head $testroot/repo`
619 got branch -r $testroot/repo -c $commit_id foo
620 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
621 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
622 local tag_id=`got ref -r $testroot/repo -l \
623 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
625 got clone -a -q $testurl/repo $testroot/repo-clone
626 ret=$?
627 if [ $ret -ne 0 ]; then
628 echo "got clone command failed unexpectedly" >&2
629 test_done "$testroot" "$ret"
630 return 1
633 echo "modified alpha on master" > $testroot/repo/alpha
634 git_commit $testroot/repo -m "modified alpha"
635 local commit_id2=`git_show_head $testroot/repo`
637 got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
638 got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
639 local tag_id2=`got ref -r $testroot/repo -l \
640 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
642 got ref -l -r $testroot/repo-clone > $testroot/stdout
644 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
645 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
646 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
647 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
648 >> $testroot/stdout.expected
649 echo "refs/remotes/origin/foo: $commit_id" \
650 >> $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
657 ret=$?
658 if [ $ret -ne 0 ]; then
659 diff -u $testroot/stdout.expected $testroot/stdout
660 test_done "$testroot" "$ret"
661 return 1
664 got fetch -a -q -r $testroot/repo-clone
665 ret=$?
666 if [ $ret -ne 0 ]; then
667 echo "got fetch command failed unexpectedly" >&2
668 test_done "$testroot" "$ret"
669 return 1
672 got ref -l -r $testroot/repo-clone > $testroot/stdout
674 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
675 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
676 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
677 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
678 >> $testroot/stdout.expected
679 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
680 echo "refs/remotes/origin/master: $commit_id2" \
681 >> $testroot/stdout.expected
682 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
683 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
685 cmp -s $testroot/stdout $testroot/stdout.expected
686 ret=$?
687 if [ $ret -ne 0 ]; then
688 diff -u $testroot/stdout.expected $testroot/stdout
689 test_done "$testroot" "$ret"
690 return 1
693 got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
694 tail -n 1 > $testroot/stdout
695 ret=$?
696 if [ $ret -ne 0 ]; then
697 echo "got fetch command failed unexpectedly" >&2
698 test_done "$testroot" "$ret"
699 return 1
702 echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
703 > $testroot/stdout.expected
705 cmp -s $testroot/stdout $testroot/stdout.expected
706 ret=$?
707 if [ $ret -ne 0 ]; then
708 diff -u $testroot/stdout.expected $testroot/stdout
709 test_done "$testroot" "$ret"
710 return 1
713 got ref -l -r $testroot/repo-clone > $testroot/stdout
715 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
716 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
717 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
718 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
719 >> $testroot/stdout.expected
720 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
721 echo "refs/remotes/origin/master: $commit_id2" \
722 >> $testroot/stdout.expected
723 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
724 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
726 cmp -s $testroot/stdout $testroot/stdout.expected
727 ret=$?
728 if [ $ret -ne 0 ]; then
729 diff -u $testroot/stdout.expected $testroot/stdout
730 test_done "$testroot" "$ret"
731 return 1
734 got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
735 ret=$?
736 if [ $ret -ne 0 ]; then
737 echo "got fetch command failed unexpectedly" >&2
738 test_done "$testroot" "$ret"
739 return 1
742 echo -n > $testroot/stdout.expected
744 cmp -s $testroot/stdout $testroot/stdout.expected
745 ret=$?
746 if [ $ret -ne 0 ]; then
747 diff -u $testroot/stdout.expected $testroot/stdout
748 test_done "$testroot" "$ret"
749 return 1
752 got ref -l -r $testroot/repo-clone > $testroot/stdout
754 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
755 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
756 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
757 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
758 >> $testroot/stdout.expected
759 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
760 echo "refs/remotes/origin/master: $commit_id2" \
761 >> $testroot/stdout.expected
762 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
763 echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
765 cmp -s $testroot/stdout $testroot/stdout.expected
766 ret=$?
767 if [ $ret -ne 0 ]; then
768 diff -u $testroot/stdout.expected $testroot/stdout
770 test_done "$testroot" "$ret"
773 test_fetch_reference() {
774 local testroot=`test_init fetch_reference`
775 local testurl=ssh://127.0.0.1/$testroot
776 local commit_id=`git_show_head $testroot/repo`
778 got clone -q $testurl/repo $testroot/repo-clone
779 ret=$?
780 if [ $ret -ne 0 ]; then
781 echo "got clone command failed unexpectedly" >&2
782 test_done "$testroot" "$ret"
783 return 1
786 got branch -r $testroot/repo -c $commit_id foo
787 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
788 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
789 local tag_id=`got ref -r $testroot/repo -l \
790 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
792 echo "modified alpha on master" > $testroot/repo/alpha
793 git_commit $testroot/repo -m "modified alpha"
794 local commit_id2=`git_show_head $testroot/repo`
796 (cd $testroot/repo && git checkout -q foo)
797 echo "modified alpha on foo" > $testroot/repo/alpha
798 git_commit $testroot/repo -m "modified alpha"
799 local commit_id3=`git_show_head $testroot/repo`
800 (cd $testroot/repo && git checkout -q master)
802 got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
803 > $testroot/stdout 2> $testroot/stderr
804 ret=$?
805 if [ $ret -eq 0 ]; then
806 echo "got fetch command succeeded unexpectedly" >&2
807 test_done "$testroot" "1"
808 return 1
811 echo -n > $testroot/stdout.expected
813 cmp -s $testroot/stdout $testroot/stdout.expected
814 ret=$?
815 if [ $ret -ne 0 ]; then
816 diff -u $testroot/stdout.expected $testroot/stdout
817 test_done "$testroot" "$ret"
818 return 1
821 echo "got: refs/remotes/origin/main: reference cannot be fetched" \
822 > $testroot/stderr.expected
824 cmp -s $testroot/stderr $testroot/stderr.expected
825 ret=$?
826 if [ $ret -ne 0 ]; then
827 diff -u $testroot/stderr.expected $testroot/stderr
828 test_done "$testroot" "$ret"
829 return 1
832 got fetch -q -r $testroot/repo-clone -R refs/hoo
833 ret=$?
834 if [ $ret -ne 0 ]; then
835 echo "got fetch command failed unexpectedly" >&2
836 test_done "$testroot" "$ret"
837 return 1
840 got ref -l -r $testroot/repo-clone > $testroot/stdout
842 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
843 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
844 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
845 >> $testroot/stdout.expected
846 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
847 >> $testroot/stdout.expected
848 echo "refs/remotes/origin/master: $commit_id2" \
849 >> $testroot/stdout.expected
850 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
852 cmp -s $testroot/stdout $testroot/stdout.expected
853 ret=$?
854 if [ $ret -ne 0 ]; then
855 diff -u $testroot/stdout.expected $testroot/stdout
857 test_done "$testroot" "$ret"
861 test_fetch_replace_symref() {
862 local testroot=`test_init fetch_replace_symref`
863 local testurl=ssh://127.0.0.1/$testroot
864 local commit_id=`git_show_head $testroot/repo`
866 got clone -m -q $testurl/repo $testroot/repo-clone
867 ret=$?
868 if [ $ret -ne 0 ]; then
869 echo "got clone command failed unexpectedly" >&2
870 test_done "$testroot" "$ret"
871 return 1
874 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
875 got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
877 got ref -l -r $testroot/repo-clone > $testroot/stdout
879 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
880 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
881 echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
883 cmp -s $testroot/stdout $testroot/stdout.expected
884 ret=$?
885 if [ $ret -ne 0 ]; then
886 diff -u $testroot/stdout.expected $testroot/stdout
887 test_done "$testroot" "$ret"
888 return 1
891 got fetch -r $testroot/repo-clone -R refs/hoo \
892 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
893 ret=$?
894 if [ $ret -ne 0 ]; then
895 echo "got fetch command failed unexpectedly" >&2
896 test_done "$testroot" "$ret"
897 return 1
900 echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
901 > $testroot/stdout.expected
903 cmp -s $testroot/stdout $testroot/stdout.expected
904 ret=$?
905 if [ $ret -ne 0 ]; then
906 diff -u $testroot/stdout.expected $testroot/stdout
907 test_done "$testroot" "$ret"
908 return 1
911 got ref -l -r $testroot/repo-clone > $testroot/stdout
913 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
914 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
915 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
917 cmp -s $testroot/stdout $testroot/stdout.expected
918 ret=$?
919 if [ $ret -ne 0 ]; then
920 diff -u $testroot/stdout.expected $testroot/stdout
922 test_done "$testroot" "$ret"
926 test_fetch_update_headref() {
927 local testroot=`test_init fetch_update_headref`
928 local testurl=ssh://127.0.0.1/$testroot
929 local commit_id=`git_show_head $testroot/repo`
931 got clone -q $testurl/repo $testroot/repo-clone
932 ret=$?
933 if [ $ret -ne 0 ]; then
934 echo "got clone command failed unexpectedly" >&2
935 test_done "$testroot" "$ret"
936 return 1
939 got ref -l -r $testroot/repo-clone > $testroot/stdout
941 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
942 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
943 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
944 >> $testroot/stdout.expected
945 echo "refs/remotes/origin/master: $commit_id" \
946 >> $testroot/stdout.expected
948 cmp -s $testroot/stdout $testroot/stdout.expected
949 ret=$?
950 if [ $ret -ne 0 ]; then
951 diff -u $testroot/stdout.expected $testroot/stdout
952 test_done "$testroot" "$ret"
953 return 1
956 got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
957 got ref -r $testroot/repo -s refs/heads/foo HEAD
958 got ref -l -r $testroot/repo > $testroot/stdout
960 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
961 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
962 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
964 cmp -s $testroot/stdout $testroot/stdout.expected
965 ret=$?
966 if [ $ret -ne 0 ]; then
967 diff -u $testroot/stdout.expected $testroot/stdout
968 test_done "$testroot" "$ret"
969 return 1
972 got fetch -q -r $testroot/repo-clone
974 got ref -l -r $testroot/repo-clone > $testroot/stdout
976 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
977 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
978 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
979 >> $testroot/stdout.expected
980 echo "refs/remotes/origin/master: $commit_id" \
981 >> $testroot/stdout.expected
983 cmp -s $testroot/stdout $testroot/stdout.expected
984 ret=$?
985 if [ $ret -ne 0 ]; then
986 diff -u $testroot/stdout.expected $testroot/stdout
987 test_done "$testroot" "$ret"
988 return 1
991 got fetch -q -r $testroot/repo-clone -a
993 got ref -l -r $testroot/repo-clone > $testroot/stdout
995 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
996 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
997 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
998 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
999 >> $testroot/stdout.expected
1000 echo "refs/remotes/origin/foo: $commit_id" \
1001 >> $testroot/stdout.expected
1002 echo "refs/remotes/origin/master: $commit_id" \
1003 >> $testroot/stdout.expected
1005 cmp -s $testroot/stdout $testroot/stdout.expected
1006 ret=$?
1007 if [ $ret -ne 0 ]; then
1008 diff -u $testroot/stdout.expected $testroot/stdout
1010 test_done "$testroot" "$ret"
1013 test_fetch_headref_deleted_locally() {
1014 local testroot=`test_init fetch_headref_deleted_locally`
1015 local testurl=ssh://127.0.0.1/$testroot
1016 local commit_id=`git_show_head $testroot/repo`
1018 got clone -q $testurl/repo $testroot/repo-clone
1019 ret=$?
1020 if [ $ret -ne 0 ]; then
1021 echo "got clone command failed unexpectedly" >&2
1022 test_done "$testroot" "$ret"
1023 return 1
1026 got ref -l -r $testroot/repo-clone > $testroot/stdout
1028 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1029 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1030 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1031 >> $testroot/stdout.expected
1032 echo "refs/remotes/origin/master: $commit_id" \
1033 >> $testroot/stdout.expected
1035 cmp -s $testroot/stdout $testroot/stdout.expected
1036 ret=$?
1037 if [ $ret -ne 0 ]; then
1038 diff -u $testroot/stdout.expected $testroot/stdout
1039 test_done "$testroot" "$ret"
1040 return 1
1043 got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1045 got fetch -q -r $testroot/repo-clone
1046 ret=$?
1047 if [ $ret -ne 0 ]; then
1048 echo "got fetch command failed unexpectedly" >&2
1049 test_done "$testroot" "$ret"
1050 return 1
1052 got ref -l -r $testroot/repo-clone > $testroot/stdout
1054 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1055 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1056 # refs/remotes/origin/HEAD has been restored:
1057 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1058 >> $testroot/stdout.expected
1059 echo "refs/remotes/origin/master: $commit_id" \
1060 >> $testroot/stdout.expected
1062 cmp -s $testroot/stdout $testroot/stdout.expected
1063 ret=$?
1064 if [ $ret -ne 0 ]; then
1065 diff -u $testroot/stdout.expected $testroot/stdout
1067 test_done "$testroot" "$ret"
1070 test_fetch_gotconfig_remote_repo() {
1071 local testroot=`test_init fetch_gotconfig_remote_repo`
1072 local testurl=ssh://127.0.0.1/$testroot
1073 local commit_id=`git_show_head $testroot/repo`
1075 got branch -r $testroot/repo -c $commit_id foo
1076 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1077 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1079 got clone -q $testurl/repo $testroot/repo-clone
1080 ret=$?
1081 if [ $ret -ne 0 ]; then
1082 echo "got clone command failed unexpectedly" >&2
1083 test_done "$testroot" "$ret"
1084 return 1
1087 cat > $testroot/repo-clone/got.conf <<EOF
1088 remote "foobar" {
1089 protocol ssh
1090 server 127.0.0.1
1091 repository "$testroot/repo"
1094 remote "barbaz" {
1095 protocol ssh
1096 server 127.0.0.1
1097 repository "$testroot/does-not-exist"
1100 echo "got: nonexistent: remote repository not found" \
1101 > $testroot/stderr.expected
1102 (cd $testroot/repo-clone && got fetch -q nonexistent \
1103 > $testroot/stdout 2> $testroot/stderr)
1104 ret=$?
1105 if [ $ret -eq 0 ]; then
1106 echo "got fetch command succeeded unexpectedly" >&2
1107 diff -u $testroot/stderr.expected $testroot/stderr
1108 test_done "$testroot" "1"
1109 return 1
1112 (cd $testroot/repo-clone && got fetch -q -l foobar \
1113 > $testroot/stdout)
1114 ret=$?
1115 if [ $ret -ne 0 ]; then
1116 echo "got fetch command failed unexpectedly" >&2
1117 test_done "$testroot" "$ret"
1118 return 1
1121 got ref -l -r $testroot/repo > $testroot/stdout.expected
1123 cmp -s $testroot/stdout $testroot/stdout.expected
1124 ret=$?
1125 if [ $ret -ne 0 ]; then
1126 diff -u $testroot/stdout.expected $testroot/stdout
1127 test_done "$testroot" "$ret"
1128 return 1
1131 got checkout $testroot/repo $testroot/wt > /dev/null
1133 cat > $testroot/wt/.got/got.conf <<EOF
1134 remote "barbaz" {
1135 protocol ssh
1136 server 127.0.0.1
1137 repository "$testroot/repo"
1140 (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1141 ret=$?
1142 if [ $ret -ne 0 ]; then
1143 echo "got fetch command failed unexpectedly" >&2
1144 test_done "$testroot" "$ret"
1145 return 1
1148 got ref -l -r $testroot/repo > $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
1154 test_done "$testroot" "$ret"
1155 return 1
1158 cat > $testroot/repo-clone/got.conf <<EOF
1159 remote "origin" {
1160 protocol ssh
1161 server 127.0.0.1
1162 repository "$testroot/repo"
1163 branch { "foo" }
1164 reference { "hoo/boo/zoo" }
1167 (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1169 local tag_id=`got ref -r $testroot/repo -l \
1170 | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1171 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1172 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1173 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1174 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1175 >> $testroot/stdout.expected
1176 echo "refs/remotes/origin/foo: $commit_id" \
1177 >> $testroot/stdout.expected
1178 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1179 >> $testroot/stdout.expected
1180 echo "refs/remotes/origin/master: $commit_id" \
1181 >> $testroot/stdout.expected
1182 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1184 got ref -l -r $testroot/repo-clone > $testroot/stdout
1186 cmp -s $testroot/stdout $testroot/stdout.expected
1187 ret=$?
1188 if [ $ret -ne 0 ]; then
1189 diff -u $testroot/stdout.expected $testroot/stdout
1191 test_done "$testroot" "$ret"
1194 test_fetch_delete_remote_refs() {
1195 local testroot=`test_init fetch_delete_remote_refs`
1196 local testurl=ssh://127.0.0.1/$testroot
1197 local commit_id=`git_show_head $testroot/repo`
1199 got clone -q $testurl/repo $testroot/repo-clone
1200 ret=$?
1201 if [ $ret -ne 0 ]; then
1202 echo "got clone command failed unexpectedly" >&2
1203 test_done "$testroot" "$ret"
1204 return 1
1207 got ref -l -r $testroot/repo-clone > $testroot/stdout
1208 ret=$?
1209 if [ $ret -ne 0 ]; then
1210 echo "got ref command failed unexpectedly" >&2
1211 test_done "$testroot" "$ret"
1212 return 1
1215 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1216 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1217 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1218 >> $testroot/stdout.expected
1219 echo "refs/remotes/origin/master: $commit_id" \
1220 >> $testroot/stdout.expected
1222 cmp -s $testroot/stdout $testroot/stdout.expected
1223 ret=$?
1224 if [ $ret -ne 0 ]; then
1225 diff -u $testroot/stdout.expected $testroot/stdout
1226 test_done "$testroot" "$ret"
1227 return 1
1230 got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1231 2> $testroot/stderr
1232 ret=$?
1233 if [ $ret -eq 0 ]; then
1234 echo "got fetch command succeeded unexpectedly" >&2
1235 test_done "$testroot" "$ret"
1236 return 1
1239 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1240 cmp -s $testroot/stderr $testroot/stderr.expected
1241 ret=$?
1242 if [ $ret -ne 0 ]; then
1243 diff -u $testroot/stderr.expected $testroot/stderr
1244 test_done "$testroot" "$ret"
1245 return 1
1248 got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1249 2> $testroot/stderr
1250 ret=$?
1251 if [ $ret -ne 0 ]; then
1252 echo "got fetch command failed unexpectedly" >&2
1253 test_done "$testroot" "$ret"
1254 return 1
1257 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1258 echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1259 echo "Deleted refs/remotes/origin/master: $commit_id" \
1260 >> $testroot/stdout.expected
1262 cmp -s $testroot/stdout $testroot/stdout.expected
1263 ret=$?
1264 if [ $ret -ne 0 ]; then
1265 diff -u $testroot/stdout.expected $testroot/stdout
1266 test_done "$testroot" "$ret"
1267 return 1
1270 got ref -l -r $testroot/repo-clone > $testroot/stdout
1271 ret=$?
1272 if [ $ret -ne 0 ]; then
1273 echo "got ref command failed unexpectedly" >&2
1274 test_done "$testroot" "$ret"
1275 return 1
1278 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1279 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1281 cmp -s $testroot/stdout $testroot/stdout.expected
1282 ret=$?
1283 if [ $ret -ne 0 ]; then
1284 diff -u $testroot/stdout.expected $testroot/stdout
1286 test_done "$testroot" "$ret"
1290 test_parseargs "$@"
1291 run_test test_fetch_basic
1292 run_test test_fetch_list
1293 run_test test_fetch_branch
1294 run_test test_fetch_all
1295 run_test test_fetch_empty_packfile
1296 run_test test_fetch_delete_branch
1297 run_test test_fetch_delete_branch_mirror
1298 run_test test_fetch_update_tag
1299 run_test test_fetch_reference
1300 run_test test_fetch_replace_symref
1301 run_test test_fetch_update_headref
1302 run_test test_fetch_headref_deleted_locally
1303 run_test test_fetch_gotconfig_remote_repo
1304 run_test test_fetch_delete_remote_refs