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 49c543a6 2022-03-31 naddy 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 3af9de88 2021-09-22 stsp (cd $testroot/repo && git rm -q beta)
44 3af9de88 2021-09-22 stsp (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
45 3af9de88 2021-09-22 stsp echo "new file alpha" > $testroot/repo/new
46 3af9de88 2021-09-22 stsp (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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 3af9de88 2021-09-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
106 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
107 3af9de88 2021-09-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
108 3af9de88 2021-09-22 stsp test_done "$testroot" "$ret"
112 3af9de88 2021-09-22 stsp got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
113 3af9de88 2021-09-22 stsp > $testroot/stdout
114 3af9de88 2021-09-22 stsp got tree -r $testroot/repo -c $commit_id2 -i -R \
115 3af9de88 2021-09-22 stsp > $testroot/stdout.expected
116 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
118 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
133 0deb9607 2022-11-18 op > $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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
178 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
179 a19f439c 2022-06-03 op 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
240 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
241 a19f439c 2022-06-03 op 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 f8a36e22 2021-08-26 stsp test_send_delete() {
326 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
327 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
328 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
330 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
331 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
333 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
335 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
336 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
337 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
340 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
341 f8a36e22 2021-08-26 stsp remote "origin" {
342 f8a36e22 2021-08-26 stsp protocol ssh
343 f8a36e22 2021-08-26 stsp server 127.0.0.1
344 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
347 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
348 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
350 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
353 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
354 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
358 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
359 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
360 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
361 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
363 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
364 f8a36e22 2021-08-26 stsp # time is not allowed.
365 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
366 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
368 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
369 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
370 a19f439c 2022-06-03 op test_done "$testroot" 1
373 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
374 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
375 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
376 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
379 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
380 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
384 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
385 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
387 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
388 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
389 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
393 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
394 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
396 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
397 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
398 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
402 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
403 0deb9607 2022-11-18 op > $testroot/stdout.expected
404 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
405 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
407 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
410 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
411 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
415 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
416 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
417 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
419 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
420 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
421 a19f439c 2022-06-03 op test_done "$testroot" 1
424 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
425 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
426 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
427 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
428 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
430 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
431 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
432 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
436 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
437 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
438 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
440 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
441 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
442 a19f439c 2022-06-03 op test_done "$testroot" 1
445 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
446 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
447 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
448 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
449 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
450 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
453 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
454 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
458 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
460 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
461 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
462 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
466 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
467 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
468 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
470 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
472 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
473 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
474 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
478 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
480 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
481 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
482 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
486 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
487 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
488 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
489 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
490 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
491 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
492 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
493 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
495 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
497 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
498 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
499 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
503 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
505 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
508 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
509 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
510 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
511 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
513 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
515 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
517 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
518 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
519 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
523 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
524 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
525 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
526 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
528 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
530 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
531 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
532 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
536 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
537 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
539 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
540 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
541 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
545 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
549 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
553 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
554 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
556 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
558 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
559 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
564 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
566 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
567 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
568 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
572 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
573 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
574 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
575 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
576 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
577 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
578 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
579 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
580 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
581 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
583 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
585 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
586 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
587 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
591 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
593 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
596 f8a36e22 2021-08-26 stsp test_send_tags() {
597 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
598 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
599 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
601 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
603 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
604 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
605 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
608 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
609 f8a36e22 2021-08-26 stsp remote "origin" {
610 f8a36e22 2021-08-26 stsp protocol ssh
611 f8a36e22 2021-08-26 stsp server 127.0.0.1
612 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
615 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
616 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
617 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
619 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
620 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
621 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
623 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
624 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
625 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
627 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
629 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
630 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
631 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
635 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
636 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
638 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
639 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
640 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
644 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
647 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
648 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
652 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
653 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
654 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
655 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
656 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
657 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
659 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
661 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
662 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
663 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
667 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
669 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
670 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
671 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
675 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
676 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
677 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
678 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
679 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
680 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
681 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
682 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
684 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
686 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
687 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
688 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
692 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
693 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
694 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
695 92410079 2021-10-16 stsp cmp -s $testroot/stdout $testroot/stdout.expected
697 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
698 92410079 2021-10-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
699 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
703 92410079 2021-10-16 stsp # Send the same tags again. This should be a no-op.
704 92410079 2021-10-16 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
706 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
707 92410079 2021-10-16 stsp echo "got send command failed unexpectedly" >&2
708 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
712 92410079 2021-10-16 stsp echo -n > $testroot/stdout.expected
713 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
715 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
716 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
721 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
722 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
723 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
724 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
725 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
727 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
728 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
730 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
731 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
732 a19f439c 2022-06-03 op test_done "$testroot" 1
736 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
737 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
738 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
740 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
741 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
742 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
746 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
747 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
748 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
750 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
751 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
752 a19f439c 2022-06-03 op test_done "$testroot" 1
756 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
757 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
758 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
762 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
766 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
767 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
768 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
769 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
771 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
772 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
773 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
777 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
778 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
779 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
781 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
782 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
783 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
787 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
788 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
789 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
790 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
792 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
793 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
794 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
798 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
799 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
800 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
802 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
803 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
804 c2105d00 2021-09-14 stsp 2> $testroot/stderr
806 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
807 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
808 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
812 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
813 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
814 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
815 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
816 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
818 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
819 c2105d00 2021-09-14 stsp 2> $testroot/stderr
821 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
822 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
823 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
826 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
827 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
828 c2105d00 2021-09-14 stsp $testroot/stdout; then
829 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
830 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
831 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
835 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
837 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
840 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
841 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
842 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
843 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
845 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
847 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
848 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
849 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
852 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
853 26960ff7 2021-09-14 stsp remote "origin" {
854 26960ff7 2021-09-14 stsp protocol ssh
855 26960ff7 2021-09-14 stsp server 127.0.0.1
856 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
859 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
861 ce2bf7b7 2022-05-29 stsp # modify beta on branch foo
862 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
863 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
864 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
865 ce2bf7b7 2022-05-29 stsp > /dev/null)
866 ce2bf7b7 2022-05-29 stsp echo buu >> $testroot/wt/beta
867 ce2bf7b7 2022-05-29 stsp (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
868 26960ff7 2021-09-14 stsp > /dev/null)
869 ce2bf7b7 2022-05-29 stsp echo baa >> $testroot/wt/beta
870 ce2bf7b7 2022-05-29 stsp (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
871 ce2bf7b7 2022-05-29 stsp > /dev/null)
872 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
874 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
875 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
876 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
877 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
879 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
880 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
882 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
883 26960ff7 2021-09-14 stsp # and the tag
884 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
885 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
886 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
888 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
890 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
891 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
892 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
896 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
897 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
899 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
900 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
901 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
905 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
907 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
908 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
909 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
913 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
914 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
915 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
916 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
917 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
918 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
919 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
920 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
921 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
923 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
925 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
926 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
927 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
931 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
933 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
934 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
935 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
939 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
940 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
941 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
942 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
943 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
944 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
945 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
947 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
949 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
950 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
951 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
955 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
956 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
958 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
960 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
961 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
966 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
968 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
971 f8a36e22 2021-08-26 stsp test_send_new_branch() {
972 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
973 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
974 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
976 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
978 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
980 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
981 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
982 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
986 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
987 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
988 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
989 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
990 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
992 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
995 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
996 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1000 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1001 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1004 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1005 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1009 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1011 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1012 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1013 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1017 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1018 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1019 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1021 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1025 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1029 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1031 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1032 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1033 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1037 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1038 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1039 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1041 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1042 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1043 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1044 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1045 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1046 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1047 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1048 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1049 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1051 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1053 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1054 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1055 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1059 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1061 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1064 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1065 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1066 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1067 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1069 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1071 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1073 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1074 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1075 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1079 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1080 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1081 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1082 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1084 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1085 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1086 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1087 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1088 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1090 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1091 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1092 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1093 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1094 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1096 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1098 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1099 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1100 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1104 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1105 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1106 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1107 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1109 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1110 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1112 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1113 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1114 a19f439c 2022-06-03 op test_done "$testroot" 1
1117 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1118 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1119 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1121 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1122 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1123 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1127 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1128 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1131 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1132 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1136 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1137 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1139 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1140 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1141 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1145 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1147 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1148 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1149 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1153 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1154 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1155 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1156 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1158 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1161 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1162 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1166 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1168 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1169 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1170 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1174 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1175 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1176 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1177 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1178 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1179 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1180 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1181 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1182 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1183 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1184 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1185 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1186 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1187 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1188 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1189 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1191 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1193 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1194 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1195 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1199 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1201 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1204 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1205 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1206 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1207 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1209 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo2
1212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1213 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1214 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1217 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1218 f8a36e22 2021-08-26 stsp remote "origin" {
1219 f8a36e22 2021-08-26 stsp protocol ssh
1220 f8a36e22 2021-08-26 stsp server 127.0.0.1
1221 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1224 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1225 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1226 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1228 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1230 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1231 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1232 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1236 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1237 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1239 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1240 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1241 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1245 02a5c5d0 2022-07-04 stsp # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1246 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1248 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1250 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1251 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1252 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1256 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1257 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1258 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1259 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1261 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1263 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1264 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1265 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1269 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1271 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1272 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1273 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1277 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1278 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1280 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1282 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1283 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1284 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1288 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1291 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1292 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1296 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1297 0deb9607 2022-11-18 op > $testroot/stdout.expected
1298 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1299 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1301 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1302 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1303 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1307 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1309 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1312 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1313 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1314 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1315 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1317 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1319 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1320 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1321 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1325 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1326 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1327 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1329 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1330 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1331 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1332 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1334 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1335 6480c871 2021-08-30 stsp remote "origin" {
1336 6480c871 2021-08-30 stsp protocol ssh
1337 6480c871 2021-08-30 stsp server 127.0.0.1
1339 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1342 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1346 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1348 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1349 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1350 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1354 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1355 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1356 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1357 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1359 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1360 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1361 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1365 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1366 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1368 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1369 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1370 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1374 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1376 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1377 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1378 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1382 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1383 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1384 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1385 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1386 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1387 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1388 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1389 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1390 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1392 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1393 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1394 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1398 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1399 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1401 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1402 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1403 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1407 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1410 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1411 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1415 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1416 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1417 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1418 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1419 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1420 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1421 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1423 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1425 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1426 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1427 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1431 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1433 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1436 eac1df47 2021-09-01 stsp test_send_config() {
1437 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1438 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1439 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1441 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1443 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1444 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1445 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1449 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1450 eac1df47 2021-09-01 stsp remote "origin" {
1451 eac1df47 2021-09-01 stsp protocol ssh
1452 eac1df47 2021-09-01 stsp server 127.0.0.1
1453 eac1df47 2021-09-01 stsp branch foo
1454 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1457 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1459 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1460 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1461 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1465 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1466 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1467 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1468 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1469 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1470 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1472 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1474 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1475 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1476 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1480 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1482 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1484 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1485 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1486 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1490 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1492 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1493 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1494 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1498 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1499 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1500 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1501 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1502 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1503 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1504 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1506 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1508 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1509 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1510 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1514 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1516 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1519 6242c45b 2022-11-14 op test_send_rejected() {
1520 6242c45b 2022-11-14 op local testroot=`test_init send_rejected`
1521 6242c45b 2022-11-14 op local testurl=ssh://127.0.0.1/$testroot
1522 6242c45b 2022-11-14 op local commit_id=`git_show_head $testroot/repo`
1524 6242c45b 2022-11-14 op if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
1525 6242c45b 2022-11-14 op echo "got clone command failed unexpectedly" >&2
1526 6242c45b 2022-11-14 op test_done "$testroot" 1
1530 6242c45b 2022-11-14 op mkdir "$testroot/repo-clone/hooks"
1531 6242c45b 2022-11-14 op cat <<'EOF' >$testroot/repo-clone/hooks/update
1532 6242c45b 2022-11-14 op case "$1" in
1534 6242c45b 2022-11-14 op echo "rejecting push on master branch"
1540 6242c45b 2022-11-14 op chmod +x "$testroot/repo-clone/hooks/update"
1542 6242c45b 2022-11-14 op cat > $testroot/repo/.git/got.conf <<EOF
1543 6242c45b 2022-11-14 op remote "origin" {
1544 6242c45b 2022-11-14 op protocol ssh
1545 6242c45b 2022-11-14 op server 127.0.0.1
1546 6242c45b 2022-11-14 op repository "$testroot/repo-clone"
1550 6242c45b 2022-11-14 op echo "modified alpha" >$testroot/repo/alpha
1551 6242c45b 2022-11-14 op git_commit "$testroot/repo" -m "modified alpha"
1553 6242c45b 2022-11-14 op got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
1555 6242c45b 2022-11-14 op if [ $ret -ne 0 ]; then
1556 6242c45b 2022-11-14 op echo "got send command failed unexpectedly" >&2
1557 6242c45b 2022-11-14 op test_done "$testroot" $ret
1561 6242c45b 2022-11-14 op touch "$testroot/stdout.expected"
1562 6242c45b 2022-11-14 op if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1563 6242c45b 2022-11-14 op diff -u "$testroot/stdout.expected" "$testroot/stdout"
1564 6242c45b 2022-11-14 op test_done "$testroot" 1
1568 6242c45b 2022-11-14 op cat <<EOF >$testroot/stderr.expected
1569 6242c45b 2022-11-14 op rejecting push on master branch
1570 6242c45b 2022-11-14 op error: hook declined to update refs/heads/master
1573 6242c45b 2022-11-14 op if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1574 6242c45b 2022-11-14 op diff -u "$testroot/stderr.expected" "$testroot/stderr"
1575 6242c45b 2022-11-14 op test_done "$testroot" 1
1579 6242c45b 2022-11-14 op test_done "$testroot" 0
1582 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1583 f8a36e22 2021-08-26 stsp run_test test_send_basic
1584 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1585 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1586 f8a36e22 2021-08-26 stsp run_test test_send_delete
1587 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1588 f8a36e22 2021-08-26 stsp run_test test_send_tags
1589 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1590 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1591 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1592 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1593 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1594 eac1df47 2021-09-01 stsp run_test test_send_config
1595 6242c45b 2022-11-14 op run_test test_send_rejected