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"
326 local testroot
=`test_init send_delete`
327 local testurl
=ssh://127.0.0.1/$testroot
328 local commit_id
=`git_show_head $testroot/repo`
330 # branch1 exists in both repositories
331 got branch
-r $testroot/repo branch1
333 got clone
-a -q $testurl/repo
$testroot/repo-clone
335 if [ $ret -ne 0 ]; then
336 echo "got clone command failed unexpectedly" >&2
337 test_done
"$testroot" "$ret"
340 cat > $testroot/repo
/.git
/got.conf
<<EOF
344 repository "$testroot/repo-clone"
347 # branch2 exists only in the remote repository
348 got branch
-r $testroot/repo-clone branch2
350 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
352 if [ $ret -ne 0 ]; then
353 echo "got ref command failed unexpectedly" >&2
354 test_done
"$testroot" "$ret"
358 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
359 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
360 echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
361 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
363 # Sending changes for a branch and deleting it at the same
364 # time is not allowed.
365 got send
-q -r $testroot/repo
-d branch1
-b branch1 \
366 > $testroot/stdout
2> $testroot/stderr
368 if [ $ret -eq 0 ]; then
369 echo "got send command succeeded unexpectedly" >&2
370 test_done
"$testroot" 1
373 echo -n "got: changes on refs/heads/branch1 will be sent to server" \
374 > $testroot/stderr.expected
375 echo ": reference cannot be deleted" >> $testroot/stderr.expected
376 cmp -s $testroot/stderr
$testroot/stderr.expected
378 if [ $ret -ne 0 ]; then
379 diff -u $testroot/stderr.expected
$testroot/stderr
380 test_done
"$testroot" "$ret"
384 got send
-q -r $testroot/repo
-d refs
/heads
/branch1 origin \
385 > $testroot/stdout
2> $testroot/stderr
387 if [ $ret -ne 0 ]; then
388 echo "got send command failed unexpectedly" >&2
389 test_done
"$testroot" "$ret"
393 got send
-r $testroot/repo
-d refs
/heads
/branch2 origin \
394 > $testroot/stdout
2>$testroot/stderr
396 if [ $ret -ne 0 ]; then
397 echo "got send command failed unexpectedly" >&2
398 test_done
"$testroot" "$ret"
402 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
403 > $testroot/stdout.expected
404 echo "Server has deleted refs/heads/branch2" \
405 >> $testroot/stdout.expected
407 cmp -s $testroot/stdout
$testroot/stdout.expected
409 if [ $ret -ne 0 ]; then
410 diff -u $testroot/stdout.expected
$testroot/stdout
411 test_done
"$testroot" "$ret"
415 # branchX exists in neither repository
416 got send
-q -r $testroot/repo
-d refs
/heads
/branchX origin \
417 > $testroot/stdout
2> $testroot/stderr
419 if [ $ret -eq 0 ]; then
420 echo "got send command succeeded unexpectedly" >&2
421 test_done
"$testroot" 1
424 echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
425 > $testroot/stderr.expected
426 echo "repository: no such reference found" >> $testroot/stderr.expected
427 echo "got: no such reference found" >> $testroot/stderr.expected
428 cmp -s $testroot/stderr
$testroot/stderr.expected
430 if [ $ret -ne 0 ]; then
431 diff -u $testroot/stderr.expected
$testroot/stderr
432 test_done
"$testroot" "$ret"
436 # References outside of refs/heads/ cannot be deleted with 'got send'.
437 got send
-q -r $testroot/repo
-d refs
/tags
/1.0 origin \
438 > $testroot/stdout
2> $testroot/stderr
440 if [ $ret -eq 0 ]; then
441 echo "got send command succeeded unexpectedly" >&2
442 test_done
"$testroot" 1
445 echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
446 > $testroot/stderr.expected
447 echo "in remote repository: no such reference found" \
448 >> $testroot/stderr.expected
449 echo "got: no such reference found" >> $testroot/stderr.expected
450 cmp -s $testroot/stderr
$testroot/stderr.expected
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stderr.expected
$testroot/stderr
454 test_done
"$testroot" "$ret"
458 got ref
-l -r $testroot/repo
> $testroot/stdout
460 if [ $ret -ne 0 ]; then
461 echo "got ref command failed unexpectedly" >&2
462 test_done
"$testroot" "$ret"
466 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
467 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
468 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
470 cmp -s $testroot/stdout
$testroot/stdout.expected
472 if [ $ret -ne 0 ]; then
473 diff -u $testroot/stdout.expected
$testroot/stdout
474 test_done
"$testroot" "$ret"
478 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
480 if [ $ret -ne 0 ]; then
481 echo "got ref command failed unexpectedly" >&2
482 test_done
"$testroot" "$ret"
486 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
487 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
488 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
489 >> $testroot/stdout.expected
490 echo "refs/remotes/origin/branch1: $commit_id" \
491 >> $testroot/stdout.expected
492 echo "refs/remotes/origin/master: $commit_id" \
493 >> $testroot/stdout.expected
495 cmp -s $testroot/stdout
$testroot/stdout.expected
497 if [ $ret -ne 0 ]; then
498 diff -u $testroot/stdout.expected
$testroot/stdout
499 test_done
"$testroot" "$ret"
503 git_fsck
"$testroot" "$testroot/repo-clone"
505 test_done
"$testroot" "$ret"
508 test_send_clone_and_send
() {
509 local testroot
=`test_init send_clone_and_send`
510 local testurl
=ssh://127.0.0.1/$testroot
511 local commit_id
=`git_show_head $testroot/repo`
513 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
515 got clone
-q $testurl/repo
$testroot/repo-clone
517 if [ $ret -ne 0 ]; then
518 echo "got clone command failed unexpectedly" >&2
519 test_done
"$testroot" "$ret"
523 got checkout
$testroot/repo-clone
$testroot/wt
>/dev
/null
524 echo "modified alpha" > $testroot/wt
/alpha
525 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
526 local commit_id2
=`git_show_head $testroot/repo-clone`
528 (cd $testroot/wt
&& got send
-q > $testroot/stdout
2> $testroot/stderr
)
530 if [ $ret -ne 0 ]; then
531 echo "got send command failed unexpectedly" >&2
532 test_done
"$testroot" "$ret"
536 echo -n > $testroot/stdout.expected
537 cmp -s $testroot/stdout
$testroot/stdout.expected
539 if [ $ret -ne 0 ]; then
540 diff -u $testroot/stdout.expected
$testroot/stdout
541 test_done
"$testroot" "$ret"
545 got ref
-l -r $testroot/repo
> $testroot/stdout
547 if [ $ret -ne 0 ]; then
548 echo "got ref command failed unexpectedly" >&2
549 test_done
"$testroot" "$ret"
553 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
554 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
556 cmp -s $testroot/stdout
$testroot/stdout.expected
558 if [ $ret -ne 0 ]; then
559 diff -u $testroot/stdout.expected
$testroot/stdout
560 test_done
"$testroot" "$ret"
564 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
566 if [ $ret -ne 0 ]; then
567 echo "got ref command failed unexpectedly" >&2
568 test_done
"$testroot" "$ret"
572 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
573 cut -d ':' -f 2 | tr -d ' ')`
574 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
575 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
576 >> $testroot/stdout.expected
577 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
578 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
579 >> $testroot/stdout.expected
580 echo "refs/remotes/origin/master: $commit_id2" \
581 >> $testroot/stdout.expected
583 cmp -s $testroot/stdout
$testroot/stdout.expected
585 if [ $ret -ne 0 ]; then
586 diff -u $testroot/stdout.expected
$testroot/stdout
587 test_done
"$testroot" "$ret"
591 git_fsck
"$testroot" "$testroot/repo-clone"
593 test_done
"$testroot" "$ret"
597 local testroot
=`test_init send_tags`
598 local testurl
=ssh://127.0.0.1/$testroot
599 local commit_id
=`git_show_head $testroot/repo`
601 got clone
-q $testurl/repo
$testroot/repo-clone
603 if [ $ret -ne 0 ]; then
604 echo "got clone command failed unexpectedly" >&2
605 test_done
"$testroot" "$ret"
608 cat > $testroot/repo
/.git
/got.conf
<<EOF
612 repository "$testroot/repo-clone"
615 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
616 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
617 | tr -d ' ' | cut -d: -f2`
619 echo "modified alpha" > $testroot/repo
/alpha
620 git_commit
$testroot/repo
-m "modified alpha"
621 local commit_id2
=`git_show_head $testroot/repo`
623 got tag
-r $testroot/repo
-m '2.0' 2.0 >/dev
/null
624 tag_id2
=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
625 | tr -d ' ' | cut -d: -f2`
627 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
629 if [ $ret -ne 0 ]; then
630 echo "got send command failed unexpectedly" >&2
631 test_done
"$testroot" "$ret"
635 echo -n > $testroot/stdout.expected
636 cmp -s $testroot/stdout
$testroot/stdout.expected
638 if [ $ret -ne 0 ]; then
639 diff -u $testroot/stdout.expected
$testroot/stdout
640 test_done
"$testroot" "$ret"
644 got ref
-l -r $testroot/repo
> $testroot/stdout
646 if [ $ret -ne 0 ]; then
647 echo "got ref command failed unexpectedly" >&2
648 test_done
"$testroot" "$ret"
652 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
653 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
654 echo "refs/remotes/origin/master: $commit_id2" \
655 >> $testroot/stdout.expected
656 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
657 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
659 cmp -s $testroot/stdout
$testroot/stdout.expected
661 if [ $ret -ne 0 ]; then
662 diff -u $testroot/stdout.expected
$testroot/stdout
663 test_done
"$testroot" "$ret"
667 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
669 if [ $ret -ne 0 ]; then
670 echo "got ref command failed unexpectedly" >&2
671 test_done
"$testroot" "$ret"
675 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
676 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
677 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
678 >> $testroot/stdout.expected
679 echo "refs/remotes/origin/master: $commit_id" \
680 >> $testroot/stdout.expected
681 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
682 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
684 cmp -s $testroot/stdout
$testroot/stdout.expected
686 if [ $ret -ne 0 ]; then
687 diff -u $testroot/stdout.expected
$testroot/stdout
688 test_done
"$testroot" "$ret"
692 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
693 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
694 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
695 cmp -s $testroot/stdout
$testroot/stdout.expected
697 if [ $ret -ne 0 ]; then
698 diff -u $testroot/stdout.expected
$testroot/stdout
699 test_done
"$testroot" "$ret"
703 # Send the same tags again. This should be a no-op.
704 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
706 if [ $ret -ne 0 ]; then
707 echo "got send command failed unexpectedly" >&2
708 test_done
"$testroot" "$ret"
712 echo -n > $testroot/stdout.expected
713 cmp -s $testroot/stdout
$testroot/stdout.expected
715 if [ $ret -ne 0 ]; then
716 diff -u $testroot/stdout.expected
$testroot/stdout
717 test_done
"$testroot" "$ret"
721 # Overwriting an existing tag 'got send -f'.
722 got ref
-r $testroot/repo
-d refs
/tags
/1.0 >/dev
/null
723 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
724 tag_id3
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
725 | tr -d ' ' | cut -d: -f2`
727 got send
-q -r $testroot/repo
-t 1.0 > $testroot/stdout \
730 if [ $ret -eq 0 ]; then
731 echo "got send command succeeded unexpectedly" >&2
732 test_done
"$testroot" 1
736 echo "got: refs/tags/1.0: tag already exists on server" \
737 > $testroot/stderr.expected
738 cmp -s $testroot/stderr
$testroot/stderr.expected
740 if [ $ret -ne 0 ]; then
741 diff -u $testroot/stderr.expected
$testroot/stderr
742 test_done
"$testroot" "$ret"
746 # attempting the same with -T should fail, too
747 got send
-q -r $testroot/repo
-T > $testroot/stdout \
750 if [ $ret -eq 0 ]; then
751 echo "got send command succeeded unexpectedly" >&2
752 test_done
"$testroot" 1
756 echo "got: refs/tags/1.0: tag already exists on server" \
757 > $testroot/stderr.expected
758 cmp -s $testroot/stderr
$testroot/stderr.expected
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stderr.expected
$testroot/stderr
762 test_done
"$testroot" "$ret"
766 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
767 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
768 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
769 cmp -s $testroot/stdout
$testroot/stdout.expected
771 if [ $ret -ne 0 ]; then
772 diff -u $testroot/stdout.expected
$testroot/stdout
773 test_done
"$testroot" "$ret"
777 # overwrite the 1.0 tag only
778 got send
-q -r $testroot/repo
-t 1.0 -f > $testroot/stdout \
781 if [ $ret -ne 0 ]; then
782 echo "got send command failed unexpectedly" >&2
783 test_done
"$testroot" "$ret"
787 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
788 echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
789 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
790 cmp -s $testroot/stdout
$testroot/stdout.expected
792 if [ $ret -ne 0 ]; then
793 diff -u $testroot/stdout.expected
$testroot/stdout
794 test_done
"$testroot" "$ret"
798 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
799 echo 'new line in file alpha' >> $testroot/wt
/alpha
800 (cd $testroot/wt
&& got commit
-m 'changing file alpha' > /dev
/null
)
802 # Send the new commit in isolation.
803 got send
-q -r $testroot/repo
> $testroot/stdout \
806 if [ $ret -ne 0 ]; then
807 echo "got send command failed unexpectedly" >&2
808 test_done
"$testroot" "$ret"
812 # Now tag it and send the tag.
813 # Verify that just the new tag object gets sent.
814 got tag
-r $testroot/repo
-m '3.0' 3.0 >/dev
/null
815 tag_id4
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
816 | tr -d ' ' | cut -d: -f2`
818 got send
-r $testroot/repo
-t 3.0 > $testroot/stdout.raw \
821 if [ $ret -ne 0 ]; then
822 echo "got send command failed unexpectedly" >&2
823 test_done
"$testroot" "$ret"
826 tr -d '\r' < $testroot/stdout.raw
> $testroot/stdout
827 if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
828 $testroot/stdout
; then
829 echo "got send did apparently pack too many objects:" >&2
830 cat $testroot/stdout.raw
>&2
831 test_done
"$testroot" "1"
835 git_fsck
"$testroot" "$testroot/repo-clone"
837 test_done
"$testroot" "$ret"
840 test_send_tag_of_deleted_branch
() {
841 local testroot
=`test_init send_tag_of_deleted_branch`
842 local testurl
=ssh://127.0.0.1/$testroot
843 local commit_id
=`git_show_head $testroot/repo`
845 got clone
-q $testurl/repo
$testroot/repo-clone
847 if [ $ret -ne 0 ]; then
848 echo "got clone command failed unexpectedly" >&2
849 test_done
"$testroot" "$ret"
852 cat > $testroot/repo
/.git
/got.conf
<<EOF
856 repository "$testroot/repo-clone"
859 got branch
-r $testroot/repo foo
861 # modify beta on branch foo
862 got checkout
-b foo
$testroot/repo
$testroot/wt
> /dev
/null
863 echo boo
>> $testroot/wt
/beta
864 (cd $testroot/wt
&& got commit
-m 'changed beta on branch foo' \
866 echo buu
>> $testroot/wt
/beta
867 (cd $testroot/wt
&& got commit
-m 'changed beta again on branch foo' \
869 echo baa
>> $testroot/wt
/beta
870 (cd $testroot/wt
&& got commit
-m 'changed beta again on branch foo' \
872 local commit_id2
=`git_show_branch_head $testroot/repo foo`
874 # tag HEAD commit of branch foo
875 got tag
-r $testroot/repo
-c foo
-m '1.0' 1.0 > /dev
/null
876 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
877 | tr -d ' ' | cut -d: -f2`
879 # delete the branch; commit is now only reachable via tags/1.0
880 got branch
-r $testroot/repo
-d foo
> /dev
/null
882 # unrelated change on master branch, then try sending this branch
884 echo "modified alpha" > $testroot/repo
/alpha
885 git_commit
$testroot/repo
-m "modified alpha"
886 local commit_id3
=`git_show_head $testroot/repo`
888 got send
-q -r $testroot/repo
-T > $testroot/stdout
2> $testroot/stderr
890 if [ $ret -ne 0 ]; then
891 echo "got send command failed unexpectedly" >&2
892 test_done
"$testroot" "$ret"
896 echo -n > $testroot/stdout.expected
897 cmp -s $testroot/stdout
$testroot/stdout.expected
899 if [ $ret -ne 0 ]; then
900 diff -u $testroot/stdout.expected
$testroot/stdout
901 test_done
"$testroot" "$ret"
905 got ref
-l -r $testroot/repo
> $testroot/stdout
907 if [ $ret -ne 0 ]; then
908 echo "got ref command failed unexpectedly" >&2
909 test_done
"$testroot" "$ret"
913 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
914 cut -d ':' -f 2 | tr -d ' ')`
915 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
916 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
917 >> $testroot/stdout.expected
918 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
919 echo "refs/remotes/origin/master: $commit_id3" \
920 >> $testroot/stdout.expected
921 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
923 cmp -s $testroot/stdout
$testroot/stdout.expected
925 if [ $ret -ne 0 ]; then
926 diff -u $testroot/stdout.expected
$testroot/stdout
927 test_done
"$testroot" "$ret"
931 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
933 if [ $ret -ne 0 ]; then
934 echo "got ref command failed unexpectedly" >&2
935 test_done
"$testroot" "$ret"
939 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
940 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
941 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
942 >> $testroot/stdout.expected
943 echo "refs/remotes/origin/master: $commit_id" \
944 >> $testroot/stdout.expected
945 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
947 cmp -s $testroot/stdout
$testroot/stdout.expected
949 if [ $ret -ne 0 ]; then
950 diff -u $testroot/stdout.expected
$testroot/stdout
951 test_done
"$testroot" "$ret"
955 got tag
-l -r $testroot/repo-clone |
grep ^tag |
sort > $testroot/stdout
956 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
958 cmp -s $testroot/stdout
$testroot/stdout.expected
960 if [ $ret -ne 0 ]; then
961 diff -u $testroot/stdout.expected
$testroot/stdout
962 test_done
"$testroot" "$ret"
966 git_fsck
"$testroot" "$testroot/repo-clone"
968 test_done
"$testroot" "$ret"
971 test_send_new_branch
() {
972 local testroot
=`test_init send_new_branch`
973 local testurl
=ssh://127.0.0.1/$testroot
974 local commit_id
=`git_show_head $testroot/repo`
976 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
978 got clone
-q $testurl/repo
$testroot/repo-clone
980 if [ $ret -ne 0 ]; then
981 echo "got clone command failed unexpectedly" >&2
982 test_done
"$testroot" "$ret"
986 got branch
-r $testroot/repo-clone foo
>/dev
/null
987 got checkout
-b foo
$testroot/repo-clone
$testroot/wt
>/dev
/null
988 echo "modified alpha" > $testroot/wt
/alpha
989 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
990 local commit_id2
=`git_show_branch_head $testroot/repo-clone foo`
992 (cd $testroot/wt
&& got send
-q > $testroot/stdout
2> $testroot/stderr
)
994 if [ $ret -ne 0 ]; then
995 echo "got send command failed unexpectedly" >&2
996 test_done
"$testroot" "$ret"
1000 echo -n > $testroot/stdout.expected
1001 cmp -s $testroot/stdout
$testroot/stdout.expected
1003 if [ $ret -ne 0 ]; then
1004 diff -u $testroot/stdout.expected
$testroot/stdout
1005 test_done
"$testroot" "$ret"
1009 got ref
-l -r $testroot/repo
> $testroot/stdout
1011 if [ $ret -ne 0 ]; then
1012 echo "got ref command failed unexpectedly" >&2
1013 test_done
"$testroot" "$ret"
1017 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1018 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1019 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1021 cmp -s $testroot/stdout
$testroot/stdout.expected
1023 if [ $ret -ne 0 ]; then
1024 diff -u $testroot/stdout.expected
$testroot/stdout
1025 test_done
"$testroot" "$ret"
1029 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1031 if [ $ret -ne 0 ]; then
1032 echo "got ref command failed unexpectedly" >&2
1033 test_done
"$testroot" "$ret"
1037 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
1038 cut -d ':' -f 2 | tr -d ' ')`
1039 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1040 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1041 >> $testroot/stdout.expected
1042 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1043 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1044 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1045 >> $testroot/stdout.expected
1046 echo "refs/remotes/origin/foo: $commit_id2" \
1047 >> $testroot/stdout.expected
1048 echo "refs/remotes/origin/master: $commit_id" \
1049 >> $testroot/stdout.expected
1051 cmp -s $testroot/stdout
$testroot/stdout.expected
1053 if [ $ret -ne 0 ]; then
1054 diff -u $testroot/stdout.expected
$testroot/stdout
1055 test_done
"$testroot" "$ret"
1059 git_fsck
"$testroot" "$testroot/repo-clone"
1061 test_done
"$testroot" "$ret"
1064 test_send_all_branches
() {
1065 local testroot
=`test_init send_all_branches`
1066 local testurl
=ssh://127.0.0.1/$testroot
1067 local commit_id
=`git_show_head $testroot/repo`
1069 (cd $testroot/repo
&& git config receive.denyCurrentBranch ignore
)
1071 got clone
-q $testurl/repo
$testroot/repo-clone
1073 if [ $ret -ne 0 ]; then
1074 echo "got clone command failed unexpectedly" >&2
1075 test_done
"$testroot" "$ret"
1079 got checkout
$testroot/repo-clone
$testroot/wt
>/dev
/null
1080 echo "modified alpha" > $testroot/wt
/alpha
1081 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
1082 local commit_id2
=`git_show_head $testroot/repo-clone`
1084 got branch
-r $testroot/repo-clone foo
>/dev
/null
1085 (cd $testroot/wt
&& got update
-b foo
>/dev
/null
)
1086 echo "modified beta on new branch foo" > $testroot/wt
/beta
1087 (cd $testroot/wt
&& got commit
-m "modified beta" >/dev
/null
)
1088 local commit_id3
=`git_show_branch_head $testroot/repo-clone foo`
1090 got branch
-r $testroot/repo-clone bar
>/dev
/null
1091 (cd $testroot/wt
&& got update
-b bar
>/dev
/null
)
1092 echo "modified beta again on new branch bar" > $testroot/wt
/beta
1093 (cd $testroot/wt
&& got commit
-m "modified beta" >/dev
/null
)
1094 local commit_id4
=`git_show_branch_head $testroot/repo-clone bar`
1096 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1098 if [ $ret -ne 0 ]; then
1099 echo "got ref command failed unexpectedly" >&2
1100 test_done
"$testroot" "$ret"
1104 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1105 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1106 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1107 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1109 got send
-a -q -r $testroot/repo-clone
-b master
> $testroot/stdout \
1112 if [ $ret -eq 0 ]; then
1113 echo "got send command succeeded unexpectedly" >&2
1114 test_done
"$testroot" 1
1117 echo "got: -a and -b options are mutually exclusive" \
1118 > $testroot/stderr.expected
1119 cmp -s $testroot/stderr
$testroot/stderr.expected
1121 if [ $ret -ne 0 ]; then
1122 diff -u $testroot/stderr.expected
$testroot/stderr
1123 test_done
"$testroot" "$ret"
1127 got send
-a -q -r $testroot/repo-clone
> $testroot/stdout \
1130 if [ $ret -ne 0 ]; then
1131 echo "got send command failed unexpectedly" >&2
1132 test_done
"$testroot" "$ret"
1136 echo -n > $testroot/stdout.expected
1137 cmp -s $testroot/stdout
$testroot/stdout.expected
1139 if [ $ret -ne 0 ]; then
1140 diff -u $testroot/stdout.expected
$testroot/stdout
1141 test_done
"$testroot" "$ret"
1145 got ref
-l -r $testroot/repo
> $testroot/stdout
1147 if [ $ret -ne 0 ]; then
1148 echo "got ref command failed unexpectedly" >&2
1149 test_done
"$testroot" "$ret"
1153 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1154 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1155 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1156 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1158 cmp -s $testroot/stdout
$testroot/stdout.expected
1160 if [ $ret -ne 0 ]; then
1161 diff -u $testroot/stdout.expected
$testroot/stdout
1162 test_done
"$testroot" "$ret"
1166 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1168 if [ $ret -ne 0 ]; then
1169 echo "got ref command failed unexpectedly" >&2
1170 test_done
"$testroot" "$ret"
1174 wt_uuid
=`(cd $testroot/wt && got info | grep 'UUID:' | \
1175 cut -d ':' -f 2 | tr -d ' ')`
1176 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1177 echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1178 >> $testroot/stdout.expected
1179 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1180 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1181 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1182 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1183 >> $testroot/stdout.expected
1184 echo "refs/remotes/origin/bar: $commit_id4" \
1185 >> $testroot/stdout.expected
1186 echo "refs/remotes/origin/foo: $commit_id3" \
1187 >> $testroot/stdout.expected
1188 echo "refs/remotes/origin/master: $commit_id2" \
1189 >> $testroot/stdout.expected
1191 cmp -s $testroot/stdout
$testroot/stdout.expected
1193 if [ $ret -ne 0 ]; then
1194 diff -u $testroot/stdout.expected
$testroot/stdout
1195 test_done
"$testroot" "$ret"
1199 git_fsck
"$testroot" "$testroot/repo-clone"
1201 test_done
"$testroot" "$ret"
1204 test_send_to_empty_repo
() {
1205 local testroot
=`test_init send_to_empty_repo`
1206 local testurl
=ssh://127.0.0.1/$testroot
1207 local commit_id
=`git_show_head $testroot/repo`
1209 gotadmin init
$testroot/repo2
1212 if [ $ret -ne 0 ]; then
1213 echo "got clone command failed unexpectedly" >&2
1214 test_done
"$testroot" "$ret"
1217 cat > $testroot/repo
/.git
/got.conf
<<EOF
1221 repository "$testroot/repo2"
1224 echo "modified alpha" > $testroot/repo
/alpha
1225 git_commit
$testroot/repo
-m "modified alpha"
1226 local commit_id2
=`git_show_head $testroot/repo`
1228 got send
-q -r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1230 if [ $ret -ne 0 ]; then
1231 echo "got send command failed unexpectedly" >&2
1232 test_done
"$testroot" "$ret"
1236 echo -n > $testroot/stdout.expected
1237 cmp -s $testroot/stdout
$testroot/stdout.expected
1239 if [ $ret -ne 0 ]; then
1240 diff -u $testroot/stdout.expected
$testroot/stdout
1241 test_done
"$testroot" "$ret"
1245 # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1246 got ref
-r $testroot/repo2
-s refs
/heads
/master HEAD
1248 got ref
-l -r $testroot/repo
> $testroot/stdout
1250 if [ $ret -ne 0 ]; then
1251 echo "got ref command failed unexpectedly" >&2
1252 test_done
"$testroot" "$ret"
1256 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1257 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1258 echo "refs/remotes/origin/master: $commit_id2" \
1259 >> $testroot/stdout.expected
1261 cmp -s $testroot/stdout
$testroot/stdout.expected
1263 if [ $ret -ne 0 ]; then
1264 diff -u $testroot/stdout.expected
$testroot/stdout
1265 test_done
"$testroot" "$ret"
1269 got ref
-l -r $testroot/repo2
> $testroot/stdout
1271 if [ $ret -ne 0 ]; then
1272 echo "got ref command failed unexpectedly" >&2
1273 test_done
"$testroot" "$ret"
1277 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1278 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1280 cmp -s $testroot/stdout
$testroot/stdout.expected
1282 if [ $ret -ne 0 ]; then
1283 diff -u $testroot/stdout.expected
$testroot/stdout
1284 test_done
"$testroot" "$ret"
1288 got send
-r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1290 if [ $ret -ne 0 ]; then
1291 echo "got send command failed unexpectedly" >&2
1292 test_done
"$testroot" "$ret"
1296 echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1297 > $testroot/stdout.expected
1298 echo "Already up-to-date" >> $testroot/stdout.expected
1299 cmp -s $testroot/stdout
$testroot/stdout.expected
1301 if [ $ret -ne 0 ]; then
1302 diff -u $testroot/stdout.expected
$testroot/stdout
1303 test_done
"$testroot" "$ret"
1307 git_fsck
"$testroot" "$testroot/repo2"
1309 test_done
"$testroot" "$ret"
1312 test_send_and_fetch_config
() {
1313 local testroot
=`test_init send_fetch_conf`
1314 local testurl
=ssh://127.0.0.1/$testroot
1315 local commit_id
=`git_show_head $testroot/repo`
1317 got clone
-q $testurl/repo
$testroot/repo-clone
1319 if [ $ret -ne 0 ]; then
1320 echo "got clone command failed unexpectedly" >&2
1321 test_done
"$testroot" "$ret"
1325 got tag
-r $testroot/repo
-m '1.0' 1.0 >/dev
/null
1326 tag_id
=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1327 | tr -d ' ' | cut -d: -f2`
1329 cp -R $testroot/repo-clone
$testroot/repo-clone2
1330 got tag
-r $testroot/repo-clone2
-m '2.0' 2.0 >/dev
/null
1331 tag_id2
=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1332 | tr -d ' ' | cut -d: -f2`
1334 cat > $testroot/repo
/.git
/got.conf
<<EOF
1339 repository "$testroot/repo-clone"
1342 repository "$testroot/repo-clone2"
1346 got ref
-l -r $testroot/repo
> $testroot/stdout
1348 if [ $ret -ne 0 ]; then
1349 echo "got ref command failed unexpectedly" >&2
1350 test_done
"$testroot" "$ret"
1354 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1355 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1356 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1357 cmp -s $testroot/stdout
$testroot/stdout.expected
1359 if [ $ret -ne 0 ]; then
1360 diff -u $testroot/stdout.expected
$testroot/stdout
1361 test_done
"$testroot" "$ret"
1365 # fetch tag 2.0 from repo-clone2
1366 got fetch
-q -r $testroot/repo
> $testroot/stdout
1368 if [ $ret -ne 0 ]; then
1369 echo "got fetch command failed unexpectedly" >&2
1370 test_done
"$testroot" "$ret"
1374 got ref
-l -r $testroot/repo
> $testroot/stdout
1376 if [ $ret -ne 0 ]; then
1377 echo "got ref command failed unexpectedly" >&2
1378 test_done
"$testroot" "$ret"
1382 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1383 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1384 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1385 >> $testroot/stdout.expected
1386 echo "refs/remotes/origin/master: $commit_id" \
1387 >> $testroot/stdout.expected
1388 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1389 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1390 cmp -s $testroot/stdout
$testroot/stdout.expected
1392 if [ $ret -ne 0 ]; then
1393 diff -u $testroot/stdout.expected
$testroot/stdout
1394 test_done
"$testroot" "$ret"
1398 # send tag 1.0 to repo-clone
1399 got send
-q -r $testroot/repo
-t 1.0 > $testroot/stdout
1401 if [ $ret -ne 0 ]; then
1402 echo "got send command failed unexpectedly" >&2
1403 test_done
"$testroot" "$ret"
1407 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1409 if [ $ret -ne 0 ]; then
1410 echo "got ref command failed unexpectedly" >&2
1411 test_done
"$testroot" "$ret"
1415 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1416 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1417 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1418 >> $testroot/stdout.expected
1419 echo "refs/remotes/origin/master: $commit_id" \
1420 >> $testroot/stdout.expected
1421 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1423 cmp -s $testroot/stdout
$testroot/stdout.expected
1425 if [ $ret -ne 0 ]; then
1426 diff -u $testroot/stdout.expected
$testroot/stdout
1427 test_done
"$testroot" "$ret"
1431 git_fsck
"$testroot" "$testroot/repo-clone"
1433 test_done
"$testroot" "$ret"
1436 test_send_config
() {
1437 local testroot
=`test_init send_fetch_conf`
1438 local testurl
=ssh://127.0.0.1/$testroot
1439 local commit_id
=`git_show_head $testroot/repo`
1441 got clone
-q $testurl/repo
$testroot/repo-clone
1443 if [ $ret -ne 0 ]; then
1444 echo "got clone command failed unexpectedly" >&2
1445 test_done
"$testroot" "$ret"
1449 cat > $testroot/repo
/.git
/got.conf
<<EOF
1454 repository "$testroot/repo-clone"
1457 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1459 if [ $ret -ne 0 ]; then
1460 echo "got ref command failed unexpectedly" >&2
1461 test_done
"$testroot" "$ret"
1465 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1466 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1467 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1468 >> $testroot/stdout.expected
1469 echo "refs/remotes/origin/master: $commit_id" \
1470 >> $testroot/stdout.expected
1472 cmp -s $testroot/stdout
$testroot/stdout.expected
1474 if [ $ret -ne 0 ]; then
1475 diff -u $testroot/stdout.expected
$testroot/stdout
1476 test_done
"$testroot" "$ret"
1480 got branch
-r $testroot/repo foo
1482 got send
-q -r $testroot/repo
> $testroot/stdout
2> $testroot/stderr
1484 if [ $ret -ne 0 ]; then
1485 echo "got send command failed unexpectedly" >&2
1486 test_done
"$testroot" "$ret"
1490 got ref
-l -r $testroot/repo-clone
> $testroot/stdout
1492 if [ $ret -ne 0 ]; then
1493 echo "got ref command failed unexpectedly" >&2
1494 test_done
"$testroot" "$ret"
1498 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1499 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1500 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1501 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1502 >> $testroot/stdout.expected
1503 echo "refs/remotes/origin/master: $commit_id" \
1504 >> $testroot/stdout.expected
1506 cmp -s $testroot/stdout
$testroot/stdout.expected
1508 if [ $ret -ne 0 ]; then
1509 diff -u $testroot/stdout.expected
$testroot/stdout
1510 test_done
"$testroot" "$ret"
1514 git_fsck
"$testroot" "$testroot/repo-clone"
1516 test_done
"$testroot" "$ret"
1519 test_send_rejected
() {
1520 local testroot
=`test_init send_rejected`
1521 local testurl
=ssh://127.0.0.1/$testroot
1522 local commit_id
=`git_show_head $testroot/repo`
1524 if ! got clone
-q "$testurl/repo" "$testroot/repo-clone"; then
1525 echo "got clone command failed unexpectedly" >&2
1526 test_done
"$testroot" 1
1530 mkdir
"$testroot/repo-clone/hooks"
1531 cat <<'EOF' >$testroot/repo-clone/hooks/update
1534 echo "rejecting push on master branch"
1540 chmod +x
"$testroot/repo-clone/hooks/update"
1542 cat > $testroot/repo
/.git
/got.conf
<<EOF
1546 repository "$testroot/repo-clone"
1550 echo "modified alpha" >$testroot/repo
/alpha
1551 git_commit
"$testroot/repo" -m "modified alpha"
1553 got send
-q -r "$testroot/repo" >$testroot/stdout
2>$testroot/stderr
1555 if [ $ret -ne 0 ]; then
1556 echo "got send command failed unexpectedly" >&2
1557 test_done
"$testroot" $ret
1561 touch "$testroot/stdout.expected"
1562 if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1563 diff -u "$testroot/stdout.expected" "$testroot/stdout"
1564 test_done
"$testroot" 1
1568 cat <<EOF >$testroot/stderr.expected
1569 rejecting push on master branch
1570 error: hook declined to update refs/heads/master
1573 if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1574 diff -u "$testroot/stderr.expected" "$testroot/stderr"
1575 test_done
"$testroot" 1
1579 test_done
"$testroot" 0
1583 run_test test_send_basic
1584 run_test test_send_rebase_required
1585 run_test test_send_rebase_required_overwrite
1586 run_test test_send_delete
1587 run_test test_send_clone_and_send
1588 run_test test_send_tags
1589 run_test test_send_tag_of_deleted_branch
1590 run_test test_send_new_branch
1591 run_test test_send_all_branches
1592 run_test test_send_to_empty_repo
1593 run_test test_send_and_fetch_config
1594 run_test test_send_config
1595 run_test test_send_rejected