3 f8a36e22 2021-08-26 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 f8a36e22 2021-08-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp # copyright notice and this permission notice appear in all copies.
9 f8a36e22 2021-08-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 f8a36e22 2021-08-26 stsp . ./common.sh
19 f8a36e22 2021-08-26 stsp test_send_basic() {
20 f8a36e22 2021-08-26 stsp local testroot=`test_init send_basic`
21 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
22 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
24 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
26 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
27 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
28 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
31 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
32 f8a36e22 2021-08-26 stsp remote "origin" {
33 f8a36e22 2021-08-26 stsp protocol ssh
34 f8a36e22 2021-08-26 stsp server 127.0.0.1
35 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
38 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
42 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
43 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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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
68 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
69 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
70 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
74 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
75 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
76 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
77 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
78 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
80 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
82 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
83 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
84 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
88 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
89 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
90 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
91 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
95 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
96 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
97 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
98 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
100 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
102 3af9de88 2021-09-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
104 3af9de88 2021-09-22 stsp if [ "$ret" != "0" ]; then
105 3af9de88 2021-09-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 3af9de88 2021-09-22 stsp test_done "$testroot" "$ret"
110 3af9de88 2021-09-22 stsp got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
111 3af9de88 2021-09-22 stsp > $testroot/stdout
112 3af9de88 2021-09-22 stsp got tree -r $testroot/repo -c $commit_id2 -i -R \
113 3af9de88 2021-09-22 stsp > $testroot/stdout.expected
114 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
116 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
117 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
118 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
122 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
124 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
125 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
126 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
130 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
131 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
132 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
134 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
135 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
136 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
140 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
142 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
145 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
146 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
147 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
148 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
150 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
152 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
153 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
154 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
157 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
158 f8a36e22 2021-08-26 stsp remote "origin" {
159 f8a36e22 2021-08-26 stsp protocol ssh
160 f8a36e22 2021-08-26 stsp server 127.0.0.1
161 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
164 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
165 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
166 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
168 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
169 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
170 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
172 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
174 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
175 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
176 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
180 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
181 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
183 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
184 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
185 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
189 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
190 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
191 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
193 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
194 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
199 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
201 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
204 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
205 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
206 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
207 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
209 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
211 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
212 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
213 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
216 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
217 f8a36e22 2021-08-26 stsp remote "foobar" {
218 f8a36e22 2021-08-26 stsp protocol ssh
219 f8a36e22 2021-08-26 stsp server 127.0.0.1
220 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
223 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
224 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
225 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
227 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
228 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
229 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
230 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
232 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
233 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
234 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
236 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
237 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
238 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
241 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
242 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
243 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
245 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
246 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
247 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
251 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
252 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
254 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
255 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
256 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
260 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
261 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
263 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
264 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
269 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
270 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
271 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
272 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
276 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
277 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
278 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
279 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
281 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
283 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
284 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
289 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
290 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
291 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
292 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
296 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
297 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
298 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
299 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
300 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
301 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
302 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
303 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
304 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
305 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
307 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
309 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
310 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
311 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
315 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
317 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
320 f8a36e22 2021-08-26 stsp test_send_delete() {
321 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
322 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
323 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
325 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
326 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
328 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
330 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
331 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
332 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
335 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
336 f8a36e22 2021-08-26 stsp remote "origin" {
337 f8a36e22 2021-08-26 stsp protocol ssh
338 f8a36e22 2021-08-26 stsp server 127.0.0.1
339 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
342 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
343 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
345 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
346 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
347 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
348 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
352 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
353 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
354 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
355 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
357 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
358 f8a36e22 2021-08-26 stsp # time is not allowed.
359 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
360 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
362 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
363 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
364 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
367 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
368 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
369 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
370 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
372 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
373 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
374 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
378 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
379 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
381 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
382 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
383 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
387 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
388 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
390 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
391 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
392 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
396 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
397 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
398 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
400 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
402 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
403 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
408 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
409 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
410 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
412 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
413 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
414 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
417 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
418 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
419 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
420 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
421 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
423 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
424 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
425 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
429 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
430 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
431 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
433 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
434 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
435 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
438 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
439 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
440 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
441 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
442 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
443 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
445 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
446 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
447 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
451 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
452 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
453 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
454 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
458 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
459 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
460 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
462 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
464 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
465 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
470 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
471 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
472 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
473 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
477 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
478 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
479 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
480 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
481 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
482 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
483 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
484 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
486 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
488 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
489 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
490 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
494 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
496 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
499 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
500 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
501 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
502 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
504 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
506 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
508 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
509 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
510 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
514 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
515 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
516 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
517 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
519 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
521 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
522 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
523 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
527 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
531 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
532 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
536 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
537 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
538 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
539 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
543 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
544 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
546 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
548 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
549 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
550 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
554 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
555 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
556 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
557 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
561 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
562 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
563 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
564 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
565 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
566 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
567 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
568 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
569 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
570 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
572 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
574 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
575 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
580 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
582 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
585 f8a36e22 2021-08-26 stsp test_send_tags() {
586 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
587 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
588 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
590 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
592 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
593 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
594 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
597 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
598 f8a36e22 2021-08-26 stsp remote "origin" {
599 f8a36e22 2021-08-26 stsp protocol ssh
600 f8a36e22 2021-08-26 stsp server 127.0.0.1
601 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
604 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
605 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
606 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
608 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
609 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
610 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
612 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
613 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
614 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
616 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
618 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
619 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
620 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
624 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
625 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
627 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
628 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
633 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
634 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
635 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
636 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
640 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
641 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
642 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
643 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
644 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
645 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
647 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
649 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
650 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
651 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
655 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
656 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
657 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
658 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
662 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
663 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
664 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
665 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
666 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
667 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
668 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
669 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
671 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
673 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
674 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
675 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
679 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
680 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
681 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
682 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
684 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
685 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
690 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
691 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
692 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
693 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
694 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
696 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
697 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
699 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
700 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
701 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
705 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
706 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
707 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
709 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
710 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
711 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
715 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
716 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
717 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
719 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
720 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
721 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
725 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
726 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
727 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
729 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
730 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
731 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
735 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
736 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
737 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
738 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
740 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
741 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
742 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
746 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
747 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
748 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
750 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
751 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
752 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
756 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
757 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
758 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
759 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
761 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
762 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
763 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
767 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
768 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
769 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
771 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
772 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
773 c2105d00 2021-09-14 stsp 2> $testroot/stderr
775 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
776 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
777 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
781 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
782 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
783 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
784 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
785 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
787 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
788 c2105d00 2021-09-14 stsp 2> $testroot/stderr
790 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
791 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
792 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
795 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
796 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
797 c2105d00 2021-09-14 stsp $testroot/stdout; then
798 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
799 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
800 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
804 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
806 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
809 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
810 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
811 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
812 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
814 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
816 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
817 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
818 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
821 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
822 26960ff7 2021-09-14 stsp remote "origin" {
823 26960ff7 2021-09-14 stsp protocol ssh
824 26960ff7 2021-09-14 stsp server 127.0.0.1
825 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
828 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
830 26960ff7 2021-09-14 stsp # modify alpha on branch foo
831 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
832 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
833 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
834 26960ff7 2021-09-14 stsp > /dev/null)
835 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
837 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
838 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
839 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
840 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
842 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
843 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
845 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
846 26960ff7 2021-09-14 stsp # and the tag
847 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
848 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
849 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
851 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
853 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
854 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
855 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
859 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
860 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
862 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
863 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
864 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
868 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
869 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
870 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
871 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
875 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
876 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
877 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
878 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
879 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
880 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
881 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
882 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
883 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
885 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
887 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
888 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
889 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
893 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
894 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
895 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
896 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
900 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
901 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
902 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
903 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
904 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
905 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
906 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
908 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
910 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
911 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
912 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
916 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
917 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
919 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
921 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
922 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
923 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
927 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
929 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
932 f8a36e22 2021-08-26 stsp test_send_new_branch() {
933 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
934 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
935 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
937 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
939 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
941 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
942 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
943 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
947 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
948 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
949 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
950 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
951 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
953 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
955 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
956 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
957 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
961 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
962 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
964 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
965 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
966 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
970 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
971 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
972 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
973 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
977 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
978 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
979 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
981 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
983 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
984 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
989 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
990 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
991 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
992 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
996 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
997 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
998 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
999 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1000 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1001 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1002 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1003 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1004 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1005 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1006 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1007 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1008 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1010 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1012 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1013 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1014 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1018 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1020 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1023 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1024 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1025 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1026 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1028 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1030 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1032 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1033 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1034 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1038 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1039 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1040 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1041 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1043 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1044 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1045 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1046 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1047 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1049 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1050 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1051 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1052 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1053 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1055 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1056 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1057 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1058 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1062 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1063 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1064 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1065 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1067 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1068 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1070 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
1071 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1072 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1075 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1076 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1077 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1079 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1080 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1081 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1085 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1086 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1088 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1090 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1094 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1095 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1097 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1098 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1099 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1103 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1104 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1105 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1106 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1110 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1111 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1112 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1113 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1115 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1117 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1118 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1119 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1123 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1124 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1125 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1126 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1130 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1131 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1132 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1133 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1134 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1135 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1136 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1137 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1138 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1139 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1140 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1141 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1142 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1143 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1144 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1145 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1147 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1149 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1150 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1155 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1157 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1160 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1161 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1162 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1163 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1165 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1168 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1169 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1170 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1173 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1174 f8a36e22 2021-08-26 stsp remote "origin" {
1175 f8a36e22 2021-08-26 stsp protocol ssh
1176 f8a36e22 2021-08-26 stsp server 127.0.0.1
1177 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1180 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1181 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1182 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1184 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1186 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1187 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1188 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1192 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1193 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1195 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1196 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1197 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1201 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1202 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1204 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1205 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1206 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1207 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1211 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1212 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1213 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1214 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1216 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1218 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1219 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1220 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1224 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1225 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1226 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1227 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1231 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1232 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1234 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1236 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1237 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1242 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1244 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1245 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1246 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1250 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1251 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1252 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1254 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1255 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1256 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1260 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1262 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1265 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1266 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1267 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1268 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1270 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1272 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1273 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1274 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1278 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1279 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1280 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1282 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1283 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1284 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1285 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1287 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1288 6480c871 2021-08-30 stsp remote "origin" {
1289 6480c871 2021-08-30 stsp protocol ssh
1290 6480c871 2021-08-30 stsp server 127.0.0.1
1292 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1295 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1299 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1300 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1301 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1302 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1306 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1307 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1308 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1309 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1311 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1312 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1313 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1317 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1318 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1320 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1321 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1322 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1326 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1327 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1328 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1329 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1333 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1334 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1335 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1336 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1337 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1338 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1339 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1340 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1341 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1343 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1344 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1345 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1349 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1350 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1352 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1353 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1354 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1358 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1359 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1360 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1361 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1365 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1366 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1367 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1368 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1369 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1370 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1371 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1373 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1375 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1376 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1377 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1381 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1383 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1386 eac1df47 2021-09-01 stsp test_send_config() {
1387 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1388 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1389 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1391 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1393 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1394 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1395 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1399 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1400 eac1df47 2021-09-01 stsp remote "origin" {
1401 eac1df47 2021-09-01 stsp protocol ssh
1402 eac1df47 2021-09-01 stsp server 127.0.0.1
1403 eac1df47 2021-09-01 stsp branch foo
1404 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1407 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1408 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1409 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1410 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1414 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1415 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1416 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1417 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1418 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1419 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1421 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1423 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1424 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1425 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1429 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1431 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1433 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1434 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1435 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1439 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1440 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1441 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1442 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1446 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1447 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1448 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1449 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1450 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1451 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1452 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1454 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1456 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1457 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1458 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1462 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1464 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1467 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1468 f8a36e22 2021-08-26 stsp run_test test_send_basic
1469 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1470 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1471 f8a36e22 2021-08-26 stsp run_test test_send_delete
1472 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1473 f8a36e22 2021-08-26 stsp run_test test_send_tags
1474 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1475 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1476 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1477 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1478 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1479 eac1df47 2021-09-01 stsp run_test test_send_config