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
120 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
124 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
126 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
129 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
130 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
131 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
132 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
134 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
136 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
137 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
138 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
141 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
142 f8a36e22 2021-08-26 stsp remote "origin" {
143 f8a36e22 2021-08-26 stsp protocol ssh
144 f8a36e22 2021-08-26 stsp server 127.0.0.1
145 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
148 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
149 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
150 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
152 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
153 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
154 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
156 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
158 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
159 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
160 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
164 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
165 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
167 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
168 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
169 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
173 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
174 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
175 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
177 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
178 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
179 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
183 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
185 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
188 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
189 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
190 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
191 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
193 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
195 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
196 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
197 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
200 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
201 f8a36e22 2021-08-26 stsp remote "foobar" {
202 f8a36e22 2021-08-26 stsp protocol ssh
203 f8a36e22 2021-08-26 stsp server 127.0.0.1
204 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
207 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
208 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
209 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
211 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
212 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
213 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
214 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
216 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
217 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
218 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
220 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
221 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
222 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
225 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
226 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
227 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
229 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
230 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
231 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
235 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
236 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
238 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
239 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
240 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
244 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
245 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
247 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
248 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
249 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
253 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
254 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
255 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
256 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
260 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
261 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
262 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
263 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
265 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
267 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
268 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
269 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
273 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
274 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
275 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
276 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
280 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
281 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
282 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
283 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
284 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
285 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
286 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
287 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
288 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
289 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
291 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
293 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
294 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
295 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
299 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
301 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
304 f8a36e22 2021-08-26 stsp test_send_delete() {
305 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
306 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
307 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
309 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
310 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
312 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
314 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
315 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
316 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
319 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
320 f8a36e22 2021-08-26 stsp remote "origin" {
321 f8a36e22 2021-08-26 stsp protocol ssh
322 f8a36e22 2021-08-26 stsp server 127.0.0.1
323 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
326 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
327 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
329 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
330 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
331 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
332 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
336 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
337 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
338 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
339 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
341 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
342 f8a36e22 2021-08-26 stsp # time is not allowed.
343 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
344 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
346 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
347 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
348 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
351 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
352 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
353 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
354 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
356 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
357 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
358 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
362 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
363 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
365 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
366 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
367 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
371 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
372 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
374 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
375 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
376 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
380 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
381 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
382 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
384 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
386 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
387 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
388 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
392 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
393 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
394 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
396 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
397 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
398 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
401 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
402 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
403 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
404 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
405 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
407 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
408 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
409 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
413 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
414 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
415 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
417 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
418 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
419 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
422 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
423 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
424 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
425 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
426 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
427 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
429 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
430 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
431 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
435 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
436 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
437 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
438 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
442 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
443 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
444 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
446 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
448 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
449 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
454 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
455 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
456 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
457 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
461 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
462 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
463 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
464 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
465 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
466 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
467 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
468 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
470 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
472 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
473 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
474 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
478 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
480 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
483 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
484 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
485 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
486 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
488 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
490 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
492 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
493 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
494 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
498 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
499 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
500 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
501 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
503 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
505 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
506 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
507 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
511 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
512 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
514 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
515 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
516 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
520 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
521 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
522 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
523 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
527 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
532 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
533 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
538 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
539 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
540 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
541 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
545 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
546 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
547 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
548 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
549 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
550 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
551 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
552 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
553 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
554 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
556 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
558 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
559 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
564 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
566 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
569 f8a36e22 2021-08-26 stsp test_send_tags() {
570 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
571 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
572 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
574 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
576 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
577 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
578 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
581 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
582 f8a36e22 2021-08-26 stsp remote "origin" {
583 f8a36e22 2021-08-26 stsp protocol ssh
584 f8a36e22 2021-08-26 stsp server 127.0.0.1
585 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
588 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
589 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
590 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
592 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
593 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
594 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
596 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
597 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
598 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
600 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
602 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
603 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
604 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
608 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
609 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
611 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
612 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
617 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
618 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
619 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
620 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
624 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
625 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
626 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
627 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
628 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
629 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
631 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
633 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
634 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
635 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
639 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
640 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
641 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
642 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
646 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
647 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
648 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
649 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
650 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
651 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
652 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
653 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
655 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
657 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
658 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
659 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
663 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
664 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
665 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
666 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
668 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
669 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
670 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
674 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
675 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
676 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
677 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
678 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
680 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
681 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
683 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
684 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
685 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
689 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
690 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
691 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
693 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
694 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
695 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
699 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
700 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
701 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
703 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
704 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
705 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
709 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
710 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
711 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
713 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
714 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
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_id" > $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
726 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
730 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
731 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
732 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
734 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
735 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
736 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
740 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
741 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
742 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
743 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
745 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
746 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
747 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
751 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
752 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
753 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
755 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
756 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
757 c2105d00 2021-09-14 stsp 2> $testroot/stderr
759 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
760 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
761 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
765 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
766 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
767 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
768 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
769 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
771 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
772 c2105d00 2021-09-14 stsp 2> $testroot/stderr
774 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
775 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
776 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
779 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
780 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
781 c2105d00 2021-09-14 stsp $testroot/stdout; then
782 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
783 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
784 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
788 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
790 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
793 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
794 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
795 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
796 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
798 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
800 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
801 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
802 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
805 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
806 26960ff7 2021-09-14 stsp remote "origin" {
807 26960ff7 2021-09-14 stsp protocol ssh
808 26960ff7 2021-09-14 stsp server 127.0.0.1
809 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
812 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
814 26960ff7 2021-09-14 stsp # modify alpha on branch foo
815 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
816 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
817 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
818 26960ff7 2021-09-14 stsp > /dev/null)
819 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
821 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
822 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
823 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
824 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
826 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
827 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
829 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
830 26960ff7 2021-09-14 stsp # and the tag
831 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
832 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
833 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
835 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
837 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
838 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
839 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
843 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
844 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
846 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
847 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
848 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
852 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
853 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
854 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
855 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
859 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
860 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
861 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
862 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
863 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
864 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
865 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
866 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
867 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
869 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
871 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
872 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
873 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
877 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
878 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
879 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
880 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
884 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
885 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
886 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
887 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
888 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
889 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
890 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
892 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
894 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
895 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
896 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
900 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
901 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
903 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
905 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
906 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
907 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
911 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
913 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
916 f8a36e22 2021-08-26 stsp test_send_new_branch() {
917 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
918 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
919 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
921 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
923 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
925 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
926 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
927 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
931 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
932 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
933 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
934 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
935 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
937 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
939 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
940 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
941 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
945 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
946 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
948 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
949 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
950 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
954 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
955 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
956 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
957 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
961 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
962 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
963 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
965 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
967 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
968 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
973 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
974 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
975 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
976 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
980 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
981 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
982 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
983 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
984 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
985 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
986 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
987 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
988 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
989 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
990 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
991 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
992 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
994 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
996 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
997 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
998 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1002 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1004 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1007 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1008 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1009 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1010 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1012 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1014 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1016 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1017 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1018 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1022 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1023 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1024 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1025 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1027 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1028 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1029 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1030 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1031 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1033 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1034 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1035 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1036 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1037 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1039 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1040 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1041 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1042 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1046 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1047 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1048 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1049 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1051 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1052 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1054 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
1055 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1056 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1059 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1060 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1061 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1063 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1064 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1065 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1069 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1070 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1072 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1073 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1074 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1078 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1079 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1081 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1082 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1083 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1087 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1088 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1090 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1094 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1095 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1096 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1097 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1099 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1101 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1102 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1103 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1107 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1108 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1109 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1110 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1114 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1115 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1116 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1117 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1118 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1119 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1120 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1121 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1122 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1123 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1124 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1125 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1126 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1127 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1128 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1129 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1131 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1133 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1134 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1135 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1139 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1141 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1144 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1145 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1146 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1147 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1149 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1152 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1153 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1154 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1157 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1158 f8a36e22 2021-08-26 stsp remote "origin" {
1159 f8a36e22 2021-08-26 stsp protocol ssh
1160 f8a36e22 2021-08-26 stsp server 127.0.0.1
1161 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1164 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1165 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1166 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1168 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1170 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1171 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1172 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1176 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1177 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1179 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1180 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1185 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1186 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1188 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1189 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1190 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1191 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1195 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1196 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1197 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1198 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1200 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1202 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1203 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1204 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1208 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1209 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1210 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1211 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1215 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1216 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1218 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1220 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1221 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1222 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1226 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1228 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1235 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1236 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1238 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1239 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1240 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1244 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1246 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1249 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1250 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1251 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1252 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1254 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1256 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1257 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1258 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1262 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1263 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1264 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1266 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1267 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1268 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1269 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1271 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1272 6480c871 2021-08-30 stsp remote "origin" {
1273 6480c871 2021-08-30 stsp protocol ssh
1274 6480c871 2021-08-30 stsp server 127.0.0.1
1276 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1279 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1283 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1284 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1285 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1286 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1290 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1291 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1292 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1293 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1295 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1296 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1297 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1301 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1302 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1304 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1305 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1306 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1310 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1311 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1312 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1313 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1317 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1318 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1319 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1320 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1321 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1322 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1323 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1324 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1325 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1327 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1328 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1329 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1333 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1334 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1336 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1337 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1338 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1342 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1343 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1344 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1345 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1349 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1350 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1351 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1352 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1353 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1354 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1355 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1357 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1359 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1360 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1361 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1365 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1367 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1370 eac1df47 2021-09-01 stsp test_send_config() {
1371 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1372 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1373 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1375 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1377 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1378 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1379 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1383 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1384 eac1df47 2021-09-01 stsp remote "origin" {
1385 eac1df47 2021-09-01 stsp protocol ssh
1386 eac1df47 2021-09-01 stsp server 127.0.0.1
1387 eac1df47 2021-09-01 stsp branch foo
1388 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1391 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1392 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1393 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1394 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1398 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1399 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1400 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1401 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1402 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1403 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1405 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1407 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1408 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1409 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1413 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1415 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1417 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1418 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1419 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1423 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1424 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1425 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1426 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1430 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1431 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1432 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1433 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1434 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1435 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1436 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1438 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1440 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1441 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1442 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1446 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1448 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1451 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1452 f8a36e22 2021-08-26 stsp run_test test_send_basic
1453 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1454 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1455 f8a36e22 2021-08-26 stsp run_test test_send_delete
1456 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1457 f8a36e22 2021-08-26 stsp run_test test_send_tags
1458 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1459 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1460 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1461 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1462 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1463 eac1df47 2021-09-01 stsp run_test test_send_config