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 27b75514 2021-08-28 stsp > $testroot/stdout 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"
365 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
366 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
367 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
369 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
371 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
372 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
373 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
377 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
378 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
379 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
381 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
382 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
383 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
386 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
387 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
388 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
389 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
390 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
392 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
393 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
394 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
398 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
399 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
400 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
402 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
403 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
404 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
407 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
408 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
409 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
410 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
411 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
412 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
414 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
415 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
416 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
420 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
421 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
422 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
423 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
427 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
428 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
429 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
431 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
433 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
434 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
435 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
439 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
440 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
441 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
442 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
446 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
447 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
448 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
449 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
450 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
451 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
452 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
453 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
455 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
457 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
458 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
460 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
463 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
464 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
465 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
466 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
468 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
470 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
472 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
473 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
474 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
478 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
479 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
480 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
481 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
483 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
485 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
486 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
487 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
491 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
492 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
494 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
495 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
500 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
501 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
502 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
503 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
507 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
508 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
510 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
512 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
513 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
514 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
518 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
519 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
520 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
521 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
525 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
526 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
527 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
529 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
531 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
532 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
533 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
534 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
536 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
538 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
539 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
541 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
544 f8a36e22 2021-08-26 stsp test_send_tags() {
545 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
546 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
547 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
549 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
551 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
552 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
553 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
556 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
557 f8a36e22 2021-08-26 stsp remote "origin" {
558 f8a36e22 2021-08-26 stsp protocol ssh
559 f8a36e22 2021-08-26 stsp server 127.0.0.1
560 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
563 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
564 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
565 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
567 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
568 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
569 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
571 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
572 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
573 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
575 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
577 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
578 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
579 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
583 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
584 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
586 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
587 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
592 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
593 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
594 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
595 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
599 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
600 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
601 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
602 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
603 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
604 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
606 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
608 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
609 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
610 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
614 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
615 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
616 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
617 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
621 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
622 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
623 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
624 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
625 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
626 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
627 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
628 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
630 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
632 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
633 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
634 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
638 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
639 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
640 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
641 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
643 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
644 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
645 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
649 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
650 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
651 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
652 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
653 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
655 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
656 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
658 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
659 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
660 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
664 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
665 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
666 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
668 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
669 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
670 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
674 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
675 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
676 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
678 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
679 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
680 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
684 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
685 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
686 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
688 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
689 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
690 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
694 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
695 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
696 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
697 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
699 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
700 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
701 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
705 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
706 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
707 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
709 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
710 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
711 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
715 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
716 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
717 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
718 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
720 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
721 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
726 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
727 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
728 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
729 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
731 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
733 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
734 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
735 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
738 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
739 26960ff7 2021-09-14 stsp remote "origin" {
740 26960ff7 2021-09-14 stsp protocol ssh
741 26960ff7 2021-09-14 stsp server 127.0.0.1
742 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
745 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
747 26960ff7 2021-09-14 stsp # modify alpha on branch foo
748 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
749 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
750 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
751 26960ff7 2021-09-14 stsp > /dev/null)
752 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
754 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
755 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
756 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
757 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
759 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
760 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
762 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
763 26960ff7 2021-09-14 stsp # and the tag
764 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
765 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
766 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
768 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
770 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
771 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
772 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
776 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
777 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
779 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
780 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
781 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
785 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
786 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
787 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
788 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
792 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
793 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
794 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
795 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
796 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
797 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
798 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
799 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
800 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
802 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
804 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
805 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
806 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
810 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
811 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
812 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
813 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
817 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
818 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
819 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
820 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
821 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
822 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
823 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
825 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
827 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
828 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
829 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
833 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
834 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
836 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
838 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
839 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
844 f8a36e22 2021-08-26 stsp test_send_new_branch() {
845 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
846 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
847 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
849 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
851 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
853 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
854 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
855 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
859 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
860 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
861 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
862 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
863 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
865 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
867 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
868 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
869 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
873 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
874 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
876 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
877 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
882 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
883 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
884 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
885 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
889 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
890 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
891 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
893 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
895 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
896 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
901 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
902 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
903 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
904 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
908 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
909 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
910 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
911 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
912 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
913 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
914 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
915 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
916 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
917 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
918 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
919 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
920 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
922 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
924 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
925 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
927 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
930 f8a36e22 2021-08-26 stsp test_send_all_branches() {
931 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
932 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
933 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
935 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
937 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
939 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
940 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
941 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
945 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
946 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
947 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
948 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
950 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
951 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
952 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
953 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
954 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
956 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
957 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
958 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
959 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
960 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
962 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
963 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
964 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
965 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
969 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
970 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
971 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
972 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
974 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
975 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
977 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
978 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
979 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
982 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
983 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
984 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
986 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
987 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
988 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
992 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
993 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
995 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
996 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
997 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1001 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1002 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1004 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1005 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1006 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1010 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1011 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1012 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1013 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1017 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1018 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1019 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $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 ref -l -r $testroot/repo-clone > $testroot/stdout
1031 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1032 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1033 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1037 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1038 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1039 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1041 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1042 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1043 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1044 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1045 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1046 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1047 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1048 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1049 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1050 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1051 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1052 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1054 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1056 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1057 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1059 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1062 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1063 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1064 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1065 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1067 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1070 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1071 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1072 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1075 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1076 f8a36e22 2021-08-26 stsp remote "origin" {
1077 f8a36e22 2021-08-26 stsp protocol ssh
1078 f8a36e22 2021-08-26 stsp server 127.0.0.1
1079 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1082 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1083 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1084 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1086 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1088 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1090 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1094 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1095 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1097 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1098 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1099 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1103 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1104 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1106 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1107 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1108 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1109 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1113 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1114 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1115 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1116 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1118 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1120 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1121 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1122 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1126 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1127 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1128 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1129 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1133 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1134 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1136 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1138 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1139 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1140 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1144 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1146 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1147 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1148 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1152 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1153 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1154 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1156 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1157 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1159 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1162 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1163 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1164 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1165 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1167 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1169 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1170 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1171 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1175 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1176 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1177 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1179 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1180 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1181 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1182 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1184 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1185 6480c871 2021-08-30 stsp remote "origin" {
1186 6480c871 2021-08-30 stsp protocol ssh
1187 6480c871 2021-08-30 stsp server 127.0.0.1
1189 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1192 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1196 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1197 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1198 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1199 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1203 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1204 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1205 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1206 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1208 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1209 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1210 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1214 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1215 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1217 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1218 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1219 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1223 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1224 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1225 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1226 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1230 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1231 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1232 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1233 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1234 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1235 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1236 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1237 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1238 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1240 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1241 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1242 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1246 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1247 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1249 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1250 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1251 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1255 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1256 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1257 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1258 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1262 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1263 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1264 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1265 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1266 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1267 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1268 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1270 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1272 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1273 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1276 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1279 eac1df47 2021-09-01 stsp test_send_config() {
1280 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1281 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1282 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1284 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1286 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1287 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1288 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1292 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1293 eac1df47 2021-09-01 stsp remote "origin" {
1294 eac1df47 2021-09-01 stsp protocol ssh
1295 eac1df47 2021-09-01 stsp server 127.0.0.1
1296 eac1df47 2021-09-01 stsp branch foo
1297 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1300 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1301 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1302 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1303 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1307 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1308 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1309 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1310 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1311 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1312 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1314 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1316 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1317 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1318 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1322 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1324 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1326 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1327 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1328 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1332 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1333 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1334 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1335 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1339 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1340 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1341 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1342 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1343 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1344 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1345 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1347 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1349 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1350 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1352 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1355 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1356 f8a36e22 2021-08-26 stsp run_test test_send_basic
1357 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1358 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1359 f8a36e22 2021-08-26 stsp run_test test_send_delete
1360 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1361 f8a36e22 2021-08-26 stsp run_test test_send_tags
1362 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1363 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1364 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1365 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1366 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1367 eac1df47 2021-09-01 stsp run_test test_send_config