Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_send_basic() {
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
25 ret="$?"
26 if [ "$ret" != "0" ]; then
27 echo "got clone command failed unexpectedly" >&2
28 test_done "$testroot" "$ret"
29 return 1
30 fi
31 cat > $testroot/repo/.git/got.conf <<EOF
32 remote "origin" {
33 protocol ssh
34 server 127.0.0.1
35 repository "$testroot/repo-clone"
36 }
37 EOF
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 git_commit $testroot/repo -m "modified alpha"
44 local commit_id2=`git_show_head $testroot/repo`
46 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
47 ret="$?"
48 if [ "$ret" != "0" ]; then
49 echo "got send command failed unexpectedly" >&2
50 test_done "$testroot" "$ret"
51 return 1
52 fi
54 echo -n > $testroot/stdout.expected
55 cmp -s $testroot/stdout $testroot/stdout.expected
56 ret="$?"
57 if [ "$ret" != "0" ]; then
58 diff -u $testroot/stdout.expected $testroot/stdout
59 test_done "$testroot" "$ret"
60 return 1
61 fi
63 got ref -l -r $testroot/repo > $testroot/stdout
64 if [ "$ret" != "0" ]; then
65 echo "got ref command failed unexpectedly" >&2
66 test_done "$testroot" "$ret"
67 return 1
68 fi
70 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
71 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
72 echo "refs/remotes/origin/master: $commit_id2" \
73 >> $testroot/stdout.expected
74 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
76 cmp -s $testroot/stdout $testroot/stdout.expected
77 ret="$?"
78 if [ "$ret" != "0" ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
80 test_done "$testroot" "$ret"
81 return 1
82 fi
84 got ref -l -r $testroot/repo-clone > $testroot/stdout
85 if [ "$ret" != "0" ]; then
86 echo "got ref command failed unexpectedly" >&2
87 test_done "$testroot" "$ret"
88 return 1
89 fi
91 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
92 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
93 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
94 >> $testroot/stdout.expected
95 echo "refs/remotes/origin/master: $commit_id" \
96 >> $testroot/stdout.expected
98 cmp -s $testroot/stdout $testroot/stdout.expected
99 ret="$?"
100 if [ "$ret" != "0" ]; then
101 diff -u $testroot/stdout.expected $testroot/stdout
102 test_done "$testroot" "$ret"
103 return 1
104 fi
106 got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
107 ret="$?"
108 if [ "$ret" != "0" ]; then
109 echo "got send command failed unexpectedly" >&2
110 test_done "$testroot" "$ret"
111 return 1
112 fi
114 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
115 echo "Already up-to-date" >> $testroot/stdout.expected
116 cmp -s $testroot/stdout $testroot/stdout.expected
117 ret="$?"
118 if [ "$ret" != "0" ]; then
119 diff -u $testroot/stdout.expected $testroot/stdout
120 fi
121 test_done "$testroot" "$ret"
124 test_send_rebase_required() {
125 local testroot=`test_init send_rebase_required`
126 local testurl=ssh://127.0.0.1/$testroot
127 local commit_id=`git_show_head $testroot/repo`
129 got clone -q $testurl/repo $testroot/repo-clone
130 ret="$?"
131 if [ "$ret" != "0" ]; then
132 echo "got clone command failed unexpectedly" >&2
133 test_done "$testroot" "$ret"
134 return 1
135 fi
136 cat > $testroot/repo/.git/got.conf <<EOF
137 remote "origin" {
138 protocol ssh
139 server 127.0.0.1
140 repository "$testroot/repo-clone"
142 EOF
143 echo "modified alpha" > $testroot/repo/alpha
144 git_commit $testroot/repo -m "modified alpha"
145 local commit_id2=`git_show_head $testroot/repo`
147 got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
148 echo "modified alpha, too" > $testroot/wt-clone/alpha
149 (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
151 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
152 ret="$?"
153 if [ "$ret" = "0" ]; then
154 echo "got send command succeeded unexpectedly" >&2
155 test_done "$testroot" "$ret"
156 return 1
157 fi
159 echo -n > $testroot/stdout.expected
160 cmp -s $testroot/stdout $testroot/stdout.expected
161 ret="$?"
162 if [ "$ret" != "0" ]; then
163 diff -u $testroot/stdout.expected $testroot/stdout
164 test_done "$testroot" "$ret"
165 return 1
166 fi
168 echo "got: refs/heads/master: fetch and rebase required" \
169 > $testroot/stderr.expected
170 cmp -s $testroot/stderr $testroot/stderr.expected
171 ret="$?"
172 if [ "$ret" != "0" ]; then
173 diff -u $testroot/stderr.expected $testroot/stderr
174 fi
175 test_done "$testroot" "$ret"
178 test_send_rebase_required_overwrite() {
179 local testroot=`test_init send_rebase_required_overwrite`
180 local testurl=ssh://127.0.0.1/$testroot
181 local commit_id=`git_show_head $testroot/repo`
183 got clone -q $testurl/repo $testroot/repo-clone
184 ret="$?"
185 if [ "$ret" != "0" ]; then
186 echo "got clone command failed unexpectedly" >&2
187 test_done "$testroot" "$ret"
188 return 1
189 fi
190 cat > $testroot/repo/.git/got.conf <<EOF
191 remote "foobar" {
192 protocol ssh
193 server 127.0.0.1
194 repository "$testroot/repo-clone"
196 EOF
197 echo "modified alpha" > $testroot/repo/alpha
198 git_commit $testroot/repo -m "modified alpha"
199 local commit_id2=`git_show_head $testroot/repo`
201 got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
202 echo "modified alpha, too" > $testroot/wt-clone/alpha
203 (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
204 local commit_id3=`git_show_head $testroot/repo-clone`
206 # non-default remote requires an explicit argument
207 got send -q -r $testroot/repo -f > $testroot/stdout \
208 2> $testroot/stderr
209 ret="$?"
210 if [ "$ret" = "0" ]; then
211 echo "got send command succeeded unexpectedly" >&2
212 test_done "$testroot" "$ret"
213 return 1
214 fi
215 echo "got: origin: remote repository not found" \
216 > $testroot/stderr.expected
217 cmp -s $testroot/stderr $testroot/stderr.expected
218 ret="$?"
219 if [ "$ret" != "0" ]; then
220 diff -u $testroot/stderr.expected $testroot/stderr
221 test_done "$testroot" "$ret"
222 return 1
223 fi
225 got send -q -r $testroot/repo -f foobar > $testroot/stdout \
226 2> $testroot/stderr
227 ret="$?"
228 if [ "$ret" != "0" ]; then
229 echo "got send command failed unexpectedly" >&2
230 test_done "$testroot" "$ret"
231 return 1
232 fi
234 echo -n > $testroot/stdout.expected
235 cmp -s $testroot/stdout $testroot/stdout.expected
236 ret="$?"
237 if [ "$ret" != "0" ]; then
238 diff -u $testroot/stdout.expected $testroot/stdout
239 test_done "$testroot" "$ret"
240 return 1
241 fi
243 got ref -l -r $testroot/repo > $testroot/stdout
244 if [ "$ret" != "0" ]; then
245 echo "got ref command failed unexpectedly" >&2
246 test_done "$testroot" "$ret"
247 return 1
248 fi
250 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
251 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
252 echo "refs/remotes/foobar/master: $commit_id2" \
253 >> $testroot/stdout.expected
255 cmp -s $testroot/stdout $testroot/stdout.expected
256 ret="$?"
257 if [ "$ret" != "0" ]; then
258 diff -u $testroot/stdout.expected $testroot/stdout
259 test_done "$testroot" "$ret"
260 return 1
261 fi
263 got ref -l -r $testroot/repo-clone > $testroot/stdout
264 if [ "$ret" != "0" ]; then
265 echo "got ref command failed unexpectedly" >&2
266 test_done "$testroot" "$ret"
267 return 1
268 fi
270 wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
271 cut -d ':' -f 2 | tr -d ' ')`
272 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
273 echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
274 >> $testroot/stdout.expected
275 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
276 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
277 >> $testroot/stdout.expected
278 echo "refs/remotes/origin/master: $commit_id" \
279 >> $testroot/stdout.expected
281 cmp -s $testroot/stdout $testroot/stdout.expected
282 ret="$?"
283 if [ "$ret" != "0" ]; then
284 diff -u $testroot/stdout.expected $testroot/stdout
285 fi
286 test_done "$testroot" "$ret"
289 test_send_delete() {
290 local testroot=`test_init send_delete`
291 local testurl=ssh://127.0.0.1/$testroot
292 local commit_id=`git_show_head $testroot/repo`
294 # branch1 exists in both repositories
295 got branch -r $testroot/repo branch1
297 got clone -a -q $testurl/repo $testroot/repo-clone
298 ret="$?"
299 if [ "$ret" != "0" ]; then
300 echo "got clone command failed unexpectedly" >&2
301 test_done "$testroot" "$ret"
302 return 1
303 fi
304 cat > $testroot/repo/.git/got.conf <<EOF
305 remote "origin" {
306 protocol ssh
307 server 127.0.0.1
308 repository "$testroot/repo-clone"
310 EOF
311 # branch2 exists only in the remote repository
312 got branch -r $testroot/repo-clone branch2
314 got ref -l -r $testroot/repo-clone > $testroot/stdout
315 if [ "$ret" != "0" ]; then
316 echo "got ref command failed unexpectedly" >&2
317 test_done "$testroot" "$ret"
318 return 1
319 fi
321 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
322 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
323 echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
324 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
326 # Sending changes for a branch and deleting it at the same
327 # time is not allowed.
328 got send -q -r $testroot/repo -d branch1 -b branch1 \
329 > $testroot/stdout 2> $testroot/stderr
330 ret="$?"
331 if [ "$ret" = "0" ]; then
332 echo "got send command succeeded unexpectedly" >&2
333 test_done "$testroot" "$ret"
334 return 1
335 fi
336 echo -n "got: changes on refs/heads/branch1 will be sent to server" \
337 > $testroot/stderr.expected
338 echo ": reference cannot be deleted" >> $testroot/stderr.expected
339 cmp -s $testroot/stderr $testroot/stderr.expected
340 ret="$?"
341 if [ "$ret" != "0" ]; then
342 diff -u $testroot/stderr.expected $testroot/stderr
343 test_done "$testroot" "$ret"
344 return 1
345 fi
347 got send -q -r $testroot/repo -d refs/heads/branch1 origin \
348 > $testroot/stdout 2> $testroot/stderr
349 ret="$?"
350 if [ "$ret" != "0" ]; then
351 echo "got send command failed unexpectedly" >&2
352 test_done "$testroot" "$ret"
353 return 1
354 fi
356 got send -r $testroot/repo -d refs/heads/branch2 origin \
357 > $testroot/stdout 2>$testroot/stderr
358 ret="$?"
359 if [ "$ret" != "0" ]; then
360 echo "got send command failed unexpectedly" >&2
361 test_done "$testroot" "$ret"
362 return 1
363 fi
365 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
366 echo "Server has deleted refs/heads/branch2" \
367 >> $testroot/stdout.expected
369 cmp -s $testroot/stdout $testroot/stdout.expected
370 ret="$?"
371 if [ "$ret" != "0" ]; then
372 diff -u $testroot/stdout.expected $testroot/stdout
373 test_done "$testroot" "$ret"
374 return 1
375 fi
377 # branchX exists in neither repository
378 got send -q -r $testroot/repo -d refs/heads/branchX origin \
379 > $testroot/stdout 2> $testroot/stderr
380 ret="$?"
381 if [ "$ret" = "0" ]; then
382 echo "got send command succeeded unexpectedly" >&2
383 test_done "$testroot" "$ret"
384 return 1
385 fi
386 echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
387 > $testroot/stderr.expected
388 echo "repository: no such reference found" >> $testroot/stderr.expected
389 echo "got: no such reference found" >> $testroot/stderr.expected
390 cmp -s $testroot/stderr $testroot/stderr.expected
391 ret="$?"
392 if [ "$ret" != "0" ]; then
393 diff -u $testroot/stderr.expected $testroot/stderr
394 test_done "$testroot" "$ret"
395 return 1
396 fi
398 # References outside of refs/heads/ cannot be deleted with 'got send'.
399 got send -q -r $testroot/repo -d refs/tags/1.0 origin \
400 > $testroot/stdout 2> $testroot/stderr
401 ret="$?"
402 if [ "$ret" = "0" ]; then
403 echo "got send command succeeded unexpectedly" >&2
404 test_done "$testroot" "$ret"
405 return 1
406 fi
407 echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
408 > $testroot/stderr.expected
409 echo "in remote repository: no such reference found" \
410 >> $testroot/stderr.expected
411 echo "got: no such reference found" >> $testroot/stderr.expected
412 cmp -s $testroot/stderr $testroot/stderr.expected
413 ret="$?"
414 if [ "$ret" != "0" ]; then
415 diff -u $testroot/stderr.expected $testroot/stderr
416 test_done "$testroot" "$ret"
417 return 1
418 fi
420 got ref -l -r $testroot/repo > $testroot/stdout
421 if [ "$ret" != "0" ]; then
422 echo "got ref command failed unexpectedly" >&2
423 test_done "$testroot" "$ret"
424 return 1
425 fi
427 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
428 echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
429 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
431 cmp -s $testroot/stdout $testroot/stdout.expected
432 ret="$?"
433 if [ "$ret" != "0" ]; then
434 diff -u $testroot/stdout.expected $testroot/stdout
435 test_done "$testroot" "$ret"
436 return 1
437 fi
439 got ref -l -r $testroot/repo-clone > $testroot/stdout
440 if [ "$ret" != "0" ]; then
441 echo "got ref command failed unexpectedly" >&2
442 test_done "$testroot" "$ret"
443 return 1
444 fi
446 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
447 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
448 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
449 >> $testroot/stdout.expected
450 echo "refs/remotes/origin/branch1: $commit_id" \
451 >> $testroot/stdout.expected
452 echo "refs/remotes/origin/master: $commit_id" \
453 >> $testroot/stdout.expected
455 cmp -s $testroot/stdout $testroot/stdout.expected
456 ret="$?"
457 if [ "$ret" != "0" ]; then
458 diff -u $testroot/stdout.expected $testroot/stdout
459 fi
460 test_done "$testroot" "$ret"
463 test_send_clone_and_send() {
464 local testroot=`test_init send_clone_and_send`
465 local testurl=ssh://127.0.0.1/$testroot
466 local commit_id=`git_show_head $testroot/repo`
468 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
470 got clone -q $testurl/repo $testroot/repo-clone
471 ret="$?"
472 if [ "$ret" != "0" ]; then
473 echo "got clone command failed unexpectedly" >&2
474 test_done "$testroot" "$ret"
475 return 1
476 fi
478 got checkout $testroot/repo-clone $testroot/wt >/dev/null
479 echo "modified alpha" > $testroot/wt/alpha
480 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
481 local commit_id2=`git_show_head $testroot/repo-clone`
483 (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
484 ret="$?"
485 if [ "$ret" != "0" ]; then
486 echo "got send command failed unexpectedly" >&2
487 test_done "$testroot" "$ret"
488 return 1
489 fi
491 echo -n > $testroot/stdout.expected
492 cmp -s $testroot/stdout $testroot/stdout.expected
493 ret="$?"
494 if [ "$ret" != "0" ]; then
495 diff -u $testroot/stdout.expected $testroot/stdout
496 test_done "$testroot" "$ret"
497 return 1
498 fi
500 got ref -l -r $testroot/repo > $testroot/stdout
501 if [ "$ret" != "0" ]; then
502 echo "got ref command failed unexpectedly" >&2
503 test_done "$testroot" "$ret"
504 return 1
505 fi
507 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
508 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
510 cmp -s $testroot/stdout $testroot/stdout.expected
511 ret="$?"
512 if [ "$ret" != "0" ]; then
513 diff -u $testroot/stdout.expected $testroot/stdout
514 test_done "$testroot" "$ret"
515 return 1
516 fi
518 got ref -l -r $testroot/repo-clone > $testroot/stdout
519 if [ "$ret" != "0" ]; then
520 echo "got ref command failed unexpectedly" >&2
521 test_done "$testroot" "$ret"
522 return 1
523 fi
525 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
526 cut -d ':' -f 2 | tr -d ' ')`
527 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
529 >> $testroot/stdout.expected
530 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
531 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
532 >> $testroot/stdout.expected
533 echo "refs/remotes/origin/master: $commit_id2" \
534 >> $testroot/stdout.expected
536 cmp -s $testroot/stdout $testroot/stdout.expected
537 ret="$?"
538 if [ "$ret" != "0" ]; then
539 diff -u $testroot/stdout.expected $testroot/stdout
540 fi
541 test_done "$testroot" "$ret"
544 test_send_tags() {
545 local testroot=`test_init send_tags`
546 local testurl=ssh://127.0.0.1/$testroot
547 local commit_id=`git_show_head $testroot/repo`
549 got clone -q $testurl/repo $testroot/repo-clone
550 ret="$?"
551 if [ "$ret" != "0" ]; then
552 echo "got clone command failed unexpectedly" >&2
553 test_done "$testroot" "$ret"
554 return 1
555 fi
556 cat > $testroot/repo/.git/got.conf <<EOF
557 remote "origin" {
558 protocol ssh
559 server 127.0.0.1
560 repository "$testroot/repo-clone"
562 EOF
563 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
564 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
565 | tr -d ' ' | cut -d: -f2`
567 echo "modified alpha" > $testroot/repo/alpha
568 git_commit $testroot/repo -m "modified alpha"
569 local commit_id2=`git_show_head $testroot/repo`
571 got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
572 tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
573 | tr -d ' ' | cut -d: -f2`
575 got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
576 ret="$?"
577 if [ "$ret" != "0" ]; then
578 echo "got send command failed unexpectedly" >&2
579 test_done "$testroot" "$ret"
580 return 1
581 fi
583 echo -n > $testroot/stdout.expected
584 cmp -s $testroot/stdout $testroot/stdout.expected
585 ret="$?"
586 if [ "$ret" != "0" ]; then
587 diff -u $testroot/stdout.expected $testroot/stdout
588 test_done "$testroot" "$ret"
589 return 1
590 fi
592 got ref -l -r $testroot/repo > $testroot/stdout
593 if [ "$ret" != "0" ]; then
594 echo "got ref command failed unexpectedly" >&2
595 test_done "$testroot" "$ret"
596 return 1
597 fi
599 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
600 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
601 echo "refs/remotes/origin/master: $commit_id2" \
602 >> $testroot/stdout.expected
603 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
604 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
606 cmp -s $testroot/stdout $testroot/stdout.expected
607 ret="$?"
608 if [ "$ret" != "0" ]; then
609 diff -u $testroot/stdout.expected $testroot/stdout
610 test_done "$testroot" "$ret"
611 return 1
612 fi
614 got ref -l -r $testroot/repo-clone > $testroot/stdout
615 if [ "$ret" != "0" ]; then
616 echo "got ref command failed unexpectedly" >&2
617 test_done "$testroot" "$ret"
618 return 1
619 fi
621 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
622 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
623 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
624 >> $testroot/stdout.expected
625 echo "refs/remotes/origin/master: $commit_id" \
626 >> $testroot/stdout.expected
627 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
628 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
630 cmp -s $testroot/stdout $testroot/stdout.expected
631 ret="$?"
632 if [ "$ret" != "0" ]; then
633 diff -u $testroot/stdout.expected $testroot/stdout
634 test_done "$testroot" "$ret"
635 return 1
636 fi
638 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
639 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
640 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
641 cmp -s $testroot/stdout $testroot/stdout.expected
642 ret="$?"
643 if [ "$ret" != "0" ]; then
644 diff -u $testroot/stdout.expected $testroot/stdout
645 test_done "$testroot" "$ret"
646 return 1
647 fi
649 # Overwriting an existing tag 'got send -f'.
650 got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
651 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
652 tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
653 | tr -d ' ' | cut -d: -f2`
655 got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
656 2> $testroot/stderr
657 ret="$?"
658 if [ "$ret" = "0" ]; then
659 echo "got send command succeeded unexpectedly" >&2
660 test_done "$testroot" "$ret"
661 return 1
662 fi
664 echo "got: refs/tags/1.0: tag already exists on server" \
665 > $testroot/stderr.expected
666 cmp -s $testroot/stderr $testroot/stderr.expected
667 ret="$?"
668 if [ "$ret" != "0" ]; then
669 diff -u $testroot/stderr.expected $testroot/stderr
670 test_done "$testroot" "$ret"
671 return 1
672 fi
674 # attempting the same with -T should fail, too
675 got send -q -r $testroot/repo -T > $testroot/stdout \
676 2> $testroot/stderr
677 ret="$?"
678 if [ "$ret" = "0" ]; then
679 echo "got send command succeeded unexpectedly" >&2
680 test_done "$testroot" "$ret"
681 return 1
682 fi
684 echo "got: refs/tags/1.0: tag already exists on server" \
685 > $testroot/stderr.expected
686 cmp -s $testroot/stderr $testroot/stderr.expected
687 ret="$?"
688 if [ "$ret" != "0" ]; then
689 diff -u $testroot/stderr.expected $testroot/stderr
690 test_done "$testroot" "$ret"
691 return 1
692 fi
694 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
695 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
696 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
697 cmp -s $testroot/stdout $testroot/stdout.expected
698 ret="$?"
699 if [ "$ret" != "0" ]; then
700 diff -u $testroot/stdout.expected $testroot/stdout
701 test_done "$testroot" "$ret"
702 return 1
703 fi
705 # overwrite the 1.0 tag only
706 got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
707 2> $testroot/stderr
708 ret="$?"
709 if [ "$ret" != "0" ]; then
710 echo "got send command failed unexpectedly" >&2
711 test_done "$testroot" "$ret"
712 return 1
713 fi
715 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
716 echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
717 echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
718 cmp -s $testroot/stdout $testroot/stdout.expected
719 ret="$?"
720 if [ "$ret" != "0" ]; then
721 diff -u $testroot/stdout.expected $testroot/stdout
722 fi
723 test_done "$testroot" "$ret"
726 test_send_tag_of_deleted_branch() {
727 local testroot=`test_init send_tag_of_deleted_branch`
728 local testurl=ssh://127.0.0.1/$testroot
729 local commit_id=`git_show_head $testroot/repo`
731 got clone -q $testurl/repo $testroot/repo-clone
732 ret="$?"
733 if [ "$ret" != "0" ]; then
734 echo "got clone command failed unexpectedly" >&2
735 test_done "$testroot" "$ret"
736 return 1
737 fi
738 cat > $testroot/repo/.git/got.conf <<EOF
739 remote "origin" {
740 protocol ssh
741 server 127.0.0.1
742 repository "$testroot/repo-clone"
744 EOF
745 got branch -r $testroot/repo foo
747 # modify alpha on branch foo
748 got checkout -b foo $testroot/repo $testroot/wt > /dev/null
749 echo boo >> $testroot/wt/beta
750 (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
751 > /dev/null)
752 local commit_id2=`git_show_branch_head $testroot/repo foo`
754 # tag HEAD commit of branch foo
755 got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
756 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
757 | tr -d ' ' | cut -d: -f2`
759 # delete the branch; commit is now only reachable via tags/1.0
760 got branch -r $testroot/repo -d foo > /dev/null
762 # unrelated change on master branch, then try sending this branch
763 # and the tag
764 echo "modified alpha" > $testroot/repo/alpha
765 git_commit $testroot/repo -m "modified alpha"
766 local commit_id3=`git_show_head $testroot/repo`
768 got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
769 ret="$?"
770 if [ "$ret" != "0" ]; then
771 echo "got send command failed unexpectedly" >&2
772 test_done "$testroot" "$ret"
773 return 1
774 fi
776 echo -n > $testroot/stdout.expected
777 cmp -s $testroot/stdout $testroot/stdout.expected
778 ret="$?"
779 if [ "$ret" != "0" ]; then
780 diff -u $testroot/stdout.expected $testroot/stdout
781 test_done "$testroot" "$ret"
782 return 1
783 fi
785 got ref -l -r $testroot/repo > $testroot/stdout
786 if [ "$ret" != "0" ]; then
787 echo "got ref command failed unexpectedly" >&2
788 test_done "$testroot" "$ret"
789 return 1
790 fi
792 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
793 cut -d ':' -f 2 | tr -d ' ')`
794 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
795 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
796 >> $testroot/stdout.expected
797 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
798 echo "refs/remotes/origin/master: $commit_id3" \
799 >> $testroot/stdout.expected
800 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
802 cmp -s $testroot/stdout $testroot/stdout.expected
803 ret="$?"
804 if [ "$ret" != "0" ]; then
805 diff -u $testroot/stdout.expected $testroot/stdout
806 test_done "$testroot" "$ret"
807 return 1
808 fi
810 got ref -l -r $testroot/repo-clone > $testroot/stdout
811 if [ "$ret" != "0" ]; then
812 echo "got ref command failed unexpectedly" >&2
813 test_done "$testroot" "$ret"
814 return 1
815 fi
817 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
818 echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
819 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
820 >> $testroot/stdout.expected
821 echo "refs/remotes/origin/master: $commit_id" \
822 >> $testroot/stdout.expected
823 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
825 cmp -s $testroot/stdout $testroot/stdout.expected
826 ret="$?"
827 if [ "$ret" != "0" ]; then
828 diff -u $testroot/stdout.expected $testroot/stdout
829 test_done "$testroot" "$ret"
830 return 1
831 fi
833 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
834 echo "tag 1.0 $tag_id" > $testroot/stdout.expected
836 cmp -s $testroot/stdout $testroot/stdout.expected
837 ret="$?"
838 if [ "$ret" != "0" ]; then
839 diff -u $testroot/stdout.expected $testroot/stdout
840 fi
841 test_done "$testroot" "$ret"
844 test_send_new_branch() {
845 local testroot=`test_init send_new_branch`
846 local testurl=ssh://127.0.0.1/$testroot
847 local commit_id=`git_show_head $testroot/repo`
849 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
851 got clone -q $testurl/repo $testroot/repo-clone
852 ret="$?"
853 if [ "$ret" != "0" ]; then
854 echo "got clone command failed unexpectedly" >&2
855 test_done "$testroot" "$ret"
856 return 1
857 fi
859 got branch -r $testroot/repo-clone foo >/dev/null
860 got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
861 echo "modified alpha" > $testroot/wt/alpha
862 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
863 local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
865 (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
866 ret="$?"
867 if [ "$ret" != "0" ]; then
868 echo "got send command failed unexpectedly" >&2
869 test_done "$testroot" "$ret"
870 return 1
871 fi
873 echo -n > $testroot/stdout.expected
874 cmp -s $testroot/stdout $testroot/stdout.expected
875 ret="$?"
876 if [ "$ret" != "0" ]; then
877 diff -u $testroot/stdout.expected $testroot/stdout
878 test_done "$testroot" "$ret"
879 return 1
880 fi
882 got ref -l -r $testroot/repo > $testroot/stdout
883 if [ "$ret" != "0" ]; then
884 echo "got ref command failed unexpectedly" >&2
885 test_done "$testroot" "$ret"
886 return 1
887 fi
889 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
890 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
891 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
893 cmp -s $testroot/stdout $testroot/stdout.expected
894 ret="$?"
895 if [ "$ret" != "0" ]; then
896 diff -u $testroot/stdout.expected $testroot/stdout
897 test_done "$testroot" "$ret"
898 return 1
899 fi
901 got ref -l -r $testroot/repo-clone > $testroot/stdout
902 if [ "$ret" != "0" ]; then
903 echo "got ref command failed unexpectedly" >&2
904 test_done "$testroot" "$ret"
905 return 1
906 fi
908 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
909 cut -d ':' -f 2 | tr -d ' ')`
910 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
911 echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
912 >> $testroot/stdout.expected
913 echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
914 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
915 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
916 >> $testroot/stdout.expected
917 echo "refs/remotes/origin/foo: $commit_id2" \
918 >> $testroot/stdout.expected
919 echo "refs/remotes/origin/master: $commit_id" \
920 >> $testroot/stdout.expected
922 cmp -s $testroot/stdout $testroot/stdout.expected
923 ret="$?"
924 if [ "$ret" != "0" ]; then
925 diff -u $testroot/stdout.expected $testroot/stdout
926 fi
927 test_done "$testroot" "$ret"
930 test_send_all_branches() {
931 local testroot=`test_init send_all_branches`
932 local testurl=ssh://127.0.0.1/$testroot
933 local commit_id=`git_show_head $testroot/repo`
935 (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
937 got clone -q $testurl/repo $testroot/repo-clone
938 ret="$?"
939 if [ "$ret" != "0" ]; then
940 echo "got clone command failed unexpectedly" >&2
941 test_done "$testroot" "$ret"
942 return 1
943 fi
945 got checkout $testroot/repo-clone $testroot/wt >/dev/null
946 echo "modified alpha" > $testroot/wt/alpha
947 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
948 local commit_id2=`git_show_head $testroot/repo-clone`
950 got branch -r $testroot/repo-clone foo >/dev/null
951 (cd $testroot/wt && got update -b foo >/dev/null)
952 echo "modified beta on new branch foo" > $testroot/wt/beta
953 (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
954 local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
956 got branch -r $testroot/repo-clone bar >/dev/null
957 (cd $testroot/wt && got update -b bar >/dev/null)
958 echo "modified beta again on new branch bar" > $testroot/wt/beta
959 (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
960 local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
962 got ref -l -r $testroot/repo-clone > $testroot/stdout
963 if [ "$ret" != "0" ]; then
964 echo "got ref command failed unexpectedly" >&2
965 test_done "$testroot" "$ret"
966 return 1
967 fi
969 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
970 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
971 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
972 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
974 got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
975 2> $testroot/stderr
976 ret="$?"
977 if [ "$ret" = "0" ]; then
978 echo "got send command succeeded unexpectedly" >&2
979 test_done "$testroot" "$ret"
980 return 1
981 fi
982 echo "got: -a and -b options are mutually exclusive" \
983 > $testroot/stderr.expected
984 cmp -s $testroot/stderr $testroot/stderr.expected
985 ret="$?"
986 if [ "$ret" != "0" ]; then
987 diff -u $testroot/stderr.expected $testroot/stderr
988 test_done "$testroot" "$ret"
989 return 1
990 fi
992 got send -a -q -r $testroot/repo-clone > $testroot/stdout \
993 2> $testroot/stderr
994 ret="$?"
995 if [ "$ret" != "0" ]; then
996 echo "got send command failed unexpectedly" >&2
997 test_done "$testroot" "$ret"
998 return 1
999 fi
1001 echo -n > $testroot/stdout.expected
1002 cmp -s $testroot/stdout $testroot/stdout.expected
1003 ret="$?"
1004 if [ "$ret" != "0" ]; then
1005 diff -u $testroot/stdout.expected $testroot/stdout
1006 test_done "$testroot" "$ret"
1007 return 1
1010 got ref -l -r $testroot/repo > $testroot/stdout
1011 if [ "$ret" != "0" ]; then
1012 echo "got ref command failed unexpectedly" >&2
1013 test_done "$testroot" "$ret"
1014 return 1
1017 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1018 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1019 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1020 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1022 cmp -s $testroot/stdout $testroot/stdout.expected
1023 ret="$?"
1024 if [ "$ret" != "0" ]; then
1025 diff -u $testroot/stdout.expected $testroot/stdout
1026 test_done "$testroot" "$ret"
1027 return 1
1030 got ref -l -r $testroot/repo-clone > $testroot/stdout
1031 if [ "$ret" != "0" ]; then
1032 echo "got ref command failed unexpectedly" >&2
1033 test_done "$testroot" "$ret"
1034 return 1
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_id4" \
1041 >> $testroot/stdout.expected
1042 echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1043 echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1044 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1045 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1046 >> $testroot/stdout.expected
1047 echo "refs/remotes/origin/bar: $commit_id4" \
1048 >> $testroot/stdout.expected
1049 echo "refs/remotes/origin/foo: $commit_id3" \
1050 >> $testroot/stdout.expected
1051 echo "refs/remotes/origin/master: $commit_id2" \
1052 >> $testroot/stdout.expected
1054 cmp -s $testroot/stdout $testroot/stdout.expected
1055 ret="$?"
1056 if [ "$ret" != "0" ]; then
1057 diff -u $testroot/stdout.expected $testroot/stdout
1059 test_done "$testroot" "$ret"
1062 test_send_to_empty_repo() {
1063 local testroot=`test_init send_to_empty_repo`
1064 local testurl=ssh://127.0.0.1/$testroot
1065 local commit_id=`git_show_head $testroot/repo`
1067 got init $testroot/repo2
1069 ret="$?"
1070 if [ "$ret" != "0" ]; then
1071 echo "got clone command failed unexpectedly" >&2
1072 test_done "$testroot" "$ret"
1073 return 1
1075 cat > $testroot/repo/.git/got.conf <<EOF
1076 remote "origin" {
1077 protocol ssh
1078 server 127.0.0.1
1079 repository "$testroot/repo2"
1081 EOF
1082 echo "modified alpha" > $testroot/repo/alpha
1083 git_commit $testroot/repo -m "modified alpha"
1084 local commit_id2=`git_show_head $testroot/repo`
1086 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1087 ret="$?"
1088 if [ "$ret" != "0" ]; then
1089 echo "got send command failed unexpectedly" >&2
1090 test_done "$testroot" "$ret"
1091 return 1
1094 echo -n > $testroot/stdout.expected
1095 cmp -s $testroot/stdout $testroot/stdout.expected
1096 ret="$?"
1097 if [ "$ret" != "0" ]; then
1098 diff -u $testroot/stdout.expected $testroot/stdout
1099 test_done "$testroot" "$ret"
1100 return 1
1103 # XXX Workaround: We cannot give the target for HEAD to 'got init'
1104 got ref -r $testroot/repo2 -s refs/heads/master HEAD
1106 got ref -l -r $testroot/repo > $testroot/stdout
1107 if [ "$ret" != "0" ]; then
1108 echo "got ref command failed unexpectedly" >&2
1109 test_done "$testroot" "$ret"
1110 return 1
1113 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1114 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1115 echo "refs/remotes/origin/master: $commit_id2" \
1116 >> $testroot/stdout.expected
1118 cmp -s $testroot/stdout $testroot/stdout.expected
1119 ret="$?"
1120 if [ "$ret" != "0" ]; then
1121 diff -u $testroot/stdout.expected $testroot/stdout
1122 test_done "$testroot" "$ret"
1123 return 1
1126 got ref -l -r $testroot/repo2 > $testroot/stdout
1127 if [ "$ret" != "0" ]; then
1128 echo "got ref command failed unexpectedly" >&2
1129 test_done "$testroot" "$ret"
1130 return 1
1133 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1134 echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1136 cmp -s $testroot/stdout $testroot/stdout.expected
1137 ret="$?"
1138 if [ "$ret" != "0" ]; then
1139 diff -u $testroot/stdout.expected $testroot/stdout
1140 test_done "$testroot" "$ret"
1141 return 1
1144 got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1145 ret="$?"
1146 if [ "$ret" != "0" ]; then
1147 echo "got send command failed unexpectedly" >&2
1148 test_done "$testroot" "$ret"
1149 return 1
1152 echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1153 echo "Already up-to-date" >> $testroot/stdout.expected
1154 cmp -s $testroot/stdout $testroot/stdout.expected
1155 ret="$?"
1156 if [ "$ret" != "0" ]; then
1157 diff -u $testroot/stdout.expected $testroot/stdout
1159 test_done "$testroot" "$ret"
1162 test_send_and_fetch_config() {
1163 local testroot=`test_init send_fetch_conf`
1164 local testurl=ssh://127.0.0.1/$testroot
1165 local commit_id=`git_show_head $testroot/repo`
1167 got clone -q $testurl/repo $testroot/repo-clone
1168 ret="$?"
1169 if [ "$ret" != "0" ]; then
1170 echo "got clone command failed unexpectedly" >&2
1171 test_done "$testroot" "$ret"
1172 return 1
1175 got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1176 tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1177 | tr -d ' ' | cut -d: -f2`
1179 cp -R $testroot/repo-clone $testroot/repo-clone2
1180 got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1181 tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1182 | tr -d ' ' | cut -d: -f2`
1184 cat > $testroot/repo/.git/got.conf <<EOF
1185 remote "origin" {
1186 protocol ssh
1187 server 127.0.0.1
1188 send {
1189 repository "$testroot/repo-clone"
1191 fetch {
1192 repository "$testroot/repo-clone2"
1195 EOF
1196 got ref -l -r $testroot/repo > $testroot/stdout
1197 if [ "$ret" != "0" ]; then
1198 echo "got ref command failed unexpectedly" >&2
1199 test_done "$testroot" "$ret"
1200 return 1
1203 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1204 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1205 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1206 cmp -s $testroot/stdout $testroot/stdout.expected
1207 ret="$?"
1208 if [ "$ret" != "0" ]; then
1209 diff -u $testroot/stdout.expected $testroot/stdout
1210 test_done "$testroot" "$ret"
1211 return 1
1214 # fetch tag 2.0 from repo-clone2
1215 got fetch -q -r $testroot/repo > $testroot/stdout
1216 ret="$?"
1217 if [ "$ret" != "0" ]; then
1218 echo "got fetch command failed unexpectedly" >&2
1219 test_done "$testroot" "$ret"
1220 return 1
1223 got ref -l -r $testroot/repo > $testroot/stdout
1224 if [ "$ret" != "0" ]; then
1225 echo "got ref command failed unexpectedly" >&2
1226 test_done "$testroot" "$ret"
1227 return 1
1230 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1231 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1232 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1233 >> $testroot/stdout.expected
1234 echo "refs/remotes/origin/master: $commit_id" \
1235 >> $testroot/stdout.expected
1236 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1237 echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1238 cmp -s $testroot/stdout $testroot/stdout.expected
1239 ret="$?"
1240 if [ "$ret" != "0" ]; then
1241 diff -u $testroot/stdout.expected $testroot/stdout
1242 test_done "$testroot" "$ret"
1243 return 1
1246 # send tag 1.0 to repo-clone
1247 got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1248 ret="$?"
1249 if [ "$ret" != "0" ]; then
1250 echo "got send command failed unexpectedly" >&2
1251 test_done "$testroot" "$ret"
1252 return 1
1255 got ref -l -r $testroot/repo-clone > $testroot/stdout
1256 if [ "$ret" != "0" ]; then
1257 echo "got ref command failed unexpectedly" >&2
1258 test_done "$testroot" "$ret"
1259 return 1
1262 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1263 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1264 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1265 >> $testroot/stdout.expected
1266 echo "refs/remotes/origin/master: $commit_id" \
1267 >> $testroot/stdout.expected
1268 echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1270 cmp -s $testroot/stdout $testroot/stdout.expected
1271 ret="$?"
1272 if [ "$ret" != "0" ]; then
1273 diff -u $testroot/stdout.expected $testroot/stdout
1276 test_done "$testroot" "$ret"
1279 test_send_config() {
1280 local testroot=`test_init send_fetch_conf`
1281 local testurl=ssh://127.0.0.1/$testroot
1282 local commit_id=`git_show_head $testroot/repo`
1284 got clone -q $testurl/repo $testroot/repo-clone
1285 ret="$?"
1286 if [ "$ret" != "0" ]; then
1287 echo "got clone command failed unexpectedly" >&2
1288 test_done "$testroot" "$ret"
1289 return 1
1292 cat > $testroot/repo/.git/got.conf <<EOF
1293 remote "origin" {
1294 protocol ssh
1295 server 127.0.0.1
1296 branch foo
1297 repository "$testroot/repo-clone"
1299 EOF
1300 got ref -l -r $testroot/repo-clone > $testroot/stdout
1301 if [ "$ret" != "0" ]; then
1302 echo "got ref command failed unexpectedly" >&2
1303 test_done "$testroot" "$ret"
1304 return 1
1307 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1308 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1309 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1310 >> $testroot/stdout.expected
1311 echo "refs/remotes/origin/master: $commit_id" \
1312 >> $testroot/stdout.expected
1314 cmp -s $testroot/stdout $testroot/stdout.expected
1315 ret="$?"
1316 if [ "$ret" != "0" ]; then
1317 diff -u $testroot/stdout.expected $testroot/stdout
1318 test_done "$testroot" "$ret"
1319 return 1
1322 got branch -r $testroot/repo foo
1324 got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1325 ret="$?"
1326 if [ "$ret" != "0" ]; then
1327 echo "got send command failed unexpectedly" >&2
1328 test_done "$testroot" "$ret"
1329 return 1
1332 got ref -l -r $testroot/repo-clone > $testroot/stdout
1333 if [ "$ret" != "0" ]; then
1334 echo "got ref command failed unexpectedly" >&2
1335 test_done "$testroot" "$ret"
1336 return 1
1339 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1340 echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1341 echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1342 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1343 >> $testroot/stdout.expected
1344 echo "refs/remotes/origin/master: $commit_id" \
1345 >> $testroot/stdout.expected
1347 cmp -s $testroot/stdout $testroot/stdout.expected
1348 ret="$?"
1349 if [ "$ret" != "0" ]; then
1350 diff -u $testroot/stdout.expected $testroot/stdout
1352 test_done "$testroot" "$ret"
1355 test_parseargs "$@"
1356 run_test test_send_basic
1357 run_test test_send_rebase_required
1358 run_test test_send_rebase_required_overwrite
1359 run_test test_send_delete
1360 run_test test_send_clone_and_send
1361 run_test test_send_tags
1362 run_test test_send_tag_of_deleted_branch
1363 run_test test_send_new_branch
1364 run_test test_send_all_branches
1365 run_test test_send_to_empty_repo
1366 run_test test_send_and_fetch_config
1367 run_test test_send_config