3 # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot=`test_init send_basic`
21 local testurl=ssh://127.0.0.1/$testroot
22 local commit_id=`git_show_head $testroot/repo`
24 got clone -q $testurl/repo $testroot/repo-clone
26 if [ $ret -ne 0 ]; then
27 echo "got clone command failed unexpectedly" >&2
28 test_done "$testroot" "$ret"
31 cat > $testroot/repo/.git/got.conf <<EOF
35 repository "$testroot/repo-clone"
38 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 | tr -d ' ' | cut -d: -f2`
42 echo "modified alpha" > $testroot/repo/alpha
43 (cd $testroot/repo && git rm -q beta)
44 (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
45 echo "new file alpha" > $testroot/repo/new
46 (cd $testroot/repo && git add new)
47 git_commit $testroot/repo -m "modified alpha"
48 local commit_id2=`git_show_head $testroot/repo`
50 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
52 if [ $ret -ne 0 ]; then
53 echo "got send command failed unexpectedly" >&2
54 test_done "$testroot" "$ret"
58 echo -n > $testroot/stdout.expected
59 cmp -s $testroot/stdout $testroot/stdout.expected
61 if [ $ret -ne 0 ]; then
62 diff -u $testroot/stdout.expected $testroot/stdout
63 test_done "$testroot" "$ret"
67 got ref -l -r $testroot/repo > $testroot/stdout
69 if [ $ret -ne 0 ]; then
70 echo "got ref command failed unexpectedly" >&2
71 test_done "$testroot" "$ret"
75 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
76 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
77 echo "refs/remotes/origin/master: $commit_id2" \
78 >> $testroot/stdout.expected
79 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
81 cmp -s $testroot/stdout $testroot/stdout.expected
83 if [ $ret -ne 0 ]; then
84 diff -u $testroot/stdout.expected $testroot/stdout
85 test_done "$testroot" "$ret"
89 got ref -l -r $testroot/repo-clone > $testroot/stdout
91 if [ $ret -ne 0 ]; then
92 echo "got ref command failed unexpectedly" >&2
93 test_done "$testroot" "$ret"
97 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
98 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
99 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
100 >> $testroot/stdout.expected
101 echo "refs/remotes/origin/master: $commit_id" \
102 >> $testroot/stdout.expected
104 cmp -s $testroot/stdout $testroot/stdout.expected
106 if [ $ret -ne 0 ]; then
107 diff -u $testroot/stdout.expected $testroot/stdout
108 test_done "$testroot" "$ret"
112 got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
114 got tree -r $testroot/repo -c $commit_id2 -i -R \
115 > $testroot/stdout.expected
116 cmp -s $testroot/stdout $testroot/stdout.expected
118 if [ $ret -ne 0 ]; then
119 diff -u $testroot/stdout.expected $testroot/stdout
120 test_done "$testroot" "$ret"
124 got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
126 if [ $ret -ne 0 ]; then
127 echo "got send command failed unexpectedly" >&2
128 test_done "$testroot" "$ret"
132 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
133 echo "Already up-to-date" >> $testroot/stdout.expected
134 cmp -s $testroot/stdout $testroot/stdout.expected
136 if [ $ret -ne 0 ]; then
137 diff -u $testroot/stdout.expected $testroot/stdout
138 test_done "$testroot" "$ret"
142 git_fsck "$testroot" "$testroot/repo-clone"
144 test_done "$testroot" "$ret"
147 test_send_rebase_required() {
148 local testroot=`test_init send_rebase_required`
149 local testurl=ssh://127.0.0.1/$testroot
150 local commit_id=`git_show_head $testroot/repo`
152 got clone -q $testurl/repo $testroot/repo-clone
154 if [ $ret -ne 0 ]; then
155 echo "got clone command failed unexpectedly" >&2
156 test_done "$testroot" "$ret"
159 cat > $testroot/repo/.git/got.conf <<EOF
163 repository "$testroot/repo-clone"
166 echo "modified alpha" > $testroot/repo/alpha
167 git_commit $testroot/repo -m "modified alpha"
168 local commit_id2=`git_show_head $testroot/repo`
170 got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
171 echo "modified alpha, too" > $testroot/wt-clone/alpha
172 (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
174 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
176 if [ $ret -eq 0 ]; then
177 echo "got send command succeeded unexpectedly" >&2
178 test_done "$testroot" 1
182 echo -n > $testroot/stdout.expected
183 cmp -s $testroot/stdout $testroot/stdout.expected
185 if [ $ret -ne 0 ]; then
186 diff -u $testroot/stdout.expected $testroot/stdout
187 test_done "$testroot" "$ret"
191 echo "got: refs/heads/master: fetch and rebase required" \
192 > $testroot/stderr.expected
193 cmp -s $testroot/stderr $testroot/stderr.expected
195 if [ $ret -ne 0 ]; then
196 diff -u $testroot/stderr.expected $testroot/stderr
197 test_done "$testroot" "$ret"
201 git_fsck "$testroot" "$testroot/repo-clone"
203 test_done "$testroot" "$ret"
206 test_send_rebase_required_overwrite() {
207 local testroot=`test_init send_rebase_required_overwrite`
208 local testurl=ssh://127.0.0.1/$testroot
209 local commit_id=`git_show_head $testroot/repo`
211 got clone -q $testurl/repo $testroot/repo-clone
213 if [ $ret -ne 0 ]; then
214 echo "got clone command failed unexpectedly" >&2
215 test_done "$testroot" "$ret"
218 cat > $testroot/repo/.git/got.conf <<EOF
222 repository "$testroot/repo-clone"
225 echo "modified alpha" > $testroot/repo/alpha
226 git_commit $testroot/repo -m "modified alpha"
227 local commit_id2=`git_show_head $testroot/repo`
229 got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
230 echo "modified alpha, too" > $testroot/wt-clone/alpha
231 (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
232 local commit_id3=`git_show_head $testroot/repo-clone`
234 # non-default remote requires an explicit argument
235 got send -q -r $testroot/repo -f > $testroot/stdout \
238 if [ $ret -eq 0 ]; then
239 echo "got send command succeeded unexpectedly" >&2
240 test_done "$testroot" 1
243 echo "got: origin: remote repository not found" \
244 > $testroot/stderr.expected
245 cmp -s $testroot/stderr $testroot/stderr.expected
247 if [ $ret -ne 0 ]; then
248 diff -u $testroot/stderr.expected $testroot/stderr
249 test_done "$testroot" "$ret"
253 got send -q -r $testroot/repo -f foobar > $testroot/stdout \
256 if [ $ret -ne 0 ]; then
257 echo "got send command failed unexpectedly" >&2
258 test_done "$testroot" "$ret"
262 echo -n > $testroot/stdout.expected
263 cmp -s $testroot/stdout $testroot/stdout.expected
265 if [ $ret -ne 0 ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
267 test_done "$testroot" "$ret"
271 got ref -l -r $testroot/repo > $testroot/stdout
273 if [ $ret -ne 0 ]; then
274 echo "got ref command failed unexpectedly" >&2
275 test_done "$testroot" "$ret"
279 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
280 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
281 echo "refs/remotes/foobar/master: $commit_id2" \
282 >> $testroot/stdout.expected
284 cmp -s $testroot/stdout $testroot/stdout.expected
286 if [ $ret -ne 0 ]; then
287 diff -u $testroot/stdout.expected $testroot/stdout
288 test_done "$testroot" "$ret"
292 got ref -l -r $testroot/repo-clone > $testroot/stdout
294 if [ $ret -ne 0 ]; then
295 echo "got ref command failed unexpectedly" >&2
296 test_done "$testroot" "$ret"
300 wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
301 cut -d ':' -f 2 | tr -d ' ')`
302 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
303 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
304 >> $testroot/stdout.expected
305 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
306 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
307 >> $testroot/stdout.expected
308 echo "refs/remotes/origin/master: $commit_id" \
309 >> $testroot/stdout.expected
311 cmp -s $testroot/stdout $testroot/stdout.expected
313 if [ $ret -ne 0 ]; then
314 diff -u $testroot/stdout.expected $testroot/stdout
315 test_done "$testroot" "$ret"
319 git_fsck "$testroot" "$testroot/repo-clone"
321 test_done "$testroot" "$ret"
325 local testroot=`test_init send_delete`
326 local testurl=ssh://127.0.0.1/$testroot
327 local commit_id=`git_show_head $testroot/repo`
329 # branch1 exists in both repositories
330 got branch -r $testroot/repo branch1
332 got clone -a -q $testurl/repo $testroot/repo-clone
334 if [ $ret -ne 0 ]; then
335 echo "got clone command failed unexpectedly" >&2
336 test_done "$testroot" "$ret"
339 cat > $testroot/repo/.git/got.conf <<EOF
343 repository "$testroot/repo-clone"
346 # branch2 exists only in the remote repository
347 got branch -r $testroot/repo-clone branch2
349 got ref -l -r $testroot/repo-clone > $testroot/stdout
351 if [ $ret -ne 0 ]; then
352 echo "got ref command failed unexpectedly" >&2
353 test_done "$testroot" "$ret"
357 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
358 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
359 echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
360 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
362 # Sending changes for a branch and deleting it at the same
363 # time is not allowed.
364 got send -q -r $testroot/repo -d branch1 -b branch1 \
365 > $testroot/stdout 2> $testroot/stderr
367 if [ $ret -eq 0 ]; then
368 echo "got send command succeeded unexpectedly" >&2
369 test_done "$testroot" 1
372 echo -n "got: changes on refs/heads/branch1 will be sent to server" \
373 > $testroot/stderr.expected
374 echo ": reference cannot be deleted" >> $testroot/stderr.expected
375 cmp -s $testroot/stderr $testroot/stderr.expected
377 if [ $ret -ne 0 ]; then
378 diff -u $testroot/stderr.expected $testroot/stderr
379 test_done "$testroot" "$ret"
383 got send -q -r $testroot/repo -d refs/heads/branch1 origin \
384 > $testroot/stdout 2> $testroot/stderr
386 if [ $ret -ne 0 ]; then
387 echo "got send command failed unexpectedly" >&2
388 test_done "$testroot" "$ret"
392 got send -r $testroot/repo -d refs/heads/branch2 origin \
393 > $testroot/stdout 2>$testroot/stderr
395 if [ $ret -ne 0 ]; then
396 echo "got send command failed unexpectedly" >&2
397 test_done "$testroot" "$ret"
401 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
402 echo "Server has deleted refs/heads/branch2" \
403 >> $testroot/stdout.expected
405 cmp -s $testroot/stdout $testroot/stdout.expected
407 if [ $ret -ne 0 ]; then
408 diff -u $testroot/stdout.expected $testroot/stdout
409 test_done "$testroot" "$ret"
413 # branchX exists in neither repository
414 got send -q -r $testroot/repo -d refs/heads/branchX origin \
415 > $testroot/stdout 2> $testroot/stderr
417 if [ $ret -eq 0 ]; then
418 echo "got send command succeeded unexpectedly" >&2
419 test_done "$testroot" 1
422 echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
423 > $testroot/stderr.expected
424 echo "repository: no such reference found" >> $testroot/stderr.expected
425 echo "got: no such reference found" >> $testroot/stderr.expected
426 cmp -s $testroot/stderr $testroot/stderr.expected
428 if [ $ret -ne 0 ]; then
429 diff -u $testroot/stderr.expected $testroot/stderr
430 test_done "$testroot" "$ret"
434 # References outside of refs/heads/ cannot be deleted with 'got send'.
435 got send -q -r $testroot/repo -d refs/tags/1.0 origin \
436 > $testroot/stdout 2> $testroot/stderr
438 if [ $ret -eq 0 ]; then
439 echo "got send command succeeded unexpectedly" >&2
440 test_done "$testroot" 1
443 echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
444 > $testroot/stderr.expected
445 echo "in remote repository: no such reference found" \
446 >> $testroot/stderr.expected
447 echo "got: no such reference found" >> $testroot/stderr.expected
448 cmp -s $testroot/stderr $testroot/stderr.expected
450 if [ $ret -ne 0 ]; then
451 diff -u $testroot/stderr.expected $testroot/stderr
452 test_done "$testroot" "$ret"
456 got ref -l -r $testroot/repo > $testroot/stdout
458 if [ $ret -ne 0 ]; then
459 echo "got ref command failed unexpectedly" >&2
460 test_done "$testroot" "$ret"
464 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
465 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
466 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
468 cmp -s $testroot/stdout $testroot/stdout.expected
470 if [ $ret -ne 0 ]; then
471 diff -u $testroot/stdout.expected $testroot/stdout
472 test_done "$testroot" "$ret"
476 got ref -l -r $testroot/repo-clone > $testroot/stdout
478 if [ $ret -ne 0 ]; then
479 echo "got ref command failed unexpectedly" >&2
480 test_done "$testroot" "$ret"
484 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
485 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
486 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
487 >> $testroot/stdout.expected
488 echo "refs/remotes/origin/branch1: $commit_id" \
489 >> $testroot/stdout.expected
490 echo "refs/remotes/origin/master: $commit_id" \
491 >> $testroot/stdout.expected
493 cmp -s $testroot/stdout $testroot/stdout.expected
495 if [ $ret -ne 0 ]; then
496 diff -u $testroot/stdout.expected $testroot/stdout
497 test_done "$testroot" "$ret"
501 git_fsck "$testroot" "$testroot/repo-clone"
503 test_done "$testroot" "$ret"
506 test_send_clone_and_send() {
507 local testroot=`test_init send_clone_and_send`
508 local testurl=ssh://127.0.0.1/$testroot
509 local commit_id=`git_show_head $testroot/repo`
511 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
513 got clone -q $testurl/repo $testroot/repo-clone
515 if [ $ret -ne 0 ]; then
516 echo "got clone command failed unexpectedly" >&2
517 test_done "$testroot" "$ret"
521 got checkout $testroot/repo-clone $testroot/wt >/dev/null
522 echo "modified alpha" > $testroot/wt/alpha
523 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
524 local commit_id2=`git_show_head $testroot/repo-clone`
526 (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
528 if [ $ret -ne 0 ]; then
529 echo "got send command failed unexpectedly" >&2
530 test_done "$testroot" "$ret"
534 echo -n > $testroot/stdout.expected
535 cmp -s $testroot/stdout $testroot/stdout.expected
537 if [ $ret -ne 0 ]; then
538 diff -u $testroot/stdout.expected $testroot/stdout
539 test_done "$testroot" "$ret"
543 got ref -l -r $testroot/repo > $testroot/stdout
545 if [ $ret -ne 0 ]; then
546 echo "got ref command failed unexpectedly" >&2
547 test_done "$testroot" "$ret"
551 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
552 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
554 cmp -s $testroot/stdout $testroot/stdout.expected
556 if [ $ret -ne 0 ]; then
557 diff -u $testroot/stdout.expected $testroot/stdout
558 test_done "$testroot" "$ret"
562 got ref -l -r $testroot/repo-clone > $testroot/stdout
564 if [ $ret -ne 0 ]; then
565 echo "got ref command failed unexpectedly" >&2
566 test_done "$testroot" "$ret"
570 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
571 cut -d ':' -f 2 | tr -d ' ')`
572 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
573 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
574 >> $testroot/stdout.expected
575 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
576 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
577 >> $testroot/stdout.expected
578 echo "refs/remotes/origin/master: $commit_id2" \
579 >> $testroot/stdout.expected
581 cmp -s $testroot/stdout $testroot/stdout.expected
583 if [ $ret -ne 0 ]; then
584 diff -u $testroot/stdout.expected $testroot/stdout
585 test_done "$testroot" "$ret"
589 git_fsck "$testroot" "$testroot/repo-clone"
591 test_done "$testroot" "$ret"
595 local testroot=`test_init send_tags`
596 local testurl=ssh://127.0.0.1/$testroot
597 local commit_id=`git_show_head $testroot/repo`
599 got clone -q $testurl/repo $testroot/repo-clone
601 if [ $ret -ne 0 ]; then
602 echo "got clone command failed unexpectedly" >&2
603 test_done "$testroot" "$ret"
606 cat > $testroot/repo/.git/got.conf <<EOF
610 repository "$testroot/repo-clone"
613 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
614 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
615 | tr -d ' ' | cut -d: -f2`
617 echo "modified alpha" > $testroot/repo/alpha
618 git_commit $testroot/repo -m "modified alpha"
619 local commit_id2=`git_show_head $testroot/repo`
621 got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
622 tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
623 | tr -d ' ' | cut -d: -f2`
625 got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
627 if [ $ret -ne 0 ]; then
628 echo "got send command failed unexpectedly" >&2
629 test_done "$testroot" "$ret"
633 echo -n > $testroot/stdout.expected
634 cmp -s $testroot/stdout $testroot/stdout.expected
636 if [ $ret -ne 0 ]; then
637 diff -u $testroot/stdout.expected $testroot/stdout
638 test_done "$testroot" "$ret"
642 got ref -l -r $testroot/repo > $testroot/stdout
644 if [ $ret -ne 0 ]; then
645 echo "got ref command failed unexpectedly" >&2
646 test_done "$testroot" "$ret"
650 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
651 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
652 echo "refs/remotes/origin/master: $commit_id2" \
653 >> $testroot/stdout.expected
654 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
655 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
657 cmp -s $testroot/stdout $testroot/stdout.expected
659 if [ $ret -ne 0 ]; then
660 diff -u $testroot/stdout.expected $testroot/stdout
661 test_done "$testroot" "$ret"
665 got ref -l -r $testroot/repo-clone > $testroot/stdout
667 if [ $ret -ne 0 ]; then
668 echo "got ref command failed unexpectedly" >&2
669 test_done "$testroot" "$ret"
673 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
674 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
675 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
676 >> $testroot/stdout.expected
677 echo "refs/remotes/origin/master: $commit_id" \
678 >> $testroot/stdout.expected
679 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
680 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
682 cmp -s $testroot/stdout $testroot/stdout.expected
684 if [ $ret -ne 0 ]; then
685 diff -u $testroot/stdout.expected $testroot/stdout
686 test_done "$testroot" "$ret"
690 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
691 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
692 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
693 cmp -s $testroot/stdout $testroot/stdout.expected
695 if [ $ret -ne 0 ]; then
696 diff -u $testroot/stdout.expected $testroot/stdout
697 test_done "$testroot" "$ret"
701 # Send the same tags again. This should be a no-op.
702 got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
704 if [ $ret -ne 0 ]; then
705 echo "got send command failed unexpectedly" >&2
706 test_done "$testroot" "$ret"
710 echo -n > $testroot/stdout.expected
711 cmp -s $testroot/stdout $testroot/stdout.expected
713 if [ $ret -ne 0 ]; then
714 diff -u $testroot/stdout.expected $testroot/stdout
715 test_done "$testroot" "$ret"
719 # Overwriting an existing tag 'got send -f'.
720 got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
721 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
722 tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
723 | tr -d ' ' | cut -d: -f2`
725 got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
728 if [ $ret -eq 0 ]; then
729 echo "got send command succeeded unexpectedly" >&2
730 test_done "$testroot" 1
734 echo "got: refs/tags/1.0: tag already exists on server" \
735 > $testroot/stderr.expected
736 cmp -s $testroot/stderr $testroot/stderr.expected
738 if [ $ret -ne 0 ]; then
739 diff -u $testroot/stderr.expected $testroot/stderr
740 test_done "$testroot" "$ret"
744 # attempting the same with -T should fail, too
745 got send -q -r $testroot/repo -T > $testroot/stdout \
748 if [ $ret -eq 0 ]; then
749 echo "got send command succeeded unexpectedly" >&2
750 test_done "$testroot" 1
754 echo "got: refs/tags/1.0: tag already exists on server" \
755 > $testroot/stderr.expected
756 cmp -s $testroot/stderr $testroot/stderr.expected
758 if [ $ret -ne 0 ]; then
759 diff -u $testroot/stderr.expected $testroot/stderr
760 test_done "$testroot" "$ret"
764 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
765 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
766 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
767 cmp -s $testroot/stdout $testroot/stdout.expected
769 if [ $ret -ne 0 ]; then
770 diff -u $testroot/stdout.expected $testroot/stdout
771 test_done "$testroot" "$ret"
775 # overwrite the 1.0 tag only
776 got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
779 if [ $ret -ne 0 ]; then
780 echo "got send command failed unexpectedly" >&2
781 test_done "$testroot" "$ret"
785 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
786 echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
787 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
788 cmp -s $testroot/stdout $testroot/stdout.expected
790 if [ $ret -ne 0 ]; then
791 diff -u $testroot/stdout.expected $testroot/stdout
792 test_done "$testroot" "$ret"
796 got checkout $testroot/repo $testroot/wt > /dev/null
797 echo 'new line in file alpha' >> $testroot/wt/alpha
798 (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
800 # Send the new commit in isolation.
801 got send -q -r $testroot/repo > $testroot/stdout \
804 if [ $ret -ne 0 ]; then
805 echo "got send command failed unexpectedly" >&2
806 test_done "$testroot" "$ret"
810 # Now tag it and send the tag.
811 # Verify that just the new tag object gets sent.
812 got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
813 tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
814 | tr -d ' ' | cut -d: -f2`
816 got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
819 if [ $ret -ne 0 ]; then
820 echo "got send command failed unexpectedly" >&2
821 test_done "$testroot" "$ret"
824 tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
825 if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
826 $testroot/stdout; then
827 echo "got send did apparently pack too many objects:" >&2
828 cat $testroot/stdout.raw >&2
829 test_done "$testroot" "1"
833 git_fsck "$testroot" "$testroot/repo-clone"
835 test_done "$testroot" "$ret"
838 test_send_tag_of_deleted_branch() {
839 local testroot=`test_init send_tag_of_deleted_branch`
840 local testurl=ssh://127.0.0.1/$testroot
841 local commit_id=`git_show_head $testroot/repo`
843 got clone -q $testurl/repo $testroot/repo-clone
845 if [ $ret -ne 0 ]; then
846 echo "got clone command failed unexpectedly" >&2
847 test_done "$testroot" "$ret"
850 cat > $testroot/repo/.git/got.conf <<EOF
854 repository "$testroot/repo-clone"
857 got branch -r $testroot/repo foo
859 # modify beta on branch foo
860 got checkout -b foo $testroot/repo $testroot/wt > /dev/null
861 echo boo >> $testroot/wt/beta
862 (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
864 echo buu >> $testroot/wt/beta
865 (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
867 echo baa >> $testroot/wt/beta
868 (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
870 local commit_id2=`git_show_branch_head $testroot/repo foo`
872 # tag HEAD commit of branch foo
873 got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
874 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
875 | tr -d ' ' | cut -d: -f2`
877 # delete the branch; commit is now only reachable via tags/1.0
878 got branch -r $testroot/repo -d foo > /dev/null
880 # unrelated change on master branch, then try sending this branch
882 echo "modified alpha" > $testroot/repo/alpha
883 git_commit $testroot/repo -m "modified alpha"
884 local commit_id3=`git_show_head $testroot/repo`
886 got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
888 if [ $ret -ne 0 ]; then
889 echo "got send command failed unexpectedly" >&2
890 test_done "$testroot" "$ret"
894 echo -n > $testroot/stdout.expected
895 cmp -s $testroot/stdout $testroot/stdout.expected
897 if [ $ret -ne 0 ]; then
898 diff -u $testroot/stdout.expected $testroot/stdout
899 test_done "$testroot" "$ret"
903 got ref -l -r $testroot/repo > $testroot/stdout
905 if [ $ret -ne 0 ]; then
906 echo "got ref command failed unexpectedly" >&2
907 test_done "$testroot" "$ret"
911 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
912 cut -d ':' -f 2 | tr -d ' ')`
913 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
914 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
915 >> $testroot/stdout.expected
916 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
917 echo "refs/remotes/origin/master: $commit_id3" \
918 >> $testroot/stdout.expected
919 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
921 cmp -s $testroot/stdout $testroot/stdout.expected
923 if [ $ret -ne 0 ]; then
924 diff -u $testroot/stdout.expected $testroot/stdout
925 test_done "$testroot" "$ret"
929 got ref -l -r $testroot/repo-clone > $testroot/stdout
931 if [ $ret -ne 0 ]; then
932 echo "got ref command failed unexpectedly" >&2
933 test_done "$testroot" "$ret"
937 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
938 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
939 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
940 >> $testroot/stdout.expected
941 echo "refs/remotes/origin/master: $commit_id" \
942 >> $testroot/stdout.expected
943 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
945 cmp -s $testroot/stdout $testroot/stdout.expected
947 if [ $ret -ne 0 ]; then
948 diff -u $testroot/stdout.expected $testroot/stdout
949 test_done "$testroot" "$ret"
953 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
954 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
956 cmp -s $testroot/stdout $testroot/stdout.expected
958 if [ $ret -ne 0 ]; then
959 diff -u $testroot/stdout.expected $testroot/stdout
960 test_done "$testroot" "$ret"
964 git_fsck "$testroot" "$testroot/repo-clone"
966 test_done "$testroot" "$ret"
969 test_send_new_branch() {
970 local testroot=`test_init send_new_branch`
971 local testurl=ssh://127.0.0.1/$testroot
972 local commit_id=`git_show_head $testroot/repo`
974 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
976 got clone -q $testurl/repo $testroot/repo-clone
978 if [ $ret -ne 0 ]; then
979 echo "got clone command failed unexpectedly" >&2
980 test_done "$testroot" "$ret"
984 got branch -r $testroot/repo-clone foo >/dev/null
985 got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
986 echo "modified alpha" > $testroot/wt/alpha
987 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
988 local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
990 (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
992 if [ $ret -ne 0 ]; then
993 echo "got send command failed unexpectedly" >&2
994 test_done "$testroot" "$ret"
998 echo -n > $testroot/stdout.expected
999 cmp -s $testroot/stdout $testroot/stdout.expected
1001 if [ $ret -ne 0 ]; then
1002 diff -u $testroot/stdout.expected $testroot/stdout
1003 test_done "$testroot" "$ret"
1007 got ref -l -r $testroot/repo > $testroot/stdout
1009 if [ $ret -ne 0 ]; then
1010 echo "got ref command failed unexpectedly" >&2
1011 test_done "$testroot" "$ret"
1015 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1016 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1017 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1019 cmp -s $testroot/stdout $testroot/stdout.expected
1021 if [ $ret -ne 0 ]; then
1022 diff -u $testroot/stdout.expected $testroot/stdout
1023 test_done "$testroot" "$ret"
1027 got ref -l -r $testroot/repo-clone > $testroot/stdout
1029 if [ $ret -ne 0 ]; then
1030 echo "got ref command failed unexpectedly" >&2
1031 test_done "$testroot" "$ret"
1035 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1036 cut -d ':' -f 2 | tr -d ' ')`
1037 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1038 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1039 >> $testroot/stdout.expected
1040 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1041 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1042 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1043 >> $testroot/stdout.expected
1044 echo "refs/remotes/origin/foo: $commit_id2" \
1045 >> $testroot/stdout.expected
1046 echo "refs/remotes/origin/master: $commit_id" \
1047 >> $testroot/stdout.expected
1049 cmp -s $testroot/stdout $testroot/stdout.expected
1051 if [ $ret -ne 0 ]; then
1052 diff -u $testroot/stdout.expected $testroot/stdout
1053 test_done "$testroot" "$ret"
1057 git_fsck "$testroot" "$testroot/repo-clone"
1059 test_done "$testroot" "$ret"
1062 test_send_all_branches() {
1063 local testroot=`test_init send_all_branches`
1064 local testurl=ssh://127.0.0.1/$testroot
1065 local commit_id=`git_show_head $testroot/repo`
1067 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1069 got clone -q $testurl/repo $testroot/repo-clone
1071 if [ $ret -ne 0 ]; then
1072 echo "got clone command failed unexpectedly" >&2
1073 test_done "$testroot" "$ret"
1077 got checkout $testroot/repo-clone $testroot/wt >/dev/null
1078 echo "modified alpha" > $testroot/wt/alpha
1079 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1080 local commit_id2=`git_show_head $testroot/repo-clone`
1082 got branch -r $testroot/repo-clone foo >/dev/null
1083 (cd $testroot/wt && got update -b foo >/dev/null)
1084 echo "modified beta on new branch foo" > $testroot/wt/beta
1085 (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1086 local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1088 got branch -r $testroot/repo-clone bar >/dev/null
1089 (cd $testroot/wt && got update -b bar >/dev/null)
1090 echo "modified beta again on new branch bar" > $testroot/wt/beta
1091 (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1092 local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1094 got ref -l -r $testroot/repo-clone > $testroot/stdout
1096 if [ $ret -ne 0 ]; then
1097 echo "got ref command failed unexpectedly" >&2
1098 test_done "$testroot" "$ret"
1102 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1103 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1104 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1105 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1107 got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1110 if [ $ret -eq 0 ]; then
1111 echo "got send command succeeded unexpectedly" >&2
1112 test_done "$testroot" 1
1115 echo "got: -a and -b options are mutually exclusive" \
1116 > $testroot/stderr.expected
1117 cmp -s $testroot/stderr $testroot/stderr.expected
1119 if [ $ret -ne 0 ]; then
1120 diff -u $testroot/stderr.expected $testroot/stderr
1121 test_done "$testroot" "$ret"
1125 got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1128 if [ $ret -ne 0 ]; then
1129 echo "got send command failed unexpectedly" >&2
1130 test_done "$testroot" "$ret"
1134 echo -n > $testroot/stdout.expected
1135 cmp -s $testroot/stdout $testroot/stdout.expected
1137 if [ $ret -ne 0 ]; then
1138 diff -u $testroot/stdout.expected $testroot/stdout
1139 test_done "$testroot" "$ret"
1143 got ref -l -r $testroot/repo > $testroot/stdout
1145 if [ $ret -ne 0 ]; then
1146 echo "got ref command failed unexpectedly" >&2
1147 test_done "$testroot" "$ret"
1151 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1152 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1153 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1154 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1156 cmp -s $testroot/stdout $testroot/stdout.expected
1158 if [ $ret -ne 0 ]; then
1159 diff -u $testroot/stdout.expected $testroot/stdout
1160 test_done "$testroot" "$ret"
1164 got ref -l -r $testroot/repo-clone > $testroot/stdout
1166 if [ $ret -ne 0 ]; then
1167 echo "got ref command failed unexpectedly" >&2
1168 test_done "$testroot" "$ret"
1172 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1173 cut -d ':' -f 2 | tr -d ' ')`
1174 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1175 echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1176 >> $testroot/stdout.expected
1177 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1178 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1179 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1180 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1181 >> $testroot/stdout.expected
1182 echo "refs/remotes/origin/bar: $commit_id4" \
1183 >> $testroot/stdout.expected
1184 echo "refs/remotes/origin/foo: $commit_id3" \
1185 >> $testroot/stdout.expected
1186 echo "refs/remotes/origin/master: $commit_id2" \
1187 >> $testroot/stdout.expected
1189 cmp -s $testroot/stdout $testroot/stdout.expected
1191 if [ $ret -ne 0 ]; then
1192 diff -u $testroot/stdout.expected $testroot/stdout
1193 test_done "$testroot" "$ret"
1197 git_fsck "$testroot" "$testroot/repo-clone"
1199 test_done "$testroot" "$ret"
1202 test_send_to_empty_repo() {
1203 local testroot=`test_init send_to_empty_repo`
1204 local testurl=ssh://127.0.0.1/$testroot
1205 local commit_id=`git_show_head $testroot/repo`
1207 gotadmin init $testroot/repo2
1210 if [ $ret -ne 0 ]; then
1211 echo "got clone command failed unexpectedly" >&2
1212 test_done "$testroot" "$ret"
1215 cat > $testroot/repo/.git/got.conf <<EOF
1219 repository "$testroot/repo2"
1222 echo "modified alpha" > $testroot/repo/alpha
1223 git_commit $testroot/repo -m "modified alpha"
1224 local commit_id2=`git_show_head $testroot/repo`
1226 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1228 if [ $ret -ne 0 ]; then
1229 echo "got send command failed unexpectedly" >&2
1230 test_done "$testroot" "$ret"
1234 echo -n > $testroot/stdout.expected
1235 cmp -s $testroot/stdout $testroot/stdout.expected
1237 if [ $ret -ne 0 ]; then
1238 diff -u $testroot/stdout.expected $testroot/stdout
1239 test_done "$testroot" "$ret"
1243 # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1244 got ref -r $testroot/repo2 -s refs/heads/master HEAD
1246 got ref -l -r $testroot/repo > $testroot/stdout
1248 if [ $ret -ne 0 ]; then
1249 echo "got ref command failed unexpectedly" >&2
1250 test_done "$testroot" "$ret"
1254 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1255 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1256 echo "refs/remotes/origin/master: $commit_id2" \
1257 >> $testroot/stdout.expected
1259 cmp -s $testroot/stdout $testroot/stdout.expected
1261 if [ $ret -ne 0 ]; then
1262 diff -u $testroot/stdout.expected $testroot/stdout
1263 test_done "$testroot" "$ret"
1267 got ref -l -r $testroot/repo2 > $testroot/stdout
1269 if [ $ret -ne 0 ]; then
1270 echo "got ref command failed unexpectedly" >&2
1271 test_done "$testroot" "$ret"
1275 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1276 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1278 cmp -s $testroot/stdout $testroot/stdout.expected
1280 if [ $ret -ne 0 ]; then
1281 diff -u $testroot/stdout.expected $testroot/stdout
1282 test_done "$testroot" "$ret"
1286 got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1288 if [ $ret -ne 0 ]; then
1289 echo "got send command failed unexpectedly" >&2
1290 test_done "$testroot" "$ret"
1294 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1295 echo "Already up-to-date" >> $testroot/stdout.expected
1296 cmp -s $testroot/stdout $testroot/stdout.expected
1298 if [ $ret -ne 0 ]; then
1299 diff -u $testroot/stdout.expected $testroot/stdout
1300 test_done "$testroot" "$ret"
1304 git_fsck "$testroot" "$testroot/repo2"
1306 test_done "$testroot" "$ret"
1309 test_send_and_fetch_config() {
1310 local testroot=`test_init send_fetch_conf`
1311 local testurl=ssh://127.0.0.1/$testroot
1312 local commit_id=`git_show_head $testroot/repo`
1314 got clone -q $testurl/repo $testroot/repo-clone
1316 if [ $ret -ne 0 ]; then
1317 echo "got clone command failed unexpectedly" >&2
1318 test_done "$testroot" "$ret"
1322 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1323 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1324 | tr -d ' ' | cut -d: -f2`
1326 cp -R $testroot/repo-clone $testroot/repo-clone2
1327 got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1328 tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1329 | tr -d ' ' | cut -d: -f2`
1331 cat > $testroot/repo/.git/got.conf <<EOF
1336 repository "$testroot/repo-clone"
1339 repository "$testroot/repo-clone2"
1343 got ref -l -r $testroot/repo > $testroot/stdout
1345 if [ $ret -ne 0 ]; then
1346 echo "got ref command failed unexpectedly" >&2
1347 test_done "$testroot" "$ret"
1351 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1352 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1353 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1354 cmp -s $testroot/stdout $testroot/stdout.expected
1356 if [ $ret -ne 0 ]; then
1357 diff -u $testroot/stdout.expected $testroot/stdout
1358 test_done "$testroot" "$ret"
1362 # fetch tag 2.0 from repo-clone2
1363 got fetch -q -r $testroot/repo > $testroot/stdout
1365 if [ $ret -ne 0 ]; then
1366 echo "got fetch command failed unexpectedly" >&2
1367 test_done "$testroot" "$ret"
1371 got ref -l -r $testroot/repo > $testroot/stdout
1373 if [ $ret -ne 0 ]; then
1374 echo "got ref command failed unexpectedly" >&2
1375 test_done "$testroot" "$ret"
1379 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1380 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1381 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1382 >> $testroot/stdout.expected
1383 echo "refs/remotes/origin/master: $commit_id" \
1384 >> $testroot/stdout.expected
1385 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1386 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1387 cmp -s $testroot/stdout $testroot/stdout.expected
1389 if [ $ret -ne 0 ]; then
1390 diff -u $testroot/stdout.expected $testroot/stdout
1391 test_done "$testroot" "$ret"
1395 # send tag 1.0 to repo-clone
1396 got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1398 if [ $ret -ne 0 ]; then
1399 echo "got send command failed unexpectedly" >&2
1400 test_done "$testroot" "$ret"
1404 got ref -l -r $testroot/repo-clone > $testroot/stdout
1406 if [ $ret -ne 0 ]; then
1407 echo "got ref command failed unexpectedly" >&2
1408 test_done "$testroot" "$ret"
1412 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1413 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1414 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1415 >> $testroot/stdout.expected
1416 echo "refs/remotes/origin/master: $commit_id" \
1417 >> $testroot/stdout.expected
1418 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1420 cmp -s $testroot/stdout $testroot/stdout.expected
1422 if [ $ret -ne 0 ]; then
1423 diff -u $testroot/stdout.expected $testroot/stdout
1424 test_done "$testroot" "$ret"
1428 git_fsck "$testroot" "$testroot/repo-clone"
1430 test_done "$testroot" "$ret"
1433 test_send_config() {
1434 local testroot=`test_init send_fetch_conf`
1435 local testurl=ssh://127.0.0.1/$testroot
1436 local commit_id=`git_show_head $testroot/repo`
1438 got clone -q $testurl/repo $testroot/repo-clone
1440 if [ $ret -ne 0 ]; then
1441 echo "got clone command failed unexpectedly" >&2
1442 test_done "$testroot" "$ret"
1446 cat > $testroot/repo/.git/got.conf <<EOF
1451 repository "$testroot/repo-clone"
1454 got ref -l -r $testroot/repo-clone > $testroot/stdout
1456 if [ $ret -ne 0 ]; then
1457 echo "got ref command failed unexpectedly" >&2
1458 test_done "$testroot" "$ret"
1462 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1463 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1464 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1465 >> $testroot/stdout.expected
1466 echo "refs/remotes/origin/master: $commit_id" \
1467 >> $testroot/stdout.expected
1469 cmp -s $testroot/stdout $testroot/stdout.expected
1471 if [ $ret -ne 0 ]; then
1472 diff -u $testroot/stdout.expected $testroot/stdout
1473 test_done "$testroot" "$ret"
1477 got branch -r $testroot/repo foo
1479 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1481 if [ $ret -ne 0 ]; then
1482 echo "got send command failed unexpectedly" >&2
1483 test_done "$testroot" "$ret"
1487 got ref -l -r $testroot/repo-clone > $testroot/stdout
1489 if [ $ret -ne 0 ]; then
1490 echo "got ref command failed unexpectedly" >&2
1491 test_done "$testroot" "$ret"
1495 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1496 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1497 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1498 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1499 >> $testroot/stdout.expected
1500 echo "refs/remotes/origin/master: $commit_id" \
1501 >> $testroot/stdout.expected
1503 cmp -s $testroot/stdout $testroot/stdout.expected
1505 if [ $ret -ne 0 ]; then
1506 diff -u $testroot/stdout.expected $testroot/stdout
1507 test_done "$testroot" "$ret"
1511 git_fsck "$testroot" "$testroot/repo-clone"
1513 test_done "$testroot" "$ret"
1517 run_test test_send_basic
1518 run_test test_send_rebase_required
1519 run_test test_send_rebase_required_overwrite
1520 run_test test_send_delete
1521 run_test test_send_clone_and_send
1522 run_test test_send_tags
1523 run_test test_send_tag_of_deleted_branch
1524 run_test test_send_new_branch
1525 run_test test_send_all_branches
1526 run_test test_send_to_empty_repo
1527 run_test test_send_and_fetch_config
1528 run_test test_send_config