3 c8c71e6e 2020-03-21 stsp # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 c8c71e6e 2020-03-21 stsp # Permission to use, copy, modify, and distribute this software for any
6 c8c71e6e 2020-03-21 stsp # purpose with or without fee is hereby granted, provided that the above
7 c8c71e6e 2020-03-21 stsp # copyright notice and this permission notice appear in all copies.
9 c8c71e6e 2020-03-21 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c8c71e6e 2020-03-21 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c8c71e6e 2020-03-21 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c8c71e6e 2020-03-21 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c8c71e6e 2020-03-21 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c8c71e6e 2020-03-21 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c8c71e6e 2020-03-21 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 c8c71e6e 2020-03-21 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_fetch_basic() {
20 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_basic`
21 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
22 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
24 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
26 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
27 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
28 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
32 c8c71e6e 2020-03-21 stsp echo "modified alpha" > $testroot/repo/alpha
33 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
34 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
36 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
37 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
38 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
39 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
43 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout \
44 c8c71e6e 2020-03-21 stsp 2> $testroot/stderr
46 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
47 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
48 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
52 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
54 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
56 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
57 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
58 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
62 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo
63 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
64 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
65 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
68 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
69 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
70 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
71 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
74 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
76 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
77 c8c71e6e 2020-03-21 stsp echo "log -p output of cloned repository differs" >&2
78 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
82 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo > $testroot/stdout
83 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
84 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
85 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
89 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
90 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
92 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
94 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
95 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
96 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
100 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
101 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
102 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
103 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
107 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
108 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
109 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
110 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
111 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
112 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
114 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
116 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
117 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
119 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
122 f6cae3ed 2020-09-13 naddy test_fetch_list() {
123 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_list`
124 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
125 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
127 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
128 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
129 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
131 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
133 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
134 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
135 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
139 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l \
140 c8c71e6e 2020-03-21 stsp > $testroot/stdout 2>$testroot/stderr)
142 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
143 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
144 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
148 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
150 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
152 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
153 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
155 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
158 f6cae3ed 2020-09-13 naddy test_fetch_branch() {
159 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_branch`
160 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
161 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
163 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
165 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
166 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
167 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
171 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
172 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
173 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
174 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
175 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
177 c8c71e6e 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
178 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
179 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
181 c8c71e6e 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
182 c8c71e6e 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
183 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
184 c8c71e6e 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
186 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
188 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
189 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
190 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
194 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
196 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
198 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
199 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
200 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
204 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
206 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
207 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
208 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
209 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
210 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
211 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
212 c8c71e6e 2020-03-21 stsp # refs/remotes/origin/master is umodified because it wasn't fetched
213 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
214 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
215 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
216 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
218 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
220 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
221 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
222 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
226 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
228 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
229 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
230 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
234 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
236 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
238 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
239 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
240 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
244 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
246 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
247 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
248 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
249 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
250 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
251 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
253 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
254 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
255 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
257 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
259 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
260 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
265 f6cae3ed 2020-09-13 naddy test_fetch_all() {
266 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
267 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
268 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
270 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
272 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
273 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
274 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
278 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
279 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
280 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
281 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
282 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
284 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
286 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
287 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
288 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
289 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
290 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
291 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
292 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
294 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
296 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
297 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
298 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
302 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
304 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
305 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
306 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
310 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
312 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
313 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
314 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
315 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
316 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
317 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
318 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
319 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
320 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
321 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
323 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
325 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
326 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
331 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
332 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
333 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
334 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
336 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
337 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
338 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
340 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
342 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
343 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
344 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
348 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
349 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
351 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
353 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
354 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
355 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
356 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
357 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
358 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
359 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
360 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
362 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
364 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
365 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
366 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
370 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
372 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
373 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
374 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
378 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
380 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
381 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
382 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
383 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
384 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
385 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
386 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
387 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
388 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
389 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
391 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
393 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
394 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
396 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
399 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
400 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
401 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
402 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
405 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
406 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
407 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
408 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
409 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
411 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
413 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
414 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
415 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
419 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
421 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
422 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
423 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
424 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
425 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
426 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
427 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
428 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
429 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
430 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
431 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
433 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
435 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
436 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
441 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -d foo
443 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
445 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
446 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
447 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
451 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
453 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
454 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
455 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
456 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
457 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
458 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
459 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
460 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
461 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
462 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
464 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
466 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
467 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
472 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
474 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
475 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
476 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
480 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
482 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
484 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
485 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
486 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
490 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
492 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
493 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
494 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
495 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
496 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
497 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
498 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
499 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
500 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
501 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
503 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
505 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
506 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
508 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
512 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
513 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
514 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
515 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
518 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
519 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
520 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
521 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
522 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
524 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
526 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
527 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
528 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
532 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
533 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
534 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
536 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
537 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
538 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
539 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
541 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
543 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
544 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
545 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
546 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
547 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
548 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
549 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
550 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
551 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
552 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
553 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
555 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
557 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
558 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
559 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
563 db6d8ad8 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
565 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
566 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
567 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
571 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
573 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
574 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
575 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
576 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
577 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
578 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
579 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
580 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
581 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
582 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
584 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
586 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
587 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
592 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
593 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
595 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
596 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
597 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
601 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
602 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
604 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
606 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
607 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
608 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
612 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
614 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
615 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
616 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
617 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
618 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
619 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
620 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
621 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
622 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
623 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
625 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
627 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
628 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
633 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
635 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
636 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
637 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
641 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
643 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
645 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
646 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
647 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
651 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
653 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
654 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
655 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
656 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
657 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
658 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
659 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
660 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
661 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
662 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
664 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
666 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
667 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
669 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
672 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
673 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
674 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
675 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
677 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
679 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
680 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
681 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
685 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
686 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
687 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
688 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
689 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
691 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
692 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
693 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
695 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
696 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
697 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
698 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
699 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
701 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
702 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
704 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
705 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
706 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
710 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
712 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
714 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
715 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
716 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
720 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
721 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
723 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
725 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
726 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
727 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
731 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
733 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
734 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
735 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
739 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
741 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
742 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
743 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
744 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
745 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
746 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
747 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
748 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
749 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
751 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
753 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
754 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
756 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
760 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
761 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
762 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
763 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
765 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
767 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
768 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
769 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
773 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
774 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
776 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
778 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
779 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
780 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
782 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
784 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
785 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
786 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
790 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
791 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
793 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
794 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
795 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
799 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
800 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
802 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
804 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
805 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
806 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
810 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
812 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
813 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
814 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
816 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
818 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
819 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
821 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
825 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
826 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
827 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
828 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
830 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
832 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
833 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
834 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
838 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
840 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
841 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
842 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
843 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
844 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
845 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
847 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
849 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
850 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
855 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
856 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
857 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
859 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
860 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
861 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
863 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
865 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
866 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
867 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
871 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
873 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
875 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
876 15d3c221 2021-01-05 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
877 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
878 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
879 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/master: $commit_id" \
880 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
882 15d3c221 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
884 15d3c221 2021-01-05 stsp if [ "$ret" != "0" ]; then
885 15d3c221 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
886 15d3c221 2021-01-05 stsp test_done "$testroot" "$ret"
890 15d3c221 2021-01-05 stsp got fetch -q -r $testroot/repo-clone -a
892 15d3c221 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
894 15d3c221 2021-01-05 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
895 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
896 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
897 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
898 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
899 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
900 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
901 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
902 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
904 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
906 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
907 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
909 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
912 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
913 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
914 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
915 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
917 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
919 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
920 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
921 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
925 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
927 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
928 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
929 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
930 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
931 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
932 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
934 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
936 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
937 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
938 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
942 bcf34b0e 2020-03-26 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD
944 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
946 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
947 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
948 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
951 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
953 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
954 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
955 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
956 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
957 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
958 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
959 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
961 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
963 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
964 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
966 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
969 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
970 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
971 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
972 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
974 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
975 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
976 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
978 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
980 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
981 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
982 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
986 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
987 50b0790e 2020-09-11 stsp remote "foobar" {
988 50b0790e 2020-09-11 stsp protocol ssh
989 50b0790e 2020-09-11 stsp server 127.0.0.1
990 50b0790e 2020-09-11 stsp repository "$testroot/repo"
993 50b0790e 2020-09-11 stsp remote "barbaz" {
994 50b0790e 2020-09-11 stsp protocol ssh
995 50b0790e 2020-09-11 stsp server 127.0.0.1
996 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
999 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
1000 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
1001 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q nonexistent \
1002 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
1004 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1005 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
1006 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
1007 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
1011 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l foobar \
1012 50b0790e 2020-09-11 stsp > $testroot/stdout)
1014 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1015 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1016 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1020 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1022 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1024 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
1025 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1030 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1032 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1033 50b0790e 2020-09-11 stsp remote "barbaz" {
1034 50b0790e 2020-09-11 stsp protocol ssh
1035 50b0790e 2020-09-11 stsp server 127.0.0.1
1036 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1039 612392ee 2021-01-05 stsp (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1041 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1042 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1043 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1047 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1049 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1051 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1052 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1054 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1058 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1059 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1060 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1061 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1062 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1063 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1064 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1065 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1066 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1067 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1068 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1069 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1070 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo