3 f8a36e22 2021-08-26 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 f8a36e22 2021-08-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp # copyright notice and this permission notice appear in all copies.
9 f8a36e22 2021-08-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 f8a36e22 2021-08-26 stsp . ./common.sh
19 f8a36e22 2021-08-26 stsp test_send_basic() {
20 f8a36e22 2021-08-26 stsp local testroot=`test_init send_basic`
21 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
22 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
24 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
26 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
27 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
28 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
31 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
32 f8a36e22 2021-08-26 stsp remote "origin" {
33 f8a36e22 2021-08-26 stsp protocol ssh
34 f8a36e22 2021-08-26 stsp server 127.0.0.1
35 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
38 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
42 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
43 08511b5e 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
44 08511b5e 2021-09-24 thomas (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
45 08511b5e 2021-09-24 thomas echo "new file alpha" > $testroot/repo/new
46 08511b5e 2021-09-24 thomas (cd $testroot/repo && git add new)
47 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
48 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
50 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
52 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
53 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
54 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
58 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
59 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
61 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
62 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
63 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
67 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
69 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
70 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
71 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
75 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
76 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
77 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
78 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
79 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
81 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
83 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
84 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
85 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
89 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
91 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
92 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
93 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
97 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
98 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
100 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
101 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
102 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
104 08511b5e 2021-09-24 thomas cmp -s $testroot/stdout $testroot/stdout.expected
106 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
107 08511b5e 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
108 08511b5e 2021-09-24 thomas test_done "$testroot" "$ret"
112 08511b5e 2021-09-24 thomas got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
113 08511b5e 2021-09-24 thomas > $testroot/stdout
114 08511b5e 2021-09-24 thomas got tree -r $testroot/repo -c $commit_id2 -i -R \
115 08511b5e 2021-09-24 thomas > $testroot/stdout.expected
116 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
118 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
119 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
120 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
124 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
126 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
127 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
128 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
132 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
133 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
134 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
135 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
138 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
143 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
145 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
148 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
149 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
150 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
151 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
153 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
155 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
156 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
157 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
160 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
161 f8a36e22 2021-08-26 stsp remote "origin" {
162 f8a36e22 2021-08-26 stsp protocol ssh
163 f8a36e22 2021-08-26 stsp server 127.0.0.1
164 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
167 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
168 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
169 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
171 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
172 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
173 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
175 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
177 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
178 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
179 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
183 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
184 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
186 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
187 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
188 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
192 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
193 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
194 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
196 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
197 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
198 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
202 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
204 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
207 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
208 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
209 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
210 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
212 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
214 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
215 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
216 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
219 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
220 f8a36e22 2021-08-26 stsp remote "foobar" {
221 f8a36e22 2021-08-26 stsp protocol ssh
222 f8a36e22 2021-08-26 stsp server 127.0.0.1
223 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
226 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
227 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
228 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
230 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
231 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
232 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
233 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
235 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
236 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
237 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
239 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
240 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
241 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
244 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
245 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
246 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
248 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
249 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
250 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
254 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
255 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
257 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
258 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
259 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
263 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
264 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
266 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
267 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
268 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
272 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
274 fc414659 2022-04-16 thomas if [ $ret -ne 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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
281 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
282 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
283 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
285 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
287 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
288 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
289 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
293 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
295 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
296 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
297 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
301 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
302 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
303 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
304 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
305 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
306 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
307 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
308 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
309 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
310 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
312 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
314 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
315 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
316 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
320 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
322 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
325 38bad86b 2023-04-22 thomas test_send_merge_commit() {
326 38bad86b 2023-04-22 thomas local testroot=`test_init send_merge_commit`
327 38bad86b 2023-04-22 thomas local testurl=ssh://127.0.0.1/$testroot
329 38bad86b 2023-04-22 thomas if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
330 38bad86b 2023-04-22 thomas echo "got clone command failed unexpectedly" >&2
331 38bad86b 2023-04-22 thomas test_done "$testroot" 1
335 38bad86b 2023-04-22 thomas echo 'upstream change' > $testroot/repo/alpha
336 38bad86b 2023-04-22 thomas git_commit $testroot/repo -m 'upstream change'
338 38bad86b 2023-04-22 thomas got checkout $testroot/repo-clone $testroot/wt-clone > /dev/null
339 38bad86b 2023-04-22 thomas echo 'downstream change' > $testroot/wt-clone/beta
340 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got commit -m 'downstream change' > /dev/null)
342 38bad86b 2023-04-22 thomas got fetch -q -r $testroot/repo-clone
343 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got update > /dev/null)
344 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got merge origin/master > /dev/null)
346 38bad86b 2023-04-22 thomas if [ $ret -ne 0 ]; then
347 38bad86b 2023-04-22 thomas echo "got merge command failed unexpectedly" >&2
348 38bad86b 2023-04-22 thomas test_done "$testroot" "$ret"
352 38bad86b 2023-04-22 thomas (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
354 38bad86b 2023-04-22 thomas got send -q -r $testroot/repo-clone
356 38bad86b 2023-04-22 thomas if [ $ret -ne 0 ]; then
357 38bad86b 2023-04-22 thomas test_done "$testroot" "$ret"
361 38bad86b 2023-04-22 thomas test_done "$testroot" 0
364 f8a36e22 2021-08-26 stsp test_send_delete() {
365 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
366 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
367 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
369 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
370 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
372 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
374 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
375 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
376 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
379 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
380 f8a36e22 2021-08-26 stsp remote "origin" {
381 f8a36e22 2021-08-26 stsp protocol ssh
382 f8a36e22 2021-08-26 stsp server 127.0.0.1
383 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
386 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
387 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
389 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
391 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
392 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
393 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
397 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
398 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
399 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
400 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
402 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
403 f8a36e22 2021-08-26 stsp # time is not allowed.
404 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
405 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
407 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
408 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
409 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
412 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
413 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
414 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
415 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
417 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
418 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
419 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
423 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
424 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
426 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
427 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
428 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
432 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
433 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
435 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
436 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
437 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
441 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
442 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
443 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
444 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
446 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
448 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
449 1bd76734 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 # branchX exists in neither repository
455 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
456 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
458 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
459 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
460 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
463 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
464 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
465 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
466 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
467 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
469 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
470 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
471 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
475 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
476 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
477 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
479 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
480 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
481 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
484 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
485 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
486 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
487 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
488 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
489 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
491 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
492 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
493 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
497 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
499 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
500 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
501 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
505 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
506 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
507 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
509 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
511 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
512 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
513 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
517 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
519 fc414659 2022-04-16 thomas if [ $ret -ne 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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
526 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
527 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
528 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
529 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
530 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
531 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
532 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
534 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
536 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
537 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
538 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
542 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
544 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
547 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
548 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
549 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
550 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
552 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
554 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
556 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
557 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
558 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
562 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
563 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
564 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
565 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
567 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
569 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
570 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
571 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
575 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
576 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
578 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
579 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
580 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
584 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
586 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
587 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
588 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
592 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
593 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
595 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
597 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
598 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
599 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
603 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
605 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
606 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
607 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
611 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
612 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
613 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
614 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
615 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
616 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
617 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
618 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
619 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
620 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
622 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
624 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
625 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
626 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
630 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
632 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
635 f8a36e22 2021-08-26 stsp test_send_tags() {
636 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
637 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
638 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
640 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
642 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
643 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
644 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
647 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
648 f8a36e22 2021-08-26 stsp remote "origin" {
649 f8a36e22 2021-08-26 stsp protocol ssh
650 f8a36e22 2021-08-26 stsp server 127.0.0.1
651 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
654 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
655 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
656 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
658 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
659 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
660 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
662 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
663 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
664 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
666 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
668 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
669 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
670 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
674 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
675 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
677 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
678 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
679 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
683 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
685 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
686 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
687 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
691 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
692 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
693 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
694 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
695 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
696 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
698 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
700 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
701 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
702 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
706 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
708 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
709 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
710 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
714 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
715 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
716 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
717 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
718 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
719 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
720 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
721 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
723 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
725 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
726 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
727 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
731 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
732 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
733 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
734 4064588e 2021-10-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
736 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
737 4064588e 2021-10-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
738 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
742 4064588e 2021-10-17 thomas # Send the same tags again. This should be a no-op.
743 4064588e 2021-10-17 thomas got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
745 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
746 4064588e 2021-10-17 thomas echo "got send command failed unexpectedly" >&2
747 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
751 4064588e 2021-10-17 thomas echo -n > $testroot/stdout.expected
752 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
754 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
755 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
756 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
760 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
761 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
762 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
763 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
764 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
766 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
767 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
769 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
770 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
771 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
775 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
776 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
777 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
779 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
780 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
781 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
785 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
786 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
787 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
789 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
790 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
791 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
795 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
796 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
797 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
799 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
800 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
801 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
805 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
806 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
807 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
808 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
810 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
811 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
812 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
816 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
817 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
818 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
820 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
821 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
822 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
826 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
827 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
828 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
829 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
831 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
832 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
833 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
837 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
838 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
839 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
841 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
842 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
843 c2105d00 2021-09-14 stsp 2> $testroot/stderr
845 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
846 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
847 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
851 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
852 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
853 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
854 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
855 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
857 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
858 c2105d00 2021-09-14 stsp 2> $testroot/stderr
860 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
861 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
862 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
865 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
866 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
867 c2105d00 2021-09-14 stsp $testroot/stdout; then
868 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
869 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
870 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
874 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
876 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
879 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
880 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
881 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
882 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
884 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
886 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
887 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
888 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
891 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
892 26960ff7 2021-09-14 stsp remote "origin" {
893 26960ff7 2021-09-14 stsp protocol ssh
894 26960ff7 2021-09-14 stsp server 127.0.0.1
895 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
898 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
900 13eb256c 2022-05-31 thomas # modify beta on branch foo
901 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
902 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
903 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
904 13eb256c 2022-05-31 thomas > /dev/null)
905 13eb256c 2022-05-31 thomas echo buu >> $testroot/wt/beta
906 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
907 26960ff7 2021-09-14 stsp > /dev/null)
908 13eb256c 2022-05-31 thomas echo baa >> $testroot/wt/beta
909 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
910 13eb256c 2022-05-31 thomas > /dev/null)
911 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
913 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
914 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
915 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
916 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
918 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
919 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
921 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
922 26960ff7 2021-09-14 stsp # and the tag
923 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
924 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
925 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
927 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
929 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
930 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
931 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
935 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
936 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
938 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
939 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
940 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
944 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
946 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
947 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
948 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
952 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
953 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
954 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
955 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
956 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
957 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
958 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
959 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
960 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
962 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
964 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
965 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
966 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
970 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
972 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
973 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
974 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
978 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
979 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
980 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
981 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
982 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
983 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
984 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
986 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
988 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
989 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
990 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
994 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
995 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
997 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
999 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1000 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1001 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1005 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1007 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
1010 f8a36e22 2021-08-26 stsp test_send_new_branch() {
1011 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
1012 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1013 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1015 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1017 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1019 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1020 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1021 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1025 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1026 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
1027 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1028 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1029 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
1031 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
1033 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1034 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1035 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1039 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1042 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1043 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1048 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1050 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1051 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1052 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1056 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1057 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1058 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1060 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1062 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1063 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1064 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1068 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1070 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1071 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1072 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1076 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1077 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1078 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1079 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1080 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1081 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1082 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1083 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1084 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1085 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1086 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1087 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1088 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1090 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1092 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1093 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1094 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1098 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1100 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1103 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1104 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1105 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1106 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1108 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1110 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1112 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1113 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1114 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1118 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1119 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1120 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1121 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1123 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1124 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1125 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1126 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1127 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1129 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1130 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1131 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1132 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1133 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1135 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1138 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1139 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1143 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1144 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1145 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1146 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1148 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1149 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1151 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1152 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1153 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
1156 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1157 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1158 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1160 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1161 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1162 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1166 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1167 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1169 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1170 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1171 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1175 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1176 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1178 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1179 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1180 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1184 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1186 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1187 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1188 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1192 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1193 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1194 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1195 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1197 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1199 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1200 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1201 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1205 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1207 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1208 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1209 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1213 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1214 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1215 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1216 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1217 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1218 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1219 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1220 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1221 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1222 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1223 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1224 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1225 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1226 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1227 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1228 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1230 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1232 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1233 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1234 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1238 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1240 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1243 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1244 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1245 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1246 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1248 27b10c3c 2022-07-04 thomas gotadmin init $testroot/repo2
1251 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1252 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1253 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1256 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1257 f8a36e22 2021-08-26 stsp remote "origin" {
1258 f8a36e22 2021-08-26 stsp protocol ssh
1259 f8a36e22 2021-08-26 stsp server 127.0.0.1
1260 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1263 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1264 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1265 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1267 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1269 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1270 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1271 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1275 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1276 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1278 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1279 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1280 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1284 27b10c3c 2022-07-04 thomas # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1285 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1287 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1289 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1290 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1291 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1295 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1296 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1297 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1298 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1300 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1302 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1303 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1304 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1308 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1310 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1311 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1312 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1316 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1317 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1319 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1321 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1322 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1323 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1327 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1329 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1330 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1331 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1335 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1336 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
1337 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1338 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1340 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1341 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1342 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1346 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1348 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1351 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1352 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1353 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1354 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1356 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1358 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1359 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1360 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1364 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1365 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1366 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1368 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1369 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1370 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1371 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1373 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1374 6480c871 2021-08-30 stsp remote "origin" {
1375 6480c871 2021-08-30 stsp protocol ssh
1376 6480c871 2021-08-30 stsp server 127.0.0.1
1378 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1381 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1385 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1387 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1388 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1389 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1393 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1394 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1395 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1396 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1398 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1399 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1400 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1404 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1405 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1407 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1408 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1409 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1413 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1415 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1416 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1417 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1421 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1422 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1423 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1424 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1425 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1426 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1427 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1428 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1429 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1431 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1432 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1433 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1437 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1438 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1440 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1441 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1442 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1446 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1448 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1449 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1450 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1454 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1455 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1456 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1457 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1458 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1459 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1460 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1462 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1465 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1470 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1472 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1475 eac1df47 2021-09-01 stsp test_send_config() {
1476 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1477 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1478 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1480 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1482 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1483 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1484 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1488 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1489 eac1df47 2021-09-01 stsp remote "origin" {
1490 eac1df47 2021-09-01 stsp protocol ssh
1491 eac1df47 2021-09-01 stsp server 127.0.0.1
1492 eac1df47 2021-09-01 stsp branch foo
1493 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1496 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1498 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1499 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1500 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1504 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1505 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1506 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1507 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1508 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1509 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1511 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1513 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1514 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1515 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1519 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1521 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1523 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1524 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1525 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1529 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1531 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1532 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1533 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1537 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1538 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1539 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1540 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1541 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1542 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1543 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1545 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1547 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1548 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1549 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1553 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1555 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1558 3fe5d0fe 2022-11-17 thomas test_send_rejected() {
1559 3fe5d0fe 2022-11-17 thomas local testroot=`test_init send_rejected`
1560 3fe5d0fe 2022-11-17 thomas local testurl=ssh://127.0.0.1/$testroot
1561 3fe5d0fe 2022-11-17 thomas local commit_id=`git_show_head $testroot/repo`
1563 3fe5d0fe 2022-11-17 thomas if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
1564 3fe5d0fe 2022-11-17 thomas echo "got clone command failed unexpectedly" >&2
1565 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1566 3fe5d0fe 2022-11-17 thomas return 1
1569 3fe5d0fe 2022-11-17 thomas mkdir "$testroot/repo-clone/hooks"
1570 3fe5d0fe 2022-11-17 thomas cat <<'EOF' >$testroot/repo-clone/hooks/update
1571 3fe5d0fe 2022-11-17 thomas case "$1" in
1572 3fe5d0fe 2022-11-17 thomas *master*)
1573 3fe5d0fe 2022-11-17 thomas echo "rejecting push on master branch"
1579 3fe5d0fe 2022-11-17 thomas chmod +x "$testroot/repo-clone/hooks/update"
1581 3fe5d0fe 2022-11-17 thomas cat > $testroot/repo/.git/got.conf <<EOF
1582 3fe5d0fe 2022-11-17 thomas remote "origin" {
1583 3fe5d0fe 2022-11-17 thomas protocol ssh
1584 3fe5d0fe 2022-11-17 thomas server 127.0.0.1
1585 3fe5d0fe 2022-11-17 thomas repository "$testroot/repo-clone"
1589 3fe5d0fe 2022-11-17 thomas echo "modified alpha" >$testroot/repo/alpha
1590 3fe5d0fe 2022-11-17 thomas git_commit "$testroot/repo" -m "modified alpha"
1592 3fe5d0fe 2022-11-17 thomas got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
1594 3fe5d0fe 2022-11-17 thomas if [ $ret -ne 0 ]; then
1595 3fe5d0fe 2022-11-17 thomas echo "got send command failed unexpectedly" >&2
1596 3fe5d0fe 2022-11-17 thomas test_done "$testroot" $ret
1597 3fe5d0fe 2022-11-17 thomas return 1
1600 3fe5d0fe 2022-11-17 thomas touch "$testroot/stdout.expected"
1601 3fe5d0fe 2022-11-17 thomas if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1602 3fe5d0fe 2022-11-17 thomas diff -u "$testroot/stdout.expected" "$testroot/stdout"
1603 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1604 3fe5d0fe 2022-11-17 thomas return 1
1607 3fe5d0fe 2022-11-17 thomas cat <<EOF >$testroot/stderr.expected
1608 3fe5d0fe 2022-11-17 thomas rejecting push on master branch
1609 3fe5d0fe 2022-11-17 thomas error: hook declined to update refs/heads/master
1612 3fe5d0fe 2022-11-17 thomas if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1613 3fe5d0fe 2022-11-17 thomas diff -u "$testroot/stderr.expected" "$testroot/stderr"
1614 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1615 3fe5d0fe 2022-11-17 thomas return 1
1618 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 0
1621 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1622 f8a36e22 2021-08-26 stsp run_test test_send_basic
1623 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1624 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1625 38bad86b 2023-04-22 thomas run_test test_send_merge_commit
1626 f8a36e22 2021-08-26 stsp run_test test_send_delete
1627 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1628 f8a36e22 2021-08-26 stsp run_test test_send_tags
1629 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1630 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1631 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1632 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1633 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1634 eac1df47 2021-09-01 stsp run_test test_send_config
1635 3fe5d0fe 2022-11-17 thomas run_test test_send_rejected