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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
44 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
46 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
48 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
49 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
50 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
54 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
55 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
57 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
58 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
59 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
63 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
64 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
65 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
66 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
70 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
71 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
72 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
73 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
74 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
76 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
78 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
79 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
84 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
85 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
86 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
87 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
91 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
92 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
93 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
94 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
95 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
96 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
98 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
100 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
101 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
102 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
106 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
108 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
109 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
110 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
114 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
115 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
116 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
118 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
119 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
121 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
124 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
125 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
126 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
127 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
129 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
131 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
132 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
133 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
136 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
137 f8a36e22 2021-08-26 stsp remote "origin" {
138 f8a36e22 2021-08-26 stsp protocol ssh
139 f8a36e22 2021-08-26 stsp server 127.0.0.1
140 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
143 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
144 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
145 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
147 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
148 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
149 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
151 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
153 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
154 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
155 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
159 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
160 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
162 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
163 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
164 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
168 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
169 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
170 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
172 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
173 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
175 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
178 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
179 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
180 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
181 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
183 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
185 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
186 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
187 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
190 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
191 f8a36e22 2021-08-26 stsp remote "foobar" {
192 f8a36e22 2021-08-26 stsp protocol ssh
193 f8a36e22 2021-08-26 stsp server 127.0.0.1
194 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
197 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
198 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
199 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
201 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
202 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
203 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
204 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
206 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
207 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
208 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
210 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
211 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
212 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
215 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
216 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
217 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
219 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
220 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
225 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
226 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
228 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
229 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
230 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
234 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
235 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
237 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
238 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
239 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
243 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
244 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
245 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
246 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
250 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
251 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
252 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
253 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
255 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
257 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
258 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
259 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
263 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
264 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
265 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
266 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
270 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
271 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
272 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
273 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
274 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
275 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
276 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
277 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
278 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
279 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
281 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
283 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
284 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
286 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
289 f8a36e22 2021-08-26 stsp test_send_delete() {
290 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
291 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
292 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
294 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
295 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
297 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
299 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
300 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
301 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
304 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
305 f8a36e22 2021-08-26 stsp remote "origin" {
306 f8a36e22 2021-08-26 stsp protocol ssh
307 f8a36e22 2021-08-26 stsp server 127.0.0.1
308 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
311 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
312 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
314 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
315 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
316 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
317 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
321 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
322 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
323 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
324 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
326 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
327 f8a36e22 2021-08-26 stsp # time is not allowed.
328 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
329 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
331 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
332 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
333 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
336 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
337 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
338 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
339 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
341 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
342 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
343 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
347 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
348 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
350 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
351 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
352 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
356 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
357 1bd76734 2021-08-26 stsp > $testroot/stdout.raw 2>$testroot/stderr
359 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
360 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
361 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
364 1bd76734 2021-08-26 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
366 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
367 1bd76734 2021-08-26 stsp echo -n "packing 0 references; 0 objects; deltify: 0%; " \
368 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
369 1bd76734 2021-08-26 stsp echo "uploading pack: 32B 100%" >> $testroot/stdout.expected
370 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
371 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
373 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
375 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
376 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
381 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
382 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
383 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
385 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
386 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
387 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
390 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
391 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
392 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
393 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
394 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
396 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
397 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
398 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
402 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
403 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
404 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
406 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
407 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
408 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
411 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
412 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
413 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
414 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
415 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
416 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
418 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
419 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
424 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
425 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
426 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
427 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
431 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
432 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
433 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
435 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
437 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
438 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
443 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
444 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
445 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
446 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
450 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
451 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
452 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
453 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
454 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
455 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
456 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
457 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
459 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
461 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
462 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
464 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
467 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
468 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
469 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
470 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
472 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
474 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
476 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
477 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
478 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
482 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
483 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
484 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
485 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
487 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
489 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
490 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
491 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
495 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
496 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
498 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
499 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
504 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
505 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
506 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
507 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
511 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
512 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
514 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
516 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
517 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
518 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
522 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
523 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
524 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
525 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
529 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
530 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
531 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
532 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
533 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
534 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
535 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
536 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
537 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
538 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
540 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
542 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
543 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
548 f8a36e22 2021-08-26 stsp test_send_tags() {
549 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
550 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
551 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
553 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
555 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
556 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
557 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
560 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
561 f8a36e22 2021-08-26 stsp remote "origin" {
562 f8a36e22 2021-08-26 stsp protocol ssh
563 f8a36e22 2021-08-26 stsp server 127.0.0.1
564 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
567 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
568 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
569 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
571 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
572 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
573 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
575 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
576 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
577 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
579 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
581 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
582 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
583 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
587 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
588 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
590 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
591 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
596 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
597 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
598 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
599 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
603 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
604 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
605 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
606 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
607 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
608 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
610 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
612 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
613 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
614 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
618 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
619 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
620 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
621 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
625 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
626 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
627 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
628 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
629 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
630 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
631 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
632 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
634 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
636 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
643 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
644 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
645 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
647 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
648 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
649 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
653 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
654 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
655 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
656 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
657 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
659 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
660 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
662 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
663 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
664 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
668 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
669 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
670 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
672 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
673 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
674 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
678 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
679 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
680 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
682 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
683 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
684 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
688 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
689 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
690 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
692 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
693 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
694 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
698 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
699 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
700 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
701 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
703 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
704 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
709 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
710 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
711 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
713 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
714 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
715 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
719 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
720 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
721 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
722 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
724 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
725 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
727 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
730 f8a36e22 2021-08-26 stsp test_send_new_branch() {
731 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
732 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
733 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
735 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
737 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
739 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
740 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
741 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
745 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
746 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
747 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
748 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
749 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
751 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
753 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
754 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
755 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
759 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
760 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
762 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
763 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
764 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
768 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
769 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
770 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
771 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
775 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
776 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
777 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
779 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
781 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
782 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
783 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
787 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
788 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
789 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
790 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
794 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
795 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
796 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
797 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
798 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
799 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
800 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
801 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
802 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
803 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
804 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
805 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
806 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
808 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
810 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
811 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
816 f8a36e22 2021-08-26 stsp test_send_all_branches() {
817 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
818 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
819 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
821 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
823 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
825 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
826 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
827 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
831 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
832 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
833 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
834 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
836 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
837 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
838 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
839 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
840 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
842 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
843 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
844 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
845 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
846 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
848 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
849 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
850 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
851 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
855 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
856 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
857 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
858 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
860 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
861 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
863 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
864 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
865 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
868 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
869 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
870 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
872 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
873 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
874 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
878 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
879 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
881 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
882 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
883 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
887 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
888 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
890 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
891 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
892 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
896 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
897 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
898 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
899 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
903 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
904 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
905 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
906 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
908 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
910 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
911 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
912 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
916 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
917 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
918 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
919 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
923 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
924 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
925 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
926 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
927 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
928 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
929 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
930 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
931 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
932 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
933 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
934 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
935 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
936 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
937 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
938 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
940 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
942 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
943 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
945 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
948 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
949 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
950 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
951 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
953 f8a36e22 2021-08-26 stsp got init $testroot/repo2
956 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
957 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
958 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
961 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
962 f8a36e22 2021-08-26 stsp remote "origin" {
963 f8a36e22 2021-08-26 stsp protocol ssh
964 f8a36e22 2021-08-26 stsp server 127.0.0.1
965 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
968 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
969 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
970 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
972 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
974 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
975 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
976 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
980 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
981 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
983 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
984 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
989 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
990 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
992 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
993 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
994 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
995 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
999 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1000 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1001 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1002 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1004 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1006 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1007 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1008 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1012 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1013 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1014 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1015 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1019 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1020 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1022 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1024 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1025 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1030 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1032 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1033 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1034 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1038 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1039 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1042 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1043 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1045 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1049 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1050 f8a36e22 2021-08-26 stsp run_test test_send_basic
1051 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1052 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1053 f8a36e22 2021-08-26 stsp run_test test_send_delete
1054 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1055 f8a36e22 2021-08-26 stsp run_test test_send_tags
1056 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1057 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1058 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo