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" != "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 if [ "$ret" != "0" ]; then
38 echo "got ref command failed unexpectedly" >&2
39 test_done "$testroot" "$ret"
40 return 1
41 fi
43 got fetch -q -r $testroot/repo-clone > $testroot/stdout \
44 2> $testroot/stderr
45 ret="$?"
46 if [ "$ret" != "0" ]; then
47 echo "got fetch command failed unexpectedly" >&2
48 test_done "$testroot" "$ret"
49 return 1
50 fi
52 echo -n > $testroot/stdout.expected
54 cmp -s $testroot/stdout $testroot/stdout.expected
55 ret="$?"
56 if [ "$ret" != "0" ]; then
57 diff -u $testroot/stdout.expected $testroot/stdout
58 test_done "$testroot" "$ret"
59 return 1
60 fi
62 got log -l0 -p -r $testroot/repo > $testroot/log-repo
63 if [ "$ret" != "0" ]; then
64 echo "got log command failed unexpectedly" >&2
65 test_done "$testroot" "$ret"
66 return 1
67 fi
68 got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
69 if [ "$ret" != "0" ]; then
70 echo "got log command failed unexpectedly" >&2
71 test_done "$testroot" "$ret"
72 return 1
73 fi
74 cmp -s $testroot/log-repo $testroot/log-repo-clone
75 ret="$?"
76 if [ "$ret" != "0" ]; then
77 echo "log -p output of cloned repository differs" >&2
78 test_done "$testroot" "$ret"
79 return 1
80 fi
82 got ref -l -r $testroot/repo > $testroot/stdout
83 if [ "$ret" != "0" ]; then
84 echo "got ref command failed unexpectedly" >&2
85 test_done "$testroot" "$ret"
86 return 1
87 fi
89 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
90 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
92 cmp -s $testroot/stdout $testroot/stdout.expected
93 ret="$?"
94 if [ "$ret" != "0" ]; then
95 diff -u $testroot/stdout.expected $testroot/stdout
96 test_done "$testroot" "$ret"
97 return 1
98 fi
100 got ref -l -r $testroot/repo-clone > $testroot/stdout
101 if [ "$ret" != "0" ]; then
102 echo "got ref command failed unexpectedly" >&2
103 test_done "$testroot" "$ret"
104 return 1
105 fi
107 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
108 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
109 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
110 >> $testroot/stdout.expected
111 echo "refs/remotes/origin/master: $commit_id2" \
112 >> $testroot/stdout.expected
114 cmp -s $testroot/stdout $testroot/stdout.expected
115 ret="$?"
116 if [ "$ret" != "0" ]; then
117 diff -u $testroot/stdout.expected $testroot/stdout
118 fi
119 test_done "$testroot" "$ret"
122 test_fetch_list() {
123 local testroot=`test_init fetch_list`
124 local testurl=ssh://127.0.0.1/$testroot
125 local commit_id=`git_show_head $testroot/repo`
127 got branch -r $testroot/repo -c $commit_id foo
128 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
129 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
131 got clone -q $testurl/repo $testroot/repo-clone
132 ret="$?"
133 if [ "$ret" != "0" ]; then
134 echo "got clone command failed unexpectedly" >&2
135 test_done "$testroot" "$ret"
136 return 1
137 fi
139 (cd $testroot/repo-clone && got fetch -q -l \
140 > $testroot/stdout 2>$testroot/stderr)
141 ret="$?"
142 if [ "$ret" != "0" ]; then
143 echo "got fetch command failed unexpectedly" >&2
144 test_done "$testroot" "$ret"
145 return 1
146 fi
148 got ref -l -r $testroot/repo > $testroot/stdout.expected
150 cmp -s $testroot/stdout $testroot/stdout.expected
151 ret="$?"
152 if [ "$ret" != "0" ]; then
153 diff -u $testroot/stdout.expected $testroot/stdout
154 fi
155 test_done "$testroot" "$ret"
158 test_fetch_branch() {
159 local testroot=`test_init fetch_branch`
160 local testurl=ssh://127.0.0.1/$testroot
161 local commit_id=`git_show_head $testroot/repo`
163 got clone -q $testurl/repo $testroot/repo-clone
164 ret="$?"
165 if [ "$ret" != "0" ]; then
166 echo "got clone command failed unexpectedly" >&2
167 test_done "$testroot" "$ret"
168 return 1
169 fi
171 got branch -r $testroot/repo -c $commit_id foo
172 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
173 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
174 local tag_id=`got ref -r $testroot/repo -l \
175 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
177 echo "modified alpha on master" > $testroot/repo/alpha
178 git_commit $testroot/repo -m "modified alpha"
179 local commit_id2=`git_show_head $testroot/repo`
181 (cd $testroot/repo && git checkout -q foo)
182 echo "modified alpha on foo" > $testroot/repo/alpha
183 git_commit $testroot/repo -m "modified alpha"
184 local commit_id3=`git_show_head $testroot/repo`
186 got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
187 ret="$?"
188 if [ "$ret" != "0" ]; then
189 echo "got fetch command failed unexpectedly" >&2
190 test_done "$testroot" "$ret"
191 return 1
192 fi
194 echo -n > $testroot/stdout.expected
196 cmp -s $testroot/stdout $testroot/stdout.expected
197 ret="$?"
198 if [ "$ret" != "0" ]; then
199 diff -u $testroot/stdout.expected $testroot/stdout
200 test_done "$testroot" "$ret"
201 return 1
202 fi
204 got ref -l -r $testroot/repo-clone > $testroot/stdout
206 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
207 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
208 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
209 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
210 >> $testroot/stdout.expected
211 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
212 # refs/remotes/origin/master is umodified because it wasn't fetched
213 echo "refs/remotes/origin/master: $commit_id" \
214 >> $testroot/stdout.expected
215 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
216 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
218 cmp -s $testroot/stdout $testroot/stdout.expected
219 ret="$?"
220 if [ "$ret" != "0" ]; then
221 diff -u $testroot/stdout.expected $testroot/stdout
222 test_done "$testroot" "$ret"
223 return 1
224 fi
226 got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
227 ret="$?"
228 if [ "$ret" != "0" ]; then
229 echo "got fetch command failed unexpectedly" >&2
230 test_done "$testroot" "$ret"
231 return 1
232 fi
234 echo -n > $testroot/stdout.expected
236 cmp -s $testroot/stdout $testroot/stdout.expected
237 ret="$?"
238 if [ "$ret" != "0" ]; then
239 diff -u $testroot/stdout.expected $testroot/stdout
240 test_done "$testroot" "$ret"
241 return 1
242 fi
244 got ref -l -r $testroot/repo-clone > $testroot/stdout
246 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
247 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
248 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
249 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
250 >> $testroot/stdout.expected
251 echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
252 echo "refs/remotes/origin/master: $commit_id2" \
253 >> $testroot/stdout.expected
254 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
255 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
257 cmp -s $testroot/stdout $testroot/stdout.expected
258 ret="$?"
259 if [ "$ret" != "0" ]; then
260 diff -u $testroot/stdout.expected $testroot/stdout
261 fi
262 test_done "$testroot" "$ret"
265 test_fetch_all() {
266 local testroot=`test_init fetch_all`
267 local testurl=ssh://127.0.0.1/$testroot
268 local commit_id=`git_show_head $testroot/repo`
270 got clone -q $testurl/repo $testroot/repo-clone
271 ret="$?"
272 if [ "$ret" != "0" ]; then
273 echo "got clone command failed unexpectedly" >&2
274 test_done "$testroot" "$ret"
275 return 1
276 fi
278 got branch -r $testroot/repo -c $commit_id foo
279 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
280 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
281 local tag_id=`got ref -r $testroot/repo -l \
282 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
284 got ref -l -r $testroot/repo-clone > $testroot/stdout
286 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
287 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
288 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
289 >> $testroot/stdout.expected
290 echo "refs/remotes/origin/master: $commit_id" \
291 >> $testroot/stdout.expected
292 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
294 cmp -s $testroot/stdout $testroot/stdout.expected
295 ret="$?"
296 if [ "$ret" != "0" ]; then
297 diff -u $testroot/stdout.expected $testroot/stdout
298 test_done "$testroot" "$ret"
299 return 1
300 fi
302 got fetch -q -a -r $testroot/repo-clone
303 ret="$?"
304 if [ "$ret" != "0" ]; then
305 echo "got fetch command failed unexpectedly" >&2
306 test_done "$testroot" "$ret"
307 return 1
308 fi
310 got ref -l -r $testroot/repo-clone > $testroot/stdout
312 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
313 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
314 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
315 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
316 >> $testroot/stdout.expected
317 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
318 echo "refs/remotes/origin/master: $commit_id" \
319 >> $testroot/stdout.expected
320 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
321 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
323 cmp -s $testroot/stdout $testroot/stdout.expected
324 ret="$?"
325 if [ "$ret" != "0" ]; then
326 diff -u $testroot/stdout.expected $testroot/stdout
327 fi
328 test_done "$testroot" "$ret"
331 test_fetch_empty_packfile() {
332 local testroot=`test_init fetch_empty_packfile`
333 local testurl=ssh://127.0.0.1/$testroot
334 local commit_id=`git_show_head $testroot/repo`
336 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
337 local tag_id=`got ref -r $testroot/repo -l \
338 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
340 got clone -q $testurl/repo $testroot/repo-clone
341 ret="$?"
342 if [ "$ret" != "0" ]; then
343 echo "got clone command failed unexpectedly" >&2
344 test_done "$testroot" "$ret"
345 return 1
346 fi
348 got branch -r $testroot/repo -c $commit_id foo
349 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
351 got ref -l -r $testroot/repo-clone > $testroot/stdout
353 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
354 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
355 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
356 >> $testroot/stdout.expected
357 echo "refs/remotes/origin/master: $commit_id" \
358 >> $testroot/stdout.expected
359 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
360 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
362 cmp -s $testroot/stdout $testroot/stdout.expected
363 ret="$?"
364 if [ "$ret" != "0" ]; then
365 diff -u $testroot/stdout.expected $testroot/stdout
366 test_done "$testroot" "$ret"
367 return 1
368 fi
370 got fetch -q -a -r $testroot/repo-clone
371 ret="$?"
372 if [ "$ret" != "0" ]; then
373 echo "got fetch command failed unexpectedly" >&2
374 test_done "$testroot" "$ret"
375 return 1
376 fi
378 got ref -l -r $testroot/repo-clone > $testroot/stdout
380 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
381 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
382 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
383 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
384 >> $testroot/stdout.expected
385 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
386 echo "refs/remotes/origin/master: $commit_id" \
387 >> $testroot/stdout.expected
388 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
389 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
391 cmp -s $testroot/stdout $testroot/stdout.expected
392 ret="$?"
393 if [ "$ret" != "0" ]; then
394 diff -u $testroot/stdout.expected $testroot/stdout
395 fi
396 test_done "$testroot" "$ret"
399 test_fetch_delete_branch() {
400 local testroot=`test_init fetch_delete_branch`
401 local testurl=ssh://127.0.0.1/$testroot
402 local commit_id=`git_show_head $testroot/repo`
405 got branch -r $testroot/repo -c $commit_id foo
406 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
407 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
408 local tag_id=`got ref -r $testroot/repo -l \
409 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
411 got clone -a -q $testurl/repo $testroot/repo-clone
412 ret="$?"
413 if [ "$ret" != "0" ]; then
414 echo "got clone command failed unexpectedly" >&2
415 test_done "$testroot" "$ret"
416 return 1
417 fi
419 got ref -l -r $testroot/repo-clone > $testroot/stdout
421 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
422 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
423 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
424 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
425 >> $testroot/stdout.expected
426 echo "refs/remotes/origin/foo: $commit_id" \
427 >> $testroot/stdout.expected
428 echo "refs/remotes/origin/master: $commit_id" \
429 >> $testroot/stdout.expected
430 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
431 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
433 cmp -s $testroot/stdout $testroot/stdout.expected
434 ret="$?"
435 if [ "$ret" != "0" ]; then
436 diff -u $testroot/stdout.expected $testroot/stdout
437 test_done "$testroot" "$ret"
438 return 1
439 fi
441 got branch -r $testroot/repo -d foo >/dev/null
443 got fetch -q -r $testroot/repo-clone
444 ret="$?"
445 if [ "$ret" != "0" ]; then
446 echo "got fetch command failed unexpectedly" >&2
447 test_done "$testroot" "$ret"
448 return 1
449 fi
451 got ref -l -r $testroot/repo-clone > $testroot/stdout
453 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
454 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
455 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
456 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
457 >> $testroot/stdout.expected
458 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
459 echo "refs/remotes/origin/master: $commit_id" \
460 >> $testroot/stdout.expected
461 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
462 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
464 cmp -s $testroot/stdout $testroot/stdout.expected
465 ret="$?"
466 if [ "$ret" != "0" ]; then
467 diff -u $testroot/stdout.expected $testroot/stdout
468 test_done "$testroot" "$ret"
469 return 1
470 fi
472 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
473 ret="$?"
474 if [ "$ret" != "0" ]; then
475 echo "got fetch command failed unexpectedly" >&2
476 test_done "$testroot" "$ret"
477 return 1
478 fi
480 echo -n > $testroot/stdout.expected
482 cmp -s $testroot/stdout $testroot/stdout.expected
483 ret="$?"
484 if [ "$ret" != "0" ]; then
485 diff -u $testroot/stdout.expected $testroot/stdout
486 test_done "$testroot" "$ret"
487 return 1
488 fi
490 got ref -l -r $testroot/repo-clone > $testroot/stdout
492 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
493 # refs/heads/foo is now deleted
494 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
495 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
496 >> $testroot/stdout.expected
497 # refs/remotes/origin/foo is now deleted
498 echo "refs/remotes/origin/master: $commit_id" \
499 >> $testroot/stdout.expected
500 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
501 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
503 cmp -s $testroot/stdout $testroot/stdout.expected
504 ret="$?"
505 if [ "$ret" != "0" ]; then
506 diff -u $testroot/stdout.expected $testroot/stdout
507 fi
508 test_done "$testroot" "$ret"
512 test_fetch_delete_branch_mirror() {
513 local testroot=`test_init fetch_delete_branch_mirror`
514 local testurl=ssh://127.0.0.1/$testroot
515 local commit_id=`git_show_head $testroot/repo`
517 got branch -r $testroot/repo -c $commit_id foo
518 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
519 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
520 local tag_id=`got ref -r $testroot/repo -l \
521 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
523 got clone -a -m -q $testurl/repo $testroot/repo-clone
524 ret="$?"
525 if [ "$ret" != "0" ]; then
526 echo "got clone command failed unexpectedly" >&2
527 test_done "$testroot" "$ret"
528 return 1
529 fi
531 got ref -l -r $testroot/repo-clone > $testroot/stdout
533 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
534 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
535 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
536 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
537 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
539 cmp -s $testroot/stdout $testroot/stdout.expected
540 ret="$?"
541 if [ "$ret" != "0" ]; then
542 diff -u $testroot/stdout.expected $testroot/stdout
543 test_done "$testroot" "$ret"
544 return 1
545 fi
547 got branch -r $testroot/repo -d foo >/dev/null
549 got fetch -q -r $testroot/repo-clone
550 ret="$?"
551 if [ "$ret" != "0" ]; then
552 echo "got fetch command failed unexpectedly" >&2
553 test_done "$testroot" "$ret"
554 return 1
555 fi
557 got ref -l -r $testroot/repo-clone > $testroot/stdout
559 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
560 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
561 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
562 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
563 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
565 cmp -s $testroot/stdout $testroot/stdout.expected
566 ret="$?"
567 if [ "$ret" != "0" ]; then
568 diff -u $testroot/stdout.expected $testroot/stdout
569 test_done "$testroot" "$ret"
570 return 1
571 fi
573 got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
574 ret="$?"
575 if [ "$ret" != "0" ]; then
576 echo "got fetch command failed unexpectedly" >&2
577 test_done "$testroot" "$ret"
578 return 1
579 fi
581 echo -n > $testroot/stdout.expected
583 cmp -s $testroot/stdout $testroot/stdout.expected
584 ret="$?"
585 if [ "$ret" != "0" ]; then
586 diff -u $testroot/stdout.expected $testroot/stdout
587 test_done "$testroot" "$ret"
588 return 1
589 fi
591 got ref -l -r $testroot/repo-clone > $testroot/stdout
593 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
594 # refs/heads/foo is now deleted
595 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
596 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
597 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
599 cmp -s $testroot/stdout $testroot/stdout.expected
600 ret="$?"
601 if [ "$ret" != "0" ]; then
602 diff -u $testroot/stdout.expected $testroot/stdout
603 fi
604 test_done "$testroot" "$ret"
608 test_fetch_update_tag() {
609 local testroot=`test_init fetch_update_tag`
610 local testurl=ssh://127.0.0.1/$testroot
611 local commit_id=`git_show_head $testroot/repo`
614 got branch -r $testroot/repo -c $commit_id foo
615 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
616 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
617 local tag_id=`got ref -r $testroot/repo -l \
618 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
620 got clone -a -q $testurl/repo $testroot/repo-clone
621 ret="$?"
622 if [ "$ret" != "0" ]; then
623 echo "got clone command failed unexpectedly" >&2
624 test_done "$testroot" "$ret"
625 return 1
626 fi
628 echo "modified alpha on master" > $testroot/repo/alpha
629 git_commit $testroot/repo -m "modified alpha"
630 local commit_id2=`git_show_head $testroot/repo`
632 got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
633 got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
634 local tag_id2=`got ref -r $testroot/repo -l \
635 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
637 got ref -l -r $testroot/repo-clone > $testroot/stdout
639 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
640 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
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 echo "refs/remotes/origin/foo: $commit_id" \
645 >> $testroot/stdout.expected
646 echo "refs/remotes/origin/master: $commit_id" \
647 >> $testroot/stdout.expected
648 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
649 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
651 cmp -s $testroot/stdout $testroot/stdout.expected
652 ret="$?"
653 if [ "$ret" != "0" ]; then
654 diff -u $testroot/stdout.expected $testroot/stdout
655 test_done "$testroot" "$ret"
656 return 1
657 fi
659 got fetch -a -q -r $testroot/repo-clone
660 ret="$?"
661 if [ "$ret" != "0" ]; then
662 echo "got fetch command failed unexpectedly" >&2
663 test_done "$testroot" "$ret"
664 return 1
665 fi
667 got ref -l -r $testroot/repo-clone > $testroot/stdout
669 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
670 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
671 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
672 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
673 >> $testroot/stdout.expected
674 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
675 echo "refs/remotes/origin/master: $commit_id2" \
676 >> $testroot/stdout.expected
677 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
678 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
680 cmp -s $testroot/stdout $testroot/stdout.expected
681 ret="$?"
682 if [ "$ret" != "0" ]; then
683 diff -u $testroot/stdout.expected $testroot/stdout
684 test_done "$testroot" "$ret"
685 return 1
686 fi
688 got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
689 tail -n 1 > $testroot/stdout
690 ret="$?"
691 if [ "$ret" != "0" ]; then
692 echo "got fetch command failed unexpectedly" >&2
693 test_done "$testroot" "$ret"
694 return 1
695 fi
697 echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
698 > $testroot/stdout.expected
700 cmp -s $testroot/stdout $testroot/stdout.expected
701 ret="$?"
702 if [ "$ret" != "0" ]; then
703 diff -u $testroot/stdout.expected $testroot/stdout
704 test_done "$testroot" "$ret"
705 return 1
706 fi
708 got ref -l -r $testroot/repo-clone > $testroot/stdout
710 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
711 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
712 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
713 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
714 >> $testroot/stdout.expected
715 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
716 echo "refs/remotes/origin/master: $commit_id2" \
717 >> $testroot/stdout.expected
718 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
719 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
721 cmp -s $testroot/stdout $testroot/stdout.expected
722 ret="$?"
723 if [ "$ret" != "0" ]; then
724 diff -u $testroot/stdout.expected $testroot/stdout
725 test_done "$testroot" "$ret"
726 return 1
727 fi
729 got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
730 ret="$?"
731 if [ "$ret" != "0" ]; then
732 echo "got fetch command failed unexpectedly" >&2
733 test_done "$testroot" "$ret"
734 return 1
735 fi
737 echo -n > $testroot/stdout.expected
739 cmp -s $testroot/stdout $testroot/stdout.expected
740 ret="$?"
741 if [ "$ret" != "0" ]; then
742 diff -u $testroot/stdout.expected $testroot/stdout
743 test_done "$testroot" "$ret"
744 return 1
745 fi
747 got ref -l -r $testroot/repo-clone > $testroot/stdout
749 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
750 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
751 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
752 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
753 >> $testroot/stdout.expected
754 echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
755 echo "refs/remotes/origin/master: $commit_id2" \
756 >> $testroot/stdout.expected
757 # refs/hoo/boo/zoo is missing because it is outside of refs/heads
758 echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
760 cmp -s $testroot/stdout $testroot/stdout.expected
761 ret="$?"
762 if [ "$ret" != "0" ]; then
763 diff -u $testroot/stdout.expected $testroot/stdout
764 fi
765 test_done "$testroot" "$ret"
768 test_fetch_reference() {
769 local testroot=`test_init fetch_reference`
770 local testurl=ssh://127.0.0.1/$testroot
771 local commit_id=`git_show_head $testroot/repo`
773 got clone -q $testurl/repo $testroot/repo-clone
774 ret="$?"
775 if [ "$ret" != "0" ]; then
776 echo "got clone command failed unexpectedly" >&2
777 test_done "$testroot" "$ret"
778 return 1
779 fi
781 got branch -r $testroot/repo -c $commit_id foo
782 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
783 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
784 local tag_id=`got ref -r $testroot/repo -l \
785 | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
787 echo "modified alpha on master" > $testroot/repo/alpha
788 git_commit $testroot/repo -m "modified alpha"
789 local commit_id2=`git_show_head $testroot/repo`
791 (cd $testroot/repo && git checkout -q foo)
792 echo "modified alpha on foo" > $testroot/repo/alpha
793 git_commit $testroot/repo -m "modified alpha"
794 local commit_id3=`git_show_head $testroot/repo`
795 (cd $testroot/repo && git checkout -q master)
797 got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
798 > $testroot/stdout 2> $testroot/stderr
799 ret="$?"
800 if [ "$ret" = "0" ]; then
801 echo "got fetch command succeeded unexpectedly" >&2
802 test_done "$testroot" "1"
803 return 1
804 fi
806 echo -n > $testroot/stdout.expected
808 cmp -s $testroot/stdout $testroot/stdout.expected
809 ret="$?"
810 if [ "$ret" != "0" ]; then
811 diff -u $testroot/stdout.expected $testroot/stdout
812 test_done "$testroot" "$ret"
813 return 1
814 fi
816 echo "got: refs/remotes/origin/main: reference cannot be fetched" \
817 > $testroot/stderr.expected
819 cmp -s $testroot/stderr $testroot/stderr.expected
820 ret="$?"
821 if [ "$ret" != "0" ]; then
822 diff -u $testroot/stderr.expected $testroot/stderr
823 test_done "$testroot" "$ret"
824 return 1
825 fi
827 got fetch -q -r $testroot/repo-clone -R refs/hoo
828 ret="$?"
829 if [ "$ret" != "0" ]; then
830 echo "got fetch command failed unexpectedly" >&2
831 test_done "$testroot" "$ret"
832 return 1
833 fi
835 got ref -l -r $testroot/repo-clone > $testroot/stdout
837 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
838 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
839 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
840 >> $testroot/stdout.expected
841 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
842 >> $testroot/stdout.expected
843 echo "refs/remotes/origin/master: $commit_id2" \
844 >> $testroot/stdout.expected
845 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
847 cmp -s $testroot/stdout $testroot/stdout.expected
848 ret="$?"
849 if [ "$ret" != "0" ]; then
850 diff -u $testroot/stdout.expected $testroot/stdout
851 fi
852 test_done "$testroot" "$ret"
856 test_fetch_replace_symref() {
857 local testroot=`test_init fetch_replace_symref`
858 local testurl=ssh://127.0.0.1/$testroot
859 local commit_id=`git_show_head $testroot/repo`
861 got clone -m -q $testurl/repo $testroot/repo-clone
862 ret="$?"
863 if [ "$ret" != "0" ]; then
864 echo "got clone command failed unexpectedly" >&2
865 test_done "$testroot" "$ret"
866 return 1
867 fi
869 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
870 got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
872 got ref -l -r $testroot/repo-clone > $testroot/stdout
874 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
875 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
876 echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
878 cmp -s $testroot/stdout $testroot/stdout.expected
879 ret="$?"
880 if [ "$ret" != "0" ]; then
881 diff -u $testroot/stdout.expected $testroot/stdout
882 test_done "$testroot" "$ret"
883 return 1
884 fi
886 got fetch -r $testroot/repo-clone -R refs/hoo \
887 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
888 ret="$?"
889 if [ "$ret" != "0" ]; then
890 echo "got fetch command failed unexpectedly" >&2
891 test_done "$testroot" "$ret"
892 return 1
893 fi
895 echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
896 > $testroot/stdout.expected
898 cmp -s $testroot/stdout $testroot/stdout.expected
899 ret="$?"
900 if [ "$ret" != "0" ]; then
901 diff -u $testroot/stdout.expected $testroot/stdout
902 test_done "$testroot" "$ret"
903 return 1
904 fi
906 got ref -l -r $testroot/repo-clone > $testroot/stdout
908 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
909 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
910 echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
912 cmp -s $testroot/stdout $testroot/stdout.expected
913 ret="$?"
914 if [ "$ret" != "0" ]; then
915 diff -u $testroot/stdout.expected $testroot/stdout
916 fi
917 test_done "$testroot" "$ret"
921 test_fetch_update_headref() {
922 local testroot=`test_init fetch_update_headref`
923 local testurl=ssh://127.0.0.1/$testroot
924 local commit_id=`git_show_head $testroot/repo`
926 got clone -q $testurl/repo $testroot/repo-clone
927 ret="$?"
928 if [ "$ret" != "0" ]; then
929 echo "got clone command failed unexpectedly" >&2
930 test_done "$testroot" "$ret"
931 return 1
932 fi
934 got ref -l -r $testroot/repo-clone > $testroot/stdout
936 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
937 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
938 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
939 >> $testroot/stdout.expected
940 echo "refs/remotes/origin/master: $commit_id" \
941 >> $testroot/stdout.expected
943 cmp -s $testroot/stdout $testroot/stdout.expected
944 ret="$?"
945 if [ "$ret" != "0" ]; then
946 diff -u $testroot/stdout.expected $testroot/stdout
947 test_done "$testroot" "$ret"
948 return 1
949 fi
951 got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
952 got ref -r $testroot/repo -s refs/heads/foo HEAD
953 got ref -l -r $testroot/repo > $testroot/stdout
955 echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
956 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
957 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
959 cmp -s $testroot/stdout $testroot/stdout.expected
960 ret="$?"
961 if [ "$ret" != "0" ]; then
962 diff -u $testroot/stdout.expected $testroot/stdout
963 test_done "$testroot" "$ret"
964 return 1
965 fi
967 got fetch -q -r $testroot/repo-clone
969 got ref -l -r $testroot/repo-clone > $testroot/stdout
971 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
972 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
973 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
974 >> $testroot/stdout.expected
975 echo "refs/remotes/origin/master: $commit_id" \
976 >> $testroot/stdout.expected
978 cmp -s $testroot/stdout $testroot/stdout.expected
979 ret="$?"
980 if [ "$ret" != "0" ]; then
981 diff -u $testroot/stdout.expected $testroot/stdout
982 test_done "$testroot" "$ret"
983 return 1
984 fi
986 got fetch -q -r $testroot/repo-clone -a
988 got ref -l -r $testroot/repo-clone > $testroot/stdout
990 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
991 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
992 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
993 echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
994 >> $testroot/stdout.expected
995 echo "refs/remotes/origin/foo: $commit_id" \
996 >> $testroot/stdout.expected
997 echo "refs/remotes/origin/master: $commit_id" \
998 >> $testroot/stdout.expected
1000 cmp -s $testroot/stdout $testroot/stdout.expected
1001 ret="$?"
1002 if [ "$ret" != "0" ]; then
1003 diff -u $testroot/stdout.expected $testroot/stdout
1005 test_done "$testroot" "$ret"
1008 test_fetch_headref_deleted_locally() {
1009 local testroot=`test_init fetch_headref_deleted_locally`
1010 local testurl=ssh://127.0.0.1/$testroot
1011 local commit_id=`git_show_head $testroot/repo`
1013 got clone -q $testurl/repo $testroot/repo-clone
1014 ret="$?"
1015 if [ "$ret" != "0" ]; then
1016 echo "got clone command failed unexpectedly" >&2
1017 test_done "$testroot" "$ret"
1018 return 1
1021 got ref -l -r $testroot/repo-clone > $testroot/stdout
1023 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1024 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1025 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1026 >> $testroot/stdout.expected
1027 echo "refs/remotes/origin/master: $commit_id" \
1028 >> $testroot/stdout.expected
1030 cmp -s $testroot/stdout $testroot/stdout.expected
1031 ret="$?"
1032 if [ "$ret" != "0" ]; then
1033 diff -u $testroot/stdout.expected $testroot/stdout
1034 test_done "$testroot" "$ret"
1035 return 1
1038 got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1040 got fetch -q -r $testroot/repo-clone
1041 ret="$?"
1042 if [ "$ret" != "0" ]; then
1043 echo "got fetch command failed unexpectedly" >&2
1044 test_done "$testroot" "$ret"
1045 return 1
1047 got ref -l -r $testroot/repo-clone > $testroot/stdout
1049 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1050 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1051 # refs/remotes/origin/HEAD has been restored:
1052 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1053 >> $testroot/stdout.expected
1054 echo "refs/remotes/origin/master: $commit_id" \
1055 >> $testroot/stdout.expected
1057 cmp -s $testroot/stdout $testroot/stdout.expected
1058 ret="$?"
1059 if [ "$ret" != "0" ]; then
1060 diff -u $testroot/stdout.expected $testroot/stdout
1062 test_done "$testroot" "$ret"
1065 test_fetch_gotconfig_remote_repo() {
1066 local testroot=`test_init fetch_gotconfig_remote_repo`
1067 local testurl=ssh://127.0.0.1/$testroot
1068 local commit_id=`git_show_head $testroot/repo`
1070 got branch -r $testroot/repo -c $commit_id foo
1071 got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1072 got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1074 got clone -q $testurl/repo $testroot/repo-clone
1075 ret="$?"
1076 if [ "$ret" != "0" ]; then
1077 echo "got clone command failed unexpectedly" >&2
1078 test_done "$testroot" "$ret"
1079 return 1
1082 cat > $testroot/repo-clone/got.conf <<EOF
1083 remote "foobar" {
1084 protocol ssh
1085 server 127.0.0.1
1086 repository "$testroot/repo"
1089 remote "barbaz" {
1090 protocol ssh
1091 server 127.0.0.1
1092 repository "$testroot/does-not-exist"
1094 EOF
1095 echo "got: nonexistent: remote repository not found" \
1096 > $testroot/stderr.expected
1097 (cd $testroot/repo-clone && got fetch -q nonexistent \
1098 > $testroot/stdout 2> $testroot/stderr)
1099 ret="$?"
1100 if [ "$ret" = "0" ]; then
1101 echo "got fetch command succeeded unexpectedly" >&2
1102 diff -u $testroot/stderr.expected $testroot/stderr
1103 test_done "$testroot" "1"
1104 return 1
1107 (cd $testroot/repo-clone && got fetch -q -l foobar \
1108 > $testroot/stdout)
1109 ret="$?"
1110 if [ "$ret" != "0" ]; then
1111 echo "got fetch command failed unexpectedly" >&2
1112 test_done "$testroot" "$ret"
1113 return 1
1116 got ref -l -r $testroot/repo > $testroot/stdout.expected
1118 cmp -s $testroot/stdout $testroot/stdout.expected
1119 ret="$?"
1120 if [ "$ret" != "0" ]; then
1121 diff -u $testroot/stdout.expected $testroot/stdout
1122 test_done "$testroot" "$ret"
1123 return 1
1126 got checkout $testroot/repo $testroot/wt > /dev/null
1128 cat > $testroot/wt/.got/got.conf <<EOF
1129 remote "barbaz" {
1130 protocol ssh
1131 server 127.0.0.1
1132 repository "$testroot/repo"
1134 EOF
1135 (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1136 ret="$?"
1137 if [ "$ret" != "0" ]; then
1138 echo "got fetch command failed unexpectedly" >&2
1139 test_done "$testroot" "$ret"
1140 return 1
1143 got ref -l -r $testroot/repo > $testroot/stdout.expected
1145 cmp -s $testroot/stdout $testroot/stdout.expected
1146 ret="$?"
1147 if [ "$ret" != "0" ]; then
1148 diff -u $testroot/stdout.expected $testroot/stdout
1149 test_done "$testroot" "$ret"
1150 return 1
1153 cat > $testroot/repo-clone/got.conf <<EOF
1154 remote "origin" {
1155 protocol ssh
1156 server 127.0.0.1
1157 repository "$testroot/repo"
1158 branch { "foo" }
1159 reference { "hoo/boo/zoo" }
1161 EOF
1162 (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1164 local tag_id=`got ref -r $testroot/repo -l \
1165 | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1166 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1167 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1168 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1169 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1170 >> $testroot/stdout.expected
1171 echo "refs/remotes/origin/foo: $commit_id" \
1172 >> $testroot/stdout.expected
1173 echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1174 >> $testroot/stdout.expected
1175 echo "refs/remotes/origin/master: $commit_id" \
1176 >> $testroot/stdout.expected
1177 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1179 got ref -l -r $testroot/repo-clone > $testroot/stdout
1181 cmp -s $testroot/stdout $testroot/stdout.expected
1182 ret="$?"
1183 if [ "$ret" != "0" ]; then
1184 diff -u $testroot/stdout.expected $testroot/stdout
1186 test_done "$testroot" "$ret"
1189 test_fetch_delete_remote_refs() {
1190 local testroot=`test_init fetch_delete_remote_refs`
1191 local testurl=ssh://127.0.0.1/$testroot
1192 local commit_id=`git_show_head $testroot/repo`
1194 got clone -q $testurl/repo $testroot/repo-clone
1195 ret="$?"
1196 if [ "$ret" != "0" ]; then
1197 echo "got clone command failed unexpectedly" >&2
1198 test_done "$testroot" "$ret"
1199 return 1
1202 got ref -l -r $testroot/repo-clone > $testroot/stdout
1203 if [ "$ret" != "0" ]; then
1204 echo "got ref command failed unexpectedly" >&2
1205 test_done "$testroot" "$ret"
1206 return 1
1209 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1210 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1211 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1212 >> $testroot/stdout.expected
1213 echo "refs/remotes/origin/master: $commit_id" \
1214 >> $testroot/stdout.expected
1216 cmp -s $testroot/stdout $testroot/stdout.expected
1217 ret="$?"
1218 if [ "$ret" != "0" ]; then
1219 diff -u $testroot/stdout.expected $testroot/stdout
1220 test_done "$testroot" "$ret"
1221 return 1
1224 got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1225 2> $testroot/stderr
1226 ret="$?"
1227 if [ "$ret" = "0" ]; then
1228 echo "got fetch command succeeded unexpectedly" >&2
1229 test_done "$testroot" "$ret"
1230 return 1
1233 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1234 cmp -s $testroot/stderr $testroot/stderr.expected
1235 ret="$?"
1236 if [ "$ret" != "0" ]; then
1237 diff -u $testroot/stderr.expected $testroot/stderr
1238 test_done "$testroot" "$ret"
1239 return 1
1242 got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1243 2> $testroot/stderr
1244 ret="$?"
1245 if [ "$ret" != "0" ]; then
1246 echo "got fetch command failed unexpectedly" >&2
1247 test_done "$testroot" "$ret"
1248 return 1
1251 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1252 echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1253 echo "Deleted refs/remotes/origin/master: $commit_id" \
1254 >> $testroot/stdout.expected
1256 cmp -s $testroot/stdout $testroot/stdout.expected
1257 ret="$?"
1258 if [ "$ret" != "0" ]; then
1259 diff -u $testroot/stdout.expected $testroot/stdout
1260 test_done "$testroot" "$ret"
1261 return 1
1264 got ref -l -r $testroot/repo-clone > $testroot/stdout
1265 if [ "$ret" != "0" ]; then
1266 echo "got ref command failed unexpectedly" >&2
1267 test_done "$testroot" "$ret"
1268 return 1
1271 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1272 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1274 cmp -s $testroot/stdout $testroot/stdout.expected
1275 ret="$?"
1276 if [ "$ret" != "0" ]; then
1277 diff -u $testroot/stdout.expected $testroot/stdout
1279 test_done "$testroot" "$ret"
1283 test_parseargs "$@"
1284 run_test test_fetch_basic
1285 run_test test_fetch_list
1286 run_test test_fetch_branch
1287 run_test test_fetch_all
1288 run_test test_fetch_empty_packfile
1289 run_test test_fetch_delete_branch
1290 run_test test_fetch_delete_branch_mirror
1291 run_test test_fetch_update_tag
1292 run_test test_fetch_reference
1293 run_test test_fetch_replace_symref
1294 run_test test_fetch_update_headref
1295 run_test test_fetch_headref_deleted_locally
1296 run_test test_fetch_gotconfig_remote_repo
1297 run_test test_fetch_delete_remote_refs