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