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\" ssh://127.0.0.1$testroot/repo-clone" \
133 > $testroot/stdout.expected
134 echo "Already up-to-date" >> $testroot/stdout.expected
135 cmp -s $testroot/stdout
$testroot/stdout.expected
137 if [ $ret -ne 0 ]; then
138 diff -u $testroot/stdout.expected
$testroot/stdout
139 test_done
"$testroot" "$ret"
143 git_fsck
"$testroot" "$testroot/repo-clone"
145 test_done
"$testroot" "$ret"
148 test_send_rebase_required
() {
149 local testroot
=`test_init send_rebase_required`
150 local testurl
=ssh://127.0.0.1/$testroot
151 local commit_id
=`git_show_head $testroot/repo`
153 got clone
-q $testurl/repo
$testroot/repo-clone
155 if [ $ret -ne 0 ]; then
156 echo "got clone command failed unexpectedly" >&2
157 test_done
"$testroot" "$ret"
160 cat > $testroot/repo
/.git
/got.conf
<<EOF
164 repository "$testroot/repo-clone"
167 echo "modified alpha" > $testroot/repo
/alpha
168 git_commit
$testroot/repo
-m "modified alpha"
169 local commit_id2
=`git_show_head $testroot/repo`
171 got checkout
$testroot/repo-clone
$testroot/wt-clone
>/dev
/null
172 echo "modified alpha, too" > $testroot/wt-clone
/alpha
173 (cd $testroot/wt-clone
&& got commit
-m 'change alpha' >/dev
/null
)
175 got send
-q -r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
177 if [ $ret -eq 0 ]; then
178 echo "got send command succeeded unexpectedly" >&2
179 test_done
"$testroot" 1
183 echo -n > $testroot/stdout.expected
184 cmp -s $testroot/stdout
$testroot/stdout.expected
186 if [ $ret -ne 0 ]; then
187 diff -u $testroot/stdout.expected
$testroot/stdout
188 test_done
"$testroot" "$ret"
192 echo "got: refs/heads/master: fetch and rebase required" \
193 > $testroot/stderr.expected
194 cmp -s $testroot/stderr
$testroot/stderr.expected
196 if [ $ret -ne 0 ]; then
197 diff -u $testroot/stderr.expected
$testroot/stderr
198 test_done
"$testroot" "$ret"
202 git_fsck
"$testroot" "$testroot/repo-clone"
204 test_done
"$testroot" "$ret"
207 test_send_rebase_required_overwrite
() {
208 local testroot
=`test_init send_rebase_required_overwrite`
209 local testurl
=ssh://127.0.0.1/$testroot
210 local commit_id
=`git_show_head $testroot/repo`
212 got clone
-q $testurl/repo
$testroot/repo-clone
214 if [ $ret -ne 0 ]; then
215 echo "got clone command failed unexpectedly" >&2
216 test_done
"$testroot" "$ret"
219 cat > $testroot/repo
/.git
/got.conf
<<EOF
223 repository "$testroot/repo-clone"
226 echo "modified alpha" > $testroot/repo
/alpha
227 git_commit
$testroot/repo
-m "modified alpha"
228 local commit_id2
=`git_show_head $testroot/repo`
230 got checkout
$testroot/repo-clone
$testroot/wt-clone
>/dev
/null
231 echo "modified alpha, too" > $testroot/wt-clone
/alpha
232 (cd $testroot/wt-clone
&& got commit
-m 'change alpha' >/dev
/null
)
233 local commit_id3
=`git_show_head $testroot/repo-clone`
235 # non-default remote requires an explicit argument
236 got send
-q -r $testroot/repo
-f > $testroot/stdout \
239 if [ $ret -eq 0 ]; then
240 echo "got send command succeeded unexpectedly" >&2
241 test_done
"$testroot" 1
244 echo "got: origin: remote repository not found" \
245 > $testroot/stderr.expected
246 cmp -s $testroot/stderr
$testroot/stderr.expected
248 if [ $ret -ne 0 ]; then
249 diff -u $testroot/stderr.expected
$testroot/stderr
250 test_done
"$testroot" "$ret"
254 got send
-q -r $testroot/repo
-f foobar
> $testroot/stdout \
257 if [ $ret -ne 0 ]; then
258 echo "got send command failed unexpectedly" >&2
259 test_done
"$testroot" "$ret"
263 echo -n > $testroot/stdout.expected
264 cmp -s $testroot/stdout
$testroot/stdout.expected
266 if [ $ret -ne 0 ]; then
267 diff -u $testroot/stdout.expected
$testroot/stdout
268 test_done
"$testroot" "$ret"
272 got ref
-l -r $testroot/repo
> $testroot/stdout
274 if [ $ret -ne 0 ]; then
275 echo "got ref command failed unexpectedly" >&2
276 test_done
"$testroot" "$ret"
280 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
281 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
282 echo "refs/remotes/foobar/master: $commit_id2" \
283 >> $testroot/stdout.expected
285 cmp -s $testroot/stdout
$testroot/stdout.expected
287 if [ $ret -ne 0 ]; then
288 diff -u $testroot/stdout.expected
$testroot/stdout
289 test_done
"$testroot" "$ret"
293 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
295 if [ $ret -ne 0 ]; then
296 echo "got ref command failed unexpectedly" >&2
297 test_done
"$testroot" "$ret"
301 wt_uuid
=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
302 cut -d ':' -f 2 | tr -d ' ')`
303 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
304 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
305 >> $testroot/stdout.expected
306 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
307 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
308 >> $testroot/stdout.expected
309 echo "refs/remotes/origin/master: $commit_id" \
310 >> $testroot/stdout.expected
312 cmp -s $testroot/stdout
$testroot/stdout.expected
314 if [ $ret -ne 0 ]; then
315 diff -u $testroot/stdout.expected
$testroot/stdout
316 test_done
"$testroot" "$ret"
320 git_fsck
"$testroot" "$testroot/repo-clone"
322 test_done
"$testroot" "$ret"
325 test_send_merge_commit
() {
326 local testroot
=`test_init send_merge_commit`
327 local testurl
=ssh://127.0.0.1/$testroot
329 if ! got clone
-q "$testurl/repo" "$testroot/repo-clone"; then
330 echo "got clone command failed unexpectedly" >&2
331 test_done
"$testroot" 1
335 echo 'upstream change' > $testroot/repo
/alpha
336 git_commit
$testroot/repo
-m 'upstream change'
338 got checkout
$testroot/repo-clone
$testroot/wt-clone
> /dev
/null
339 echo 'downstream change' > $testroot/wt-clone
/beta
340 (cd $testroot/wt-clone
&& got commit
-m 'downstream change' > /dev
/null
)
342 got fetch
-q -r $testroot/repo-clone
343 (cd $testroot/wt-clone
&& got update
> /dev
/null
)
344 (cd $testroot/wt-clone
&& got merge origin
/master
> /dev
/null
)
346 if [ $ret -ne 0 ]; then
347 echo "got merge command failed unexpectedly" >&2
348 test_done
"$testroot" "$ret"
352 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
354 got send
-q -r $testroot/repo-clone
356 if [ $ret -ne 0 ]; then
357 test_done
"$testroot" "$ret"
361 test_done
"$testroot" 0
365 local testroot
=`test_init send_delete`
366 local testurl
=ssh://127.0.0.1/$testroot
367 local commit_id
=`git_show_head $testroot/repo`
369 # branch1 exists in both repositories
370 got branch
-r $testroot/repo branch1
372 got clone
-a -q $testurl/repo
$testroot/repo-clone
374 if [ $ret -ne 0 ]; then
375 echo "got clone command failed unexpectedly" >&2
376 test_done
"$testroot" "$ret"
379 cat > $testroot/repo
/.git
/got.conf
<<EOF
383 repository "$testroot/repo-clone"
386 # branch2 exists only in the remote repository
387 got branch
-r $testroot/repo-clone branch2
389 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
391 if [ $ret -ne 0 ]; then
392 echo "got ref command failed unexpectedly" >&2
393 test_done
"$testroot" "$ret"
397 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
398 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
399 echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
400 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
402 # Sending changes for a branch and deleting it at the same
403 # time is not allowed.
404 got send
-q -r $testroot/repo
-d branch1
-b branch1 \
405 > $testroot/stdout
2> $testroot/stderr
407 if [ $ret -eq 0 ]; then
408 echo "got send command succeeded unexpectedly" >&2
409 test_done
"$testroot" 1
412 echo -n "got: changes on refs/heads/branch1 will be sent to server" \
413 > $testroot/stderr.expected
414 echo ": reference cannot be deleted" >> $testroot/stderr.expected
415 cmp -s $testroot/stderr
$testroot/stderr.expected
417 if [ $ret -ne 0 ]; then
418 diff -u $testroot/stderr.expected
$testroot/stderr
419 test_done
"$testroot" "$ret"
423 got send
-q -r $testroot/repo
-d refs
/heads
/branch1 origin \
424 > $testroot/stdout
2> $testroot/stderr
426 if [ $ret -ne 0 ]; then
427 echo "got send command failed unexpectedly" >&2
428 test_done
"$testroot" "$ret"
432 got send
-r $testroot/repo
-d refs
/heads
/branch2 origin \
433 > $testroot/stdout
2>$testroot/stderr
435 if [ $ret -ne 0 ]; then
436 echo "got send command failed unexpectedly" >&2
437 test_done
"$testroot" "$ret"
441 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
442 > $testroot/stdout.expected
443 echo "Server has deleted refs/heads/branch2" \
444 >> $testroot/stdout.expected
446 cmp -s $testroot/stdout
$testroot/stdout.expected
448 if [ $ret -ne 0 ]; then
449 diff -u $testroot/stdout.expected
$testroot/stdout
450 test_done
"$testroot" "$ret"
454 # branchX exists in neither repository
455 got send
-q -r $testroot/repo
-d refs
/heads
/branchX origin \
456 > $testroot/stdout
2> $testroot/stderr
458 if [ $ret -eq 0 ]; then
459 echo "got send command succeeded unexpectedly" >&2
460 test_done
"$testroot" 1
463 echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
464 > $testroot/stderr.expected
465 echo "repository: no such reference found" >> $testroot/stderr.expected
466 echo "got: no such reference found" >> $testroot/stderr.expected
467 cmp -s $testroot/stderr
$testroot/stderr.expected
469 if [ $ret -ne 0 ]; then
470 diff -u $testroot/stderr.expected
$testroot/stderr
471 test_done
"$testroot" "$ret"
475 # References outside of refs/heads/ cannot be deleted with 'got send'.
476 got send
-q -r $testroot/repo
-d refs
/tags
/1.0 origin \
477 > $testroot/stdout
2> $testroot/stderr
479 if [ $ret -eq 0 ]; then
480 echo "got send command succeeded unexpectedly" >&2
481 test_done
"$testroot" 1
484 echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
485 > $testroot/stderr.expected
486 echo "in remote repository: no such reference found" \
487 >> $testroot/stderr.expected
488 echo "got: no such reference found" >> $testroot/stderr.expected
489 cmp -s $testroot/stderr
$testroot/stderr.expected
491 if [ $ret -ne 0 ]; then
492 diff -u $testroot/stderr.expected
$testroot/stderr
493 test_done
"$testroot" "$ret"
497 got ref
-l -r $testroot/repo
> $testroot/stdout
499 if [ $ret -ne 0 ]; then
500 echo "got ref command failed unexpectedly" >&2
501 test_done
"$testroot" "$ret"
505 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
506 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
507 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
509 cmp -s $testroot/stdout
$testroot/stdout.expected
511 if [ $ret -ne 0 ]; then
512 diff -u $testroot/stdout.expected
$testroot/stdout
513 test_done
"$testroot" "$ret"
517 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
519 if [ $ret -ne 0 ]; then
520 echo "got ref command failed unexpectedly" >&2
521 test_done
"$testroot" "$ret"
525 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
526 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
527 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
528 >> $testroot/stdout.expected
529 echo "refs/remotes/origin/branch1: $commit_id" \
530 >> $testroot/stdout.expected
531 echo "refs/remotes/origin/master: $commit_id" \
532 >> $testroot/stdout.expected
534 cmp -s $testroot/stdout
$testroot/stdout.expected
536 if [ $ret -ne 0 ]; then
537 diff -u $testroot/stdout.expected
$testroot/stdout
538 test_done
"$testroot" "$ret"
542 git_fsck
"$testroot" "$testroot/repo-clone"
544 test_done
"$testroot" "$ret"
547 test_send_clone_and_send
() {
548 local testroot
=`test_init send_clone_and_send`
549 local testurl
=ssh://127.0.0.1/$testroot
550 local commit_id
=`git_show_head $testroot/repo`
552 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
554 got clone
-q $testurl/repo
$testroot/repo-clone
556 if [ $ret -ne 0 ]; then
557 echo "got clone command failed unexpectedly" >&2
558 test_done
"$testroot" "$ret"
562 got checkout
$testroot/repo-clone
$testroot/wt
>/dev
/null
563 echo "modified alpha" > $testroot/wt
/alpha
564 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
565 local commit_id2
=`git_show_head $testroot/repo-clone`
567 (cd $testroot/wt
&& got send
-q > $testroot/stdout
2> $testroot/stderr
)
569 if [ $ret -ne 0 ]; then
570 echo "got send command failed unexpectedly" >&2
571 test_done
"$testroot" "$ret"
575 echo -n > $testroot/stdout.expected
576 cmp -s $testroot/stdout
$testroot/stdout.expected
578 if [ $ret -ne 0 ]; then
579 diff -u $testroot/stdout.expected
$testroot/stdout
580 test_done
"$testroot" "$ret"
584 got ref
-l -r $testroot/repo
> $testroot/stdout
586 if [ $ret -ne 0 ]; then
587 echo "got ref command failed unexpectedly" >&2
588 test_done
"$testroot" "$ret"
592 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
593 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
595 cmp -s $testroot/stdout
$testroot/stdout.expected
597 if [ $ret -ne 0 ]; then
598 diff -u $testroot/stdout.expected
$testroot/stdout
599 test_done
"$testroot" "$ret"
603 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
605 if [ $ret -ne 0 ]; then
606 echo "got ref command failed unexpectedly" >&2
607 test_done
"$testroot" "$ret"
611 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
612 cut -d ':' -f 2 | tr -d ' ')`
613 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
614 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
615 >> $testroot/stdout.expected
616 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
617 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
618 >> $testroot/stdout.expected
619 echo "refs/remotes/origin/master: $commit_id2" \
620 >> $testroot/stdout.expected
622 cmp -s $testroot/stdout
$testroot/stdout.expected
624 if [ $ret -ne 0 ]; then
625 diff -u $testroot/stdout.expected
$testroot/stdout
626 test_done
"$testroot" "$ret"
630 git_fsck
"$testroot" "$testroot/repo-clone"
632 test_done
"$testroot" "$ret"
636 local testroot
=`test_init send_tags`
637 local testurl
=ssh://127.0.0.1/$testroot
638 local commit_id
=`git_show_head $testroot/repo`
640 got clone
-q $testurl/repo
$testroot/repo-clone
642 if [ $ret -ne 0 ]; then
643 echo "got clone command failed unexpectedly" >&2
644 test_done
"$testroot" "$ret"
647 cat > $testroot/repo
/.git
/got.conf
<<EOF
651 repository "$testroot/repo-clone"
654 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
655 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
656 | tr -d ' ' | cut -d: -f2`
658 echo "modified alpha" > $testroot/repo
/alpha
659 git_commit
$testroot/repo
-m "modified alpha"
660 local commit_id2
=`git_show_head $testroot/repo`
662 got tag
-r $testroot/repo
-m '2.0' 2.0 >/dev
/null
663 tag_id2
=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
664 | tr -d ' ' | cut -d: -f2`
666 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
668 if [ $ret -ne 0 ]; then
669 echo "got send command failed unexpectedly" >&2
670 test_done
"$testroot" "$ret"
674 echo -n > $testroot/stdout.expected
675 cmp -s $testroot/stdout
$testroot/stdout.expected
677 if [ $ret -ne 0 ]; then
678 diff -u $testroot/stdout.expected
$testroot/stdout
679 test_done
"$testroot" "$ret"
683 got ref
-l -r $testroot/repo
> $testroot/stdout
685 if [ $ret -ne 0 ]; then
686 echo "got ref command failed unexpectedly" >&2
687 test_done
"$testroot" "$ret"
691 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
692 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
693 echo "refs/remotes/origin/master: $commit_id2" \
694 >> $testroot/stdout.expected
695 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
696 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
698 cmp -s $testroot/stdout
$testroot/stdout.expected
700 if [ $ret -ne 0 ]; then
701 diff -u $testroot/stdout.expected
$testroot/stdout
702 test_done
"$testroot" "$ret"
706 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
708 if [ $ret -ne 0 ]; then
709 echo "got ref command failed unexpectedly" >&2
710 test_done
"$testroot" "$ret"
714 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
715 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
716 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
717 >> $testroot/stdout.expected
718 echo "refs/remotes/origin/master: $commit_id" \
719 >> $testroot/stdout.expected
720 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
721 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
723 cmp -s $testroot/stdout
$testroot/stdout.expected
725 if [ $ret -ne 0 ]; then
726 diff -u $testroot/stdout.expected
$testroot/stdout
727 test_done
"$testroot" "$ret"
731 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
732 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
733 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
734 cmp -s $testroot/stdout
$testroot/stdout.expected
736 if [ $ret -ne 0 ]; then
737 diff -u $testroot/stdout.expected
$testroot/stdout
738 test_done
"$testroot" "$ret"
742 # Send the same tags again. This should be a no-op.
743 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
745 if [ $ret -ne 0 ]; then
746 echo "got send command failed unexpectedly" >&2
747 test_done
"$testroot" "$ret"
751 echo -n > $testroot/stdout.expected
752 cmp -s $testroot/stdout
$testroot/stdout.expected
754 if [ $ret -ne 0 ]; then
755 diff -u $testroot/stdout.expected
$testroot/stdout
756 test_done
"$testroot" "$ret"
760 # Overwriting an existing tag 'got send -f'.
761 got ref
-r $testroot/repo
-d refs
/tags
/1.0 >/dev
/null
762 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
763 tag_id3
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
764 | tr -d ' ' | cut -d: -f2`
766 got send
-q -r $testroot/repo
-t 1.0 > $testroot/stdout \
769 if [ $ret -eq 0 ]; then
770 echo "got send command succeeded unexpectedly" >&2
771 test_done
"$testroot" 1
775 echo "got: refs/tags/1.0: tag already exists on server" \
776 > $testroot/stderr.expected
777 cmp -s $testroot/stderr
$testroot/stderr.expected
779 if [ $ret -ne 0 ]; then
780 diff -u $testroot/stderr.expected
$testroot/stderr
781 test_done
"$testroot" "$ret"
785 # attempting the same with -T should fail, too
786 got send
-q -r $testroot/repo
-T > $testroot/stdout \
789 if [ $ret -eq 0 ]; then
790 echo "got send command succeeded unexpectedly" >&2
791 test_done
"$testroot" 1
795 echo "got: refs/tags/1.0: tag already exists on server" \
796 > $testroot/stderr.expected
797 cmp -s $testroot/stderr
$testroot/stderr.expected
799 if [ $ret -ne 0 ]; then
800 diff -u $testroot/stderr.expected
$testroot/stderr
801 test_done
"$testroot" "$ret"
805 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
806 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
807 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
808 cmp -s $testroot/stdout
$testroot/stdout.expected
810 if [ $ret -ne 0 ]; then
811 diff -u $testroot/stdout.expected
$testroot/stdout
812 test_done
"$testroot" "$ret"
816 # overwrite the 1.0 tag only
817 got send
-q -r $testroot/repo
-t 1.0 -f > $testroot/stdout \
820 if [ $ret -ne 0 ]; then
821 echo "got send command failed unexpectedly" >&2
822 test_done
"$testroot" "$ret"
826 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
827 echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
828 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
829 cmp -s $testroot/stdout
$testroot/stdout.expected
831 if [ $ret -ne 0 ]; then
832 diff -u $testroot/stdout.expected
$testroot/stdout
833 test_done
"$testroot" "$ret"
837 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
838 echo 'new line in file alpha' >> $testroot/wt
/alpha
839 (cd $testroot/wt
&& got commit
-m 'changing file alpha' > /dev
/null
)
841 # Send the new commit in isolation.
842 got send
-q -r $testroot/repo
> $testroot/stdout \
845 if [ $ret -ne 0 ]; then
846 echo "got send command failed unexpectedly" >&2
847 test_done
"$testroot" "$ret"
851 # Now tag it and send the tag.
852 # Verify that just the new tag object gets sent.
853 got tag
-r $testroot/repo
-m '3.0' 3.0 >/dev
/null
854 tag_id4
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
855 | tr -d ' ' | cut -d: -f2`
857 got send
-r $testroot/repo
-t 3.0 > $testroot/stdout.raw \
860 if [ $ret -ne 0 ]; then
861 echo "got send command failed unexpectedly" >&2
862 test_done
"$testroot" "$ret"
865 tr -d '\r' < $testroot/stdout.raw
> $testroot/stdout
866 if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
867 $testroot/stdout
; then
868 echo "got send did apparently pack too many objects:" >&2
869 cat $testroot/stdout.raw
>&2
870 test_done
"$testroot" "1"
874 git_fsck
"$testroot" "$testroot/repo-clone"
876 test_done
"$testroot" "$ret"
879 test_send_tag_of_deleted_branch
() {
880 local testroot
=`test_init send_tag_of_deleted_branch`
881 local testurl
=ssh://127.0.0.1/$testroot
882 local commit_id
=`git_show_head $testroot/repo`
884 got clone
-q $testurl/repo
$testroot/repo-clone
886 if [ $ret -ne 0 ]; then
887 echo "got clone command failed unexpectedly" >&2
888 test_done
"$testroot" "$ret"
891 cat > $testroot/repo
/.git
/got.conf
<<EOF
895 repository "$testroot/repo-clone"
898 got branch
-r $testroot/repo foo
900 # modify beta on branch foo
901 got checkout
-b foo
$testroot/repo
$testroot/wt
> /dev
/null
902 echo boo
>> $testroot/wt
/beta
903 (cd $testroot/wt
&& got commit
-m 'changed beta on branch foo' \
905 echo buu
>> $testroot/wt
/beta
906 (cd $testroot/wt
&& got commit
-m 'changed beta again on branch foo' \
908 echo baa
>> $testroot/wt
/beta
909 (cd $testroot/wt
&& got commit
-m 'changed beta again on branch foo' \
911 local commit_id2
=`git_show_branch_head $testroot/repo foo`
913 # tag HEAD commit of branch foo
914 got tag
-r $testroot/repo
-c foo
-m '1.0' 1.0 > /dev
/null
915 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
916 | tr -d ' ' | cut -d: -f2`
918 # delete the branch; commit is now only reachable via tags/1.0
919 got branch
-r $testroot/repo
-d foo
> /dev
/null
921 # unrelated change on master branch, then try sending this branch
923 echo "modified alpha" > $testroot/repo
/alpha
924 git_commit
$testroot/repo
-m "modified alpha"
925 local commit_id3
=`git_show_head $testroot/repo`
927 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
929 if [ $ret -ne 0 ]; then
930 echo "got send command failed unexpectedly" >&2
931 test_done
"$testroot" "$ret"
935 echo -n > $testroot/stdout.expected
936 cmp -s $testroot/stdout
$testroot/stdout.expected
938 if [ $ret -ne 0 ]; then
939 diff -u $testroot/stdout.expected
$testroot/stdout
940 test_done
"$testroot" "$ret"
944 got ref
-l -r $testroot/repo
> $testroot/stdout
946 if [ $ret -ne 0 ]; then
947 echo "got ref command failed unexpectedly" >&2
948 test_done
"$testroot" "$ret"
952 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
953 cut -d ':' -f 2 | tr -d ' ')`
954 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
955 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
956 >> $testroot/stdout.expected
957 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
958 echo "refs/remotes/origin/master: $commit_id3" \
959 >> $testroot/stdout.expected
960 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
962 cmp -s $testroot/stdout
$testroot/stdout.expected
964 if [ $ret -ne 0 ]; then
965 diff -u $testroot/stdout.expected
$testroot/stdout
966 test_done
"$testroot" "$ret"
970 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
972 if [ $ret -ne 0 ]; then
973 echo "got ref command failed unexpectedly" >&2
974 test_done
"$testroot" "$ret"
978 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
979 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
980 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
981 >> $testroot/stdout.expected
982 echo "refs/remotes/origin/master: $commit_id" \
983 >> $testroot/stdout.expected
984 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
986 cmp -s $testroot/stdout
$testroot/stdout.expected
988 if [ $ret -ne 0 ]; then
989 diff -u $testroot/stdout.expected
$testroot/stdout
990 test_done
"$testroot" "$ret"
994 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
995 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
997 cmp -s $testroot/stdout
$testroot/stdout.expected
999 if [ $ret -ne 0 ]; then
1000 diff -u $testroot/stdout.expected
$testroot/stdout
1001 test_done
"$testroot" "$ret"
1005 git_fsck
"$testroot" "$testroot/repo-clone"
1007 test_done
"$testroot" "$ret"
1010 test_send_new_branch
() {
1011 local testroot
=`test_init send_new_branch`
1012 local testurl
=ssh://127.0.0.1/$testroot
1013 local commit_id
=`git_show_head $testroot/repo`
1015 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
1017 got clone
-q $testurl/repo
$testroot/repo-clone
1019 if [ $ret -ne 0 ]; then
1020 echo "got clone command failed unexpectedly" >&2
1021 test_done
"$testroot" "$ret"
1025 got branch
-r $testroot/repo-clone foo
>/dev
/null
1026 got checkout
-b foo
$testroot/repo-clone
$testroot/wt
>/dev
/null
1027 echo "modified alpha" > $testroot/wt
/alpha
1028 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
1029 local commit_id2
=`git_show_branch_head $testroot/repo-clone foo`
1031 (cd $testroot/wt
&& got send
-q > $testroot/stdout
2> $testroot/stderr
)
1033 if [ $ret -ne 0 ]; then
1034 echo "got send command failed unexpectedly" >&2
1035 test_done
"$testroot" "$ret"
1039 echo -n > $testroot/stdout.expected
1040 cmp -s $testroot/stdout
$testroot/stdout.expected
1042 if [ $ret -ne 0 ]; then
1043 diff -u $testroot/stdout.expected
$testroot/stdout
1044 test_done
"$testroot" "$ret"
1048 got ref
-l -r $testroot/repo
> $testroot/stdout
1050 if [ $ret -ne 0 ]; then
1051 echo "got ref command failed unexpectedly" >&2
1052 test_done
"$testroot" "$ret"
1056 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1057 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1058 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1060 cmp -s $testroot/stdout
$testroot/stdout.expected
1062 if [ $ret -ne 0 ]; then
1063 diff -u $testroot/stdout.expected
$testroot/stdout
1064 test_done
"$testroot" "$ret"
1068 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1070 if [ $ret -ne 0 ]; then
1071 echo "got ref command failed unexpectedly" >&2
1072 test_done
"$testroot" "$ret"
1076 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
1077 cut -d ':' -f 2 | tr -d ' ')`
1078 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1079 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1080 >> $testroot/stdout.expected
1081 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1082 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1083 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1084 >> $testroot/stdout.expected
1085 echo "refs/remotes/origin/foo: $commit_id2" \
1086 >> $testroot/stdout.expected
1087 echo "refs/remotes/origin/master: $commit_id" \
1088 >> $testroot/stdout.expected
1090 cmp -s $testroot/stdout
$testroot/stdout.expected
1092 if [ $ret -ne 0 ]; then
1093 diff -u $testroot/stdout.expected
$testroot/stdout
1094 test_done
"$testroot" "$ret"
1098 git_fsck
"$testroot" "$testroot/repo-clone"
1100 test_done
"$testroot" "$ret"
1103 test_send_all_branches
() {
1104 local testroot
=`test_init send_all_branches`
1105 local testurl
=ssh://127.0.0.1/$testroot
1106 local commit_id
=`git_show_head $testroot/repo`
1108 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
1110 got clone
-q $testurl/repo
$testroot/repo-clone
1112 if [ $ret -ne 0 ]; then
1113 echo "got clone command failed unexpectedly" >&2
1114 test_done
"$testroot" "$ret"
1118 got checkout
$testroot/repo-clone
$testroot/wt
>/dev
/null
1119 echo "modified alpha" > $testroot/wt
/alpha
1120 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
1121 local commit_id2
=`git_show_head $testroot/repo-clone`
1123 got branch
-r $testroot/repo-clone foo
>/dev
/null
1124 (cd $testroot/wt
&& got update
-b foo
>/dev
/null
)
1125 echo "modified beta on new branch foo" > $testroot/wt
/beta
1126 (cd $testroot/wt
&& got commit
-m "modified beta" >/dev
/null
)
1127 local commit_id3
=`git_show_branch_head $testroot/repo-clone foo`
1129 got branch
-r $testroot/repo-clone bar
>/dev
/null
1130 (cd $testroot/wt
&& got update
-b bar
>/dev
/null
)
1131 echo "modified beta again on new branch bar" > $testroot/wt
/beta
1132 (cd $testroot/wt
&& got commit
-m "modified beta" >/dev
/null
)
1133 local commit_id4
=`git_show_branch_head $testroot/repo-clone bar`
1135 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1137 if [ $ret -ne 0 ]; then
1138 echo "got ref command failed unexpectedly" >&2
1139 test_done
"$testroot" "$ret"
1143 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1144 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1145 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1146 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1148 got send
-a -q -r $testroot/repo-clone
-b master
> $testroot/stdout \
1151 if [ $ret -eq 0 ]; then
1152 echo "got send command succeeded unexpectedly" >&2
1153 test_done
"$testroot" 1
1156 echo "got: -a and -b options are mutually exclusive" \
1157 > $testroot/stderr.expected
1158 cmp -s $testroot/stderr
$testroot/stderr.expected
1160 if [ $ret -ne 0 ]; then
1161 diff -u $testroot/stderr.expected
$testroot/stderr
1162 test_done
"$testroot" "$ret"
1166 got send
-a -q -r $testroot/repo-clone
> $testroot/stdout \
1169 if [ $ret -ne 0 ]; then
1170 echo "got send command failed unexpectedly" >&2
1171 test_done
"$testroot" "$ret"
1175 echo -n > $testroot/stdout.expected
1176 cmp -s $testroot/stdout
$testroot/stdout.expected
1178 if [ $ret -ne 0 ]; then
1179 diff -u $testroot/stdout.expected
$testroot/stdout
1180 test_done
"$testroot" "$ret"
1184 got ref
-l -r $testroot/repo
> $testroot/stdout
1186 if [ $ret -ne 0 ]; then
1187 echo "got ref command failed unexpectedly" >&2
1188 test_done
"$testroot" "$ret"
1192 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1193 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1194 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1195 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1197 cmp -s $testroot/stdout
$testroot/stdout.expected
1199 if [ $ret -ne 0 ]; then
1200 diff -u $testroot/stdout.expected
$testroot/stdout
1201 test_done
"$testroot" "$ret"
1205 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1207 if [ $ret -ne 0 ]; then
1208 echo "got ref command failed unexpectedly" >&2
1209 test_done
"$testroot" "$ret"
1213 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
1214 cut -d ':' -f 2 | tr -d ' ')`
1215 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1216 echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1217 >> $testroot/stdout.expected
1218 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1219 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1220 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1221 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1222 >> $testroot/stdout.expected
1223 echo "refs/remotes/origin/bar: $commit_id4" \
1224 >> $testroot/stdout.expected
1225 echo "refs/remotes/origin/foo: $commit_id3" \
1226 >> $testroot/stdout.expected
1227 echo "refs/remotes/origin/master: $commit_id2" \
1228 >> $testroot/stdout.expected
1230 cmp -s $testroot/stdout
$testroot/stdout.expected
1232 if [ $ret -ne 0 ]; then
1233 diff -u $testroot/stdout.expected
$testroot/stdout
1234 test_done
"$testroot" "$ret"
1238 git_fsck
"$testroot" "$testroot/repo-clone"
1240 test_done
"$testroot" "$ret"
1243 test_send_to_empty_repo
() {
1244 local testroot
=`test_init send_to_empty_repo`
1245 local testurl
=ssh://127.0.0.1/$testroot
1246 local commit_id
=`git_show_head $testroot/repo`
1248 gotadmin init
$testroot/repo2
1251 if [ $ret -ne 0 ]; then
1252 echo "got clone command failed unexpectedly" >&2
1253 test_done
"$testroot" "$ret"
1256 cat > $testroot/repo
/.git
/got.conf
<<EOF
1260 repository "$testroot/repo2"
1263 echo "modified alpha" > $testroot/repo
/alpha
1264 git_commit
$testroot/repo
-m "modified alpha"
1265 local commit_id2
=`git_show_head $testroot/repo`
1267 got send
-q -r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1269 if [ $ret -ne 0 ]; then
1270 echo "got send command failed unexpectedly" >&2
1271 test_done
"$testroot" "$ret"
1275 echo -n > $testroot/stdout.expected
1276 cmp -s $testroot/stdout
$testroot/stdout.expected
1278 if [ $ret -ne 0 ]; then
1279 diff -u $testroot/stdout.expected
$testroot/stdout
1280 test_done
"$testroot" "$ret"
1284 # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1285 got ref
-r $testroot/repo2
-s refs
/heads
/master HEAD
1287 got ref
-l -r $testroot/repo
> $testroot/stdout
1289 if [ $ret -ne 0 ]; then
1290 echo "got ref command failed unexpectedly" >&2
1291 test_done
"$testroot" "$ret"
1295 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1296 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1297 echo "refs/remotes/origin/master: $commit_id2" \
1298 >> $testroot/stdout.expected
1300 cmp -s $testroot/stdout
$testroot/stdout.expected
1302 if [ $ret -ne 0 ]; then
1303 diff -u $testroot/stdout.expected
$testroot/stdout
1304 test_done
"$testroot" "$ret"
1308 got ref
-l -r $testroot/repo2
> $testroot/stdout
1310 if [ $ret -ne 0 ]; then
1311 echo "got ref command failed unexpectedly" >&2
1312 test_done
"$testroot" "$ret"
1316 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1317 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1319 cmp -s $testroot/stdout
$testroot/stdout.expected
1321 if [ $ret -ne 0 ]; then
1322 diff -u $testroot/stdout.expected
$testroot/stdout
1323 test_done
"$testroot" "$ret"
1327 got send
-r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1329 if [ $ret -ne 0 ]; then
1330 echo "got send command failed unexpectedly" >&2
1331 test_done
"$testroot" "$ret"
1335 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1336 > $testroot/stdout.expected
1337 echo "Already up-to-date" >> $testroot/stdout.expected
1338 cmp -s $testroot/stdout
$testroot/stdout.expected
1340 if [ $ret -ne 0 ]; then
1341 diff -u $testroot/stdout.expected
$testroot/stdout
1342 test_done
"$testroot" "$ret"
1346 git_fsck
"$testroot" "$testroot/repo2"
1348 test_done
"$testroot" "$ret"
1351 test_send_and_fetch_config
() {
1352 local testroot
=`test_init send_fetch_conf`
1353 local testurl
=ssh://127.0.0.1/$testroot
1354 local commit_id
=`git_show_head $testroot/repo`
1356 got clone
-q $testurl/repo
$testroot/repo-clone
1358 if [ $ret -ne 0 ]; then
1359 echo "got clone command failed unexpectedly" >&2
1360 test_done
"$testroot" "$ret"
1364 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
1365 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1366 | tr -d ' ' | cut -d: -f2`
1368 cp -R $testroot/repo-clone
$testroot/repo-clone2
1369 got tag
-r $testroot/repo-clone2
-m '2.0' 2.0 >/dev
/null
1370 tag_id2
=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1371 | tr -d ' ' | cut -d: -f2`
1373 cat > $testroot/repo
/.git
/got.conf
<<EOF
1378 repository "$testroot/repo-clone"
1381 repository "$testroot/repo-clone2"
1385 got ref
-l -r $testroot/repo
> $testroot/stdout
1387 if [ $ret -ne 0 ]; then
1388 echo "got ref command failed unexpectedly" >&2
1389 test_done
"$testroot" "$ret"
1393 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1394 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1395 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1396 cmp -s $testroot/stdout
$testroot/stdout.expected
1398 if [ $ret -ne 0 ]; then
1399 diff -u $testroot/stdout.expected
$testroot/stdout
1400 test_done
"$testroot" "$ret"
1404 # fetch tag 2.0 from repo-clone2
1405 got fetch
-q -r $testroot/repo
> $testroot/stdout
1407 if [ $ret -ne 0 ]; then
1408 echo "got fetch command failed unexpectedly" >&2
1409 test_done
"$testroot" "$ret"
1413 got ref
-l -r $testroot/repo
> $testroot/stdout
1415 if [ $ret -ne 0 ]; then
1416 echo "got ref command failed unexpectedly" >&2
1417 test_done
"$testroot" "$ret"
1421 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1422 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1423 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1424 >> $testroot/stdout.expected
1425 echo "refs/remotes/origin/master: $commit_id" \
1426 >> $testroot/stdout.expected
1427 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1428 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1429 cmp -s $testroot/stdout
$testroot/stdout.expected
1431 if [ $ret -ne 0 ]; then
1432 diff -u $testroot/stdout.expected
$testroot/stdout
1433 test_done
"$testroot" "$ret"
1437 # send tag 1.0 to repo-clone
1438 got send
-q -r $testroot/repo
-t 1.0 > $testroot/stdout
1440 if [ $ret -ne 0 ]; then
1441 echo "got send command failed unexpectedly" >&2
1442 test_done
"$testroot" "$ret"
1446 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1448 if [ $ret -ne 0 ]; then
1449 echo "got ref command failed unexpectedly" >&2
1450 test_done
"$testroot" "$ret"
1454 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1455 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1456 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1457 >> $testroot/stdout.expected
1458 echo "refs/remotes/origin/master: $commit_id" \
1459 >> $testroot/stdout.expected
1460 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1462 cmp -s $testroot/stdout
$testroot/stdout.expected
1464 if [ $ret -ne 0 ]; then
1465 diff -u $testroot/stdout.expected
$testroot/stdout
1466 test_done
"$testroot" "$ret"
1470 git_fsck
"$testroot" "$testroot/repo-clone"
1472 test_done
"$testroot" "$ret"
1475 test_send_config
() {
1476 local testroot
=`test_init send_config`
1477 local testurl
=ssh://127.0.0.1/$testroot
1478 local commit_id
=`git_show_head $testroot/repo`
1480 got clone
-q $testurl/repo
$testroot/repo-clone
1482 if [ $ret -ne 0 ]; then
1483 echo "got clone command failed unexpectedly" >&2
1484 test_done
"$testroot" "$ret"
1488 cat > $testroot/repo
/.git
/got.conf
<<EOF
1493 repository "$testroot/repo-clone"
1496 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1498 if [ $ret -ne 0 ]; then
1499 echo "got ref command failed unexpectedly" >&2
1500 test_done
"$testroot" "$ret"
1504 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1505 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1506 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1507 >> $testroot/stdout.expected
1508 echo "refs/remotes/origin/master: $commit_id" \
1509 >> $testroot/stdout.expected
1511 cmp -s $testroot/stdout
$testroot/stdout.expected
1513 if [ $ret -ne 0 ]; then
1514 diff -u $testroot/stdout.expected
$testroot/stdout
1515 test_done
"$testroot" "$ret"
1519 got branch
-r $testroot/repo foo
1521 got send
-q -r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1523 if [ $ret -ne 0 ]; then
1524 echo "got send command failed unexpectedly" >&2
1525 test_done
"$testroot" "$ret"
1529 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1531 if [ $ret -ne 0 ]; then
1532 echo "got ref command failed unexpectedly" >&2
1533 test_done
"$testroot" "$ret"
1537 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1538 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1539 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1540 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1541 >> $testroot/stdout.expected
1542 echo "refs/remotes/origin/master: $commit_id" \
1543 >> $testroot/stdout.expected
1545 cmp -s $testroot/stdout
$testroot/stdout.expected
1547 if [ $ret -ne 0 ]; then
1548 diff -u $testroot/stdout.expected
$testroot/stdout
1549 test_done
"$testroot" "$ret"
1553 git_fsck
"$testroot" "$testroot/repo-clone"
1555 test_done
"$testroot" "$ret"
1558 test_send_rejected
() {
1559 local testroot
=`test_init send_rejected`
1560 local testurl
=ssh://127.0.0.1/$testroot
1561 local commit_id
=`git_show_head $testroot/repo`
1563 if ! got clone
-q "$testurl/repo" "$testroot/repo-clone"; then
1564 echo "got clone command failed unexpectedly" >&2
1565 test_done
"$testroot" 1
1569 mkdir
"$testroot/repo-clone/hooks"
1570 cat <<'EOF' >$testroot/repo-clone/hooks/update
1573 echo "rejecting push on master branch"
1579 chmod +x
"$testroot/repo-clone/hooks/update"
1581 cat > $testroot/repo
/.git
/got.conf
<<EOF
1585 repository "$testroot/repo-clone"
1589 echo "modified alpha" >$testroot/repo
/alpha
1590 git_commit
"$testroot/repo" -m "modified alpha"
1592 got send
-q -r "$testroot/repo" >$testroot/stdout
2>$testroot/stderr
1594 if [ $ret -ne 0 ]; then
1595 echo "got send command failed unexpectedly" >&2
1596 test_done
"$testroot" $ret
1600 touch "$testroot/stdout.expected"
1601 if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1602 diff -u "$testroot/stdout.expected" "$testroot/stdout"
1603 test_done
"$testroot" 1
1607 cat <<EOF >$testroot/stderr.expected
1608 rejecting push on master branch
1609 error: hook declined to update refs/heads/master
1612 if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1613 diff -u "$testroot/stderr.expected" "$testroot/stderr"
1614 test_done
"$testroot" 1
1618 test_done
"$testroot" 0
1622 run_test test_send_basic
1623 run_test test_send_rebase_required
1624 run_test test_send_rebase_required_overwrite
1625 run_test test_send_merge_commit
1626 run_test test_send_delete
1627 run_test test_send_clone_and_send
1628 run_test test_send_tags
1629 run_test test_send_tag_of_deleted_branch
1630 run_test test_send_new_branch
1631 run_test test_send_all_branches
1632 run_test test_send_to_empty_repo
1633 run_test test_send_and_fetch_config
1634 run_test test_send_config
1635 run_test test_send_rejected