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 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
44 d1e03b8c 2023-10-08 thomas (cd $testroot/repo && ln -s epsilon/zeta symlink)
45 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add symlink
46 08511b5e 2021-09-24 thomas echo "new file alpha" > $testroot/repo/new
47 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add new
48 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
49 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
51 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
53 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
54 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
55 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
59 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
60 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
62 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
63 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
64 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
68 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
70 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
71 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
72 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
76 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
77 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
78 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
79 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
80 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
82 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
84 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
85 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
86 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
90 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
92 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
93 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
94 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
98 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
100 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
101 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
102 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
103 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
105 08511b5e 2021-09-24 thomas cmp -s $testroot/stdout $testroot/stdout.expected
107 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
108 08511b5e 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
109 08511b5e 2021-09-24 thomas test_done "$testroot" "$ret"
113 08511b5e 2021-09-24 thomas got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
114 08511b5e 2021-09-24 thomas > $testroot/stdout
115 08511b5e 2021-09-24 thomas got tree -r $testroot/repo -c $commit_id2 -i -R \
116 08511b5e 2021-09-24 thomas > $testroot/stdout.expected
117 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
119 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
120 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
121 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
125 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
127 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
128 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
129 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
133 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
134 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
135 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
136 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
138 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
139 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
140 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
144 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
146 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
149 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
150 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
151 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
152 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
154 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
156 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
157 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
158 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
161 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
162 f8a36e22 2021-08-26 stsp remote "origin" {
163 f8a36e22 2021-08-26 stsp protocol ssh
164 f8a36e22 2021-08-26 stsp server 127.0.0.1
165 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
168 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
169 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
170 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
172 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
173 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
174 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
176 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
178 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
179 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
180 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
184 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
185 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
187 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
188 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
193 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
194 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
195 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
197 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
198 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
199 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
203 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
205 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
208 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
209 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
210 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
211 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
213 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
215 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
216 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
217 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
220 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
221 f8a36e22 2021-08-26 stsp remote "foobar" {
222 f8a36e22 2021-08-26 stsp protocol ssh
223 f8a36e22 2021-08-26 stsp server 127.0.0.1
224 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
227 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
228 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
229 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
231 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
232 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
233 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
234 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
236 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
237 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
238 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
240 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
241 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
242 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
245 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
246 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
247 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
249 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
250 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
251 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
255 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
256 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
258 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
259 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
260 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
264 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
265 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
267 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
268 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
269 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
273 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
275 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
276 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
277 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
281 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
282 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
283 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
284 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
286 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
288 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
289 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
290 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
294 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
296 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
297 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
298 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
302 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
303 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
304 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
305 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
306 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
307 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
308 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
309 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
310 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
311 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
313 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
315 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
316 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
321 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
323 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
326 38bad86b 2023-04-22 thomas test_send_merge_commit() {
327 38bad86b 2023-04-22 thomas local testroot=`test_init send_merge_commit`
328 38bad86b 2023-04-22 thomas local testurl=ssh://127.0.0.1/$testroot
330 38bad86b 2023-04-22 thomas if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
331 38bad86b 2023-04-22 thomas echo "got clone command failed unexpectedly" >&2
332 38bad86b 2023-04-22 thomas test_done "$testroot" 1
336 38bad86b 2023-04-22 thomas echo 'upstream change' > $testroot/repo/alpha
337 38bad86b 2023-04-22 thomas git_commit $testroot/repo -m 'upstream change'
339 38bad86b 2023-04-22 thomas got checkout $testroot/repo-clone $testroot/wt-clone > /dev/null
340 38bad86b 2023-04-22 thomas echo 'downstream change' > $testroot/wt-clone/beta
341 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got commit -m 'downstream change' > /dev/null)
343 38bad86b 2023-04-22 thomas got fetch -q -r $testroot/repo-clone
344 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got update > /dev/null)
345 38bad86b 2023-04-22 thomas (cd $testroot/wt-clone && got merge origin/master > /dev/null)
347 38bad86b 2023-04-22 thomas if [ $ret -ne 0 ]; then
348 38bad86b 2023-04-22 thomas echo "got merge command failed unexpectedly" >&2
349 38bad86b 2023-04-22 thomas test_done "$testroot" "$ret"
353 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config receive.denyCurrentBranch ignore
355 38bad86b 2023-04-22 thomas got send -q -r $testroot/repo-clone
357 38bad86b 2023-04-22 thomas if [ $ret -ne 0 ]; then
358 38bad86b 2023-04-22 thomas test_done "$testroot" "$ret"
362 38bad86b 2023-04-22 thomas test_done "$testroot" 0
365 f8a36e22 2021-08-26 stsp test_send_delete() {
366 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
367 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
368 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
370 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
371 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
373 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
375 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
376 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
377 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
380 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
381 f8a36e22 2021-08-26 stsp remote "origin" {
382 f8a36e22 2021-08-26 stsp protocol ssh
383 f8a36e22 2021-08-26 stsp server 127.0.0.1
384 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
387 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
388 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
390 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
392 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
393 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
394 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
398 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
399 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
400 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
401 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
403 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
404 f8a36e22 2021-08-26 stsp # time is not allowed.
405 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
406 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
408 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
409 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
410 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
413 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
414 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
415 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
416 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
418 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
419 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
424 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
425 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
427 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
428 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
429 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
433 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
434 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
436 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
437 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
438 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
442 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
443 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
444 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
445 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
447 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
449 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
450 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
451 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
455 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
456 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
457 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
459 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
460 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
461 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
464 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
465 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
466 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
467 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
468 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
470 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
471 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
472 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
476 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
477 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
478 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
480 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
481 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
482 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
485 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
486 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
487 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
488 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
489 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
490 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
492 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
493 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
494 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
498 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
500 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
501 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
502 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
506 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
507 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
508 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
510 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
512 fc414659 2022-04-16 thomas if [ $ret -ne 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
520 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
521 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
522 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
526 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
527 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
529 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
531 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
532 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
533 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
535 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
537 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
538 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
543 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
545 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
548 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
549 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
550 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
551 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
553 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config receive.denyCurrentBranch ignore
555 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
557 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
558 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
559 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
563 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
564 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
565 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
566 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
568 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
570 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
571 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
572 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
576 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
577 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
579 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
580 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
581 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
585 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
587 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
588 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
589 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
593 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
594 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
596 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
598 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
599 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
600 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
604 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
606 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
607 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
608 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
612 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
613 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
614 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
615 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
616 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
617 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
618 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
619 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
620 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
621 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
623 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
625 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
626 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
627 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
631 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
633 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
636 f8a36e22 2021-08-26 stsp test_send_tags() {
637 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
638 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
639 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
641 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
643 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
644 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
645 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
648 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
649 f8a36e22 2021-08-26 stsp remote "origin" {
650 f8a36e22 2021-08-26 stsp protocol ssh
651 f8a36e22 2021-08-26 stsp server 127.0.0.1
652 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
655 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
656 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
657 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
659 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
660 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
661 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
663 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
664 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
665 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
667 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
669 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
670 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
671 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
675 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
676 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
678 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
679 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
680 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
684 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
686 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
687 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
688 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
692 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
693 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
694 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
695 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
696 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
697 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
699 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
701 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
702 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
703 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
707 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
709 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
710 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
711 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
715 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
716 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
717 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
718 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
719 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
720 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
721 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
722 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
724 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
726 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
727 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
732 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
733 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
734 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
735 4064588e 2021-10-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
737 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
738 4064588e 2021-10-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
739 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
743 4064588e 2021-10-17 thomas # Send the same tags again. This should be a no-op.
744 4064588e 2021-10-17 thomas got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
746 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
747 4064588e 2021-10-17 thomas echo "got send command failed unexpectedly" >&2
748 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
752 4064588e 2021-10-17 thomas echo -n > $testroot/stdout.expected
753 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
755 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
756 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
761 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
762 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
763 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
764 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
765 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
767 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
768 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
770 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
771 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
772 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
776 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
777 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
778 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
780 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
781 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
782 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
786 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
787 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
788 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
790 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
791 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
792 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
796 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
797 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
798 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
800 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
801 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
802 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
806 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
807 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
808 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
809 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
811 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
812 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
817 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
818 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
819 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
821 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
822 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
823 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
827 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
828 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
829 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
830 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
832 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
833 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
834 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
838 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
839 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
840 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
842 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
843 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
844 c2105d00 2021-09-14 stsp 2> $testroot/stderr
846 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
847 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
848 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
852 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
853 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
854 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
855 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
856 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
858 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
859 c2105d00 2021-09-14 stsp 2> $testroot/stderr
861 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
862 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
863 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
866 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
867 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
868 c2105d00 2021-09-14 stsp $testroot/stdout; then
869 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
870 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
871 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
875 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
877 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
880 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
881 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
882 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
883 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
885 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
887 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
888 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
889 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
892 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
893 26960ff7 2021-09-14 stsp remote "origin" {
894 26960ff7 2021-09-14 stsp protocol ssh
895 26960ff7 2021-09-14 stsp server 127.0.0.1
896 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
899 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
901 13eb256c 2022-05-31 thomas # modify beta on branch foo
902 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
903 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
904 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
905 13eb256c 2022-05-31 thomas > /dev/null)
906 13eb256c 2022-05-31 thomas echo buu >> $testroot/wt/beta
907 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
908 26960ff7 2021-09-14 stsp > /dev/null)
909 13eb256c 2022-05-31 thomas echo baa >> $testroot/wt/beta
910 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
911 13eb256c 2022-05-31 thomas > /dev/null)
912 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
914 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
915 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
916 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
917 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
919 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
920 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
922 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
923 26960ff7 2021-09-14 stsp # and the tag
924 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
925 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
926 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
928 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
930 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
931 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
932 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
936 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
937 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
939 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
940 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
945 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
947 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
948 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
949 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
953 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
954 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
955 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
956 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
957 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
958 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
959 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
960 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
961 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
963 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
965 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
966 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
967 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
971 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
973 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
974 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
975 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
979 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
980 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
981 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
982 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
983 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
984 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
985 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
987 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
989 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
990 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
991 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
995 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
996 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
998 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1000 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1001 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1006 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1008 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
1011 f8a36e22 2021-08-26 stsp test_send_new_branch() {
1012 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
1013 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1014 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1016 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config receive.denyCurrentBranch ignore
1018 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1020 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1021 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1022 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1026 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1027 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
1028 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1029 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1030 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
1032 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
1034 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1035 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1036 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1040 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1041 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1043 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1044 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1045 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1049 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1051 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1052 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1053 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1057 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1058 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1059 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1061 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1063 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1064 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1065 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1069 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1071 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1072 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1073 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1077 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1078 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1079 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1080 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1081 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1082 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1083 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1084 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1085 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1086 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1087 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1088 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1089 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1091 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1093 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1094 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1095 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1099 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1101 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1104 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1105 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1106 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1107 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1109 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config receive.denyCurrentBranch ignore
1111 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1113 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1114 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1115 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1119 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1120 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1121 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1122 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1124 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1125 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1126 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1127 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1128 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1130 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1131 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1132 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1133 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1134 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1136 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1138 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1139 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1140 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1144 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1145 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1146 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1147 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1149 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1150 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1152 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1153 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1154 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
1157 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1158 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1159 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1161 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1162 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1163 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1167 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1168 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1170 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1171 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1172 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1176 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1177 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1179 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1180 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1185 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1187 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1188 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1189 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1193 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1194 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1195 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1196 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1198 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1200 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1201 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1202 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1206 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1208 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1209 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1210 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1214 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1215 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1216 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1217 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1218 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1219 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1220 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1221 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1222 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1223 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1224 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1225 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1226 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1227 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1228 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1229 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1231 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1233 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1234 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1239 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1241 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1244 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1245 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1246 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1247 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1249 27b10c3c 2022-07-04 thomas gotadmin init $testroot/repo2
1252 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1253 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1254 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1257 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1258 f8a36e22 2021-08-26 stsp remote "origin" {
1259 f8a36e22 2021-08-26 stsp protocol ssh
1260 f8a36e22 2021-08-26 stsp server 127.0.0.1
1261 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1264 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1265 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1266 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1268 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1270 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1271 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1272 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1276 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1277 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1279 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1280 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1281 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1285 27b10c3c 2022-07-04 thomas # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1286 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1288 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1290 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1291 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1292 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1296 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1297 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1298 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1299 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1301 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1303 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1304 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1305 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1309 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1311 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1312 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1313 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1317 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1318 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1320 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1322 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1323 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1324 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1328 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1330 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1331 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1332 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1336 6df5d941 2022-11-18 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1337 6df5d941 2022-11-18 thomas > $testroot/stdout.expected
1338 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1339 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1341 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1342 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1343 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1347 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1349 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1352 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1353 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1354 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1355 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1357 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1359 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1360 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1361 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1365 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1366 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1367 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1369 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1370 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1371 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1372 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1374 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1375 6480c871 2021-08-30 stsp remote "origin" {
1376 6480c871 2021-08-30 stsp protocol ssh
1377 6480c871 2021-08-30 stsp server 127.0.0.1
1379 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1382 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1386 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1388 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1389 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1390 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1394 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1395 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1396 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1397 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1399 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1400 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1401 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1405 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1406 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1408 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1409 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1410 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1414 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1416 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1417 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1418 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1422 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1423 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1424 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1425 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1426 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1427 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1428 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1429 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1430 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1432 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1433 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1434 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1438 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1439 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1441 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1442 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1443 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1447 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1449 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1450 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1451 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1455 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1456 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1457 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1458 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1459 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1460 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1461 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1463 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1465 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1466 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1467 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1471 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1473 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1476 eac1df47 2021-09-01 stsp test_send_config() {
1477 a56c54fb 2023-09-14 thomas local testroot=`test_init send_config`
1478 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1479 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1481 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1483 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1484 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1485 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1489 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1490 eac1df47 2021-09-01 stsp remote "origin" {
1491 eac1df47 2021-09-01 stsp protocol ssh
1492 eac1df47 2021-09-01 stsp server 127.0.0.1
1493 eac1df47 2021-09-01 stsp branch foo
1494 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1497 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1499 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1500 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1501 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1505 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1506 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1507 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1508 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1509 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1510 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1512 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1514 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1515 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1516 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1520 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1522 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1524 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1525 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1526 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1530 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1532 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1533 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1534 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1538 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1539 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1540 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1541 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1542 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1543 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1544 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1546 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1548 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1549 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1550 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1554 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1556 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1559 3fe5d0fe 2022-11-17 thomas test_send_rejected() {
1560 3fe5d0fe 2022-11-17 thomas local testroot=`test_init send_rejected`
1561 3fe5d0fe 2022-11-17 thomas local testurl=ssh://127.0.0.1/$testroot
1562 3fe5d0fe 2022-11-17 thomas local commit_id=`git_show_head $testroot/repo`
1564 3fe5d0fe 2022-11-17 thomas if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
1565 3fe5d0fe 2022-11-17 thomas echo "got clone command failed unexpectedly" >&2
1566 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1567 3fe5d0fe 2022-11-17 thomas return 1
1570 3fe5d0fe 2022-11-17 thomas mkdir "$testroot/repo-clone/hooks"
1571 3fe5d0fe 2022-11-17 thomas cat <<'EOF' >$testroot/repo-clone/hooks/update
1572 3fe5d0fe 2022-11-17 thomas case "$1" in
1573 3fe5d0fe 2022-11-17 thomas *master*)
1574 3fe5d0fe 2022-11-17 thomas echo "rejecting push on master branch"
1580 3fe5d0fe 2022-11-17 thomas chmod +x "$testroot/repo-clone/hooks/update"
1582 3fe5d0fe 2022-11-17 thomas cat > $testroot/repo/.git/got.conf <<EOF
1583 3fe5d0fe 2022-11-17 thomas remote "origin" {
1584 3fe5d0fe 2022-11-17 thomas protocol ssh
1585 3fe5d0fe 2022-11-17 thomas server 127.0.0.1
1586 3fe5d0fe 2022-11-17 thomas repository "$testroot/repo-clone"
1590 3fe5d0fe 2022-11-17 thomas echo "modified alpha" >$testroot/repo/alpha
1591 3fe5d0fe 2022-11-17 thomas git_commit "$testroot/repo" -m "modified alpha"
1593 3fe5d0fe 2022-11-17 thomas got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
1595 3fe5d0fe 2022-11-17 thomas if [ $ret -ne 0 ]; then
1596 3fe5d0fe 2022-11-17 thomas echo "got send command failed unexpectedly" >&2
1597 3fe5d0fe 2022-11-17 thomas test_done "$testroot" $ret
1598 3fe5d0fe 2022-11-17 thomas return 1
1601 3fe5d0fe 2022-11-17 thomas touch "$testroot/stdout.expected"
1602 3fe5d0fe 2022-11-17 thomas if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1603 3fe5d0fe 2022-11-17 thomas diff -u "$testroot/stdout.expected" "$testroot/stdout"
1604 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1605 3fe5d0fe 2022-11-17 thomas return 1
1608 3fe5d0fe 2022-11-17 thomas cat <<EOF >$testroot/stderr.expected
1609 3fe5d0fe 2022-11-17 thomas rejecting push on master branch
1610 3fe5d0fe 2022-11-17 thomas error: hook declined to update refs/heads/master
1613 3fe5d0fe 2022-11-17 thomas if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1614 3fe5d0fe 2022-11-17 thomas diff -u "$testroot/stderr.expected" "$testroot/stderr"
1615 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 1
1616 3fe5d0fe 2022-11-17 thomas return 1
1619 3fe5d0fe 2022-11-17 thomas test_done "$testroot" 0
1622 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1623 f8a36e22 2021-08-26 stsp run_test test_send_basic
1624 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1625 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1626 38bad86b 2023-04-22 thomas run_test test_send_merge_commit
1627 f8a36e22 2021-08-26 stsp run_test test_send_delete
1628 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1629 f8a36e22 2021-08-26 stsp run_test test_send_tags
1630 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1631 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1632 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1633 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1634 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1635 eac1df47 2021-09-01 stsp run_test test_send_config
1636 3fe5d0fe 2022-11-17 thomas run_test test_send_rejected