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 c8c71e6e 2020-03-21 stsp (cd $testroot/repo-clone && got fetch -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 d7c4e80d 2020-04-19 stsp echo "Connecting to \"origin\" 127.0.0.1" > $testroot/stdout.expected
149 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
151 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
153 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
154 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
156 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
159 f6cae3ed 2020-09-13 naddy test_fetch_branch() {
160 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_branch`
161 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
162 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
164 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
166 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
167 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
168 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
172 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
173 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
174 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
175 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
176 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
178 c8c71e6e 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
179 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
180 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
182 c8c71e6e 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
183 c8c71e6e 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
184 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
185 c8c71e6e 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
187 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
189 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
190 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
191 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
195 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
197 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
199 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
200 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
201 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
205 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
207 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
208 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
209 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
210 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
211 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
212 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
213 c8c71e6e 2020-03-21 stsp # refs/remotes/origin/master is umodified because it wasn't fetched
214 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
215 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
216 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
217 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
219 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
221 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
222 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
223 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
227 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
229 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
230 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
231 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
235 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
237 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
239 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
240 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
241 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
245 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
247 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
248 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
249 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
250 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
251 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
254 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
255 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
256 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
258 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
260 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
261 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
266 f6cae3ed 2020-09-13 naddy test_fetch_all() {
267 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
268 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
269 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
271 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
273 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
274 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
275 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
279 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
280 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
281 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
282 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
283 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
285 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
287 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
288 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
289 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
290 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
291 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
292 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
293 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
295 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
297 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
298 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
299 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
303 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
305 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
306 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
307 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
311 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
313 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
314 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
315 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
316 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
317 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
318 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
319 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
320 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
321 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
322 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
324 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
326 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
327 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
332 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
333 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
334 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
335 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
337 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
338 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
339 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
341 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
343 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
344 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
345 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
349 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
350 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
352 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
354 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
355 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
356 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
357 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
358 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
359 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
360 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
361 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
363 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
365 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
366 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
367 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
371 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
373 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
374 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
375 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
379 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
381 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
382 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
383 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
384 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
385 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
386 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
387 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
388 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
389 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
390 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
392 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
394 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
395 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
397 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
400 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
401 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
402 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
403 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
406 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
407 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
408 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
409 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
410 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
412 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
414 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
415 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
416 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
420 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
422 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
423 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
424 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
425 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
426 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
427 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
428 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
429 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
430 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
431 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
432 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
434 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
436 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
437 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
438 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
442 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -d foo
444 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
446 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
447 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
448 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
452 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
454 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
455 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
456 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
457 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
458 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
459 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
460 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
461 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
462 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
463 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
465 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
467 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
468 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
469 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
473 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
475 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
476 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
477 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
481 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
483 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
485 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
486 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
487 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
491 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
493 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
494 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
495 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
496 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
497 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
498 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
499 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
500 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
501 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
502 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
504 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
506 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
507 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
509 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
513 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
514 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
515 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
516 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
519 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
520 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
521 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
522 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
523 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
525 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
527 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
528 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
529 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
533 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
534 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
535 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
537 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
538 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
539 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
540 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
542 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
544 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
545 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
546 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
547 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
548 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
549 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
550 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
551 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
552 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
553 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
554 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
556 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
558 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
559 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
564 db6d8ad8 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
566 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
567 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
568 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
572 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
574 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
575 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
576 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
577 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
578 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
579 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
580 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
581 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
582 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
583 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
585 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
587 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
588 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
589 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
593 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
594 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
596 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
597 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
598 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
602 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
603 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
605 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
607 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
608 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
609 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
613 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
615 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
616 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
617 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
618 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
619 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
620 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
621 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
622 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
623 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
624 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
626 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
628 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
629 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
634 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
636 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
637 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
638 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
642 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
644 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
646 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
647 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
652 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
654 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
655 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
656 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
657 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
658 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
659 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
660 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
661 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
662 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
663 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
665 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
667 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
668 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
670 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
673 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
674 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
675 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
676 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
678 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
680 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
681 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
682 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
686 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
687 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
688 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
689 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
690 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
692 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
693 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
694 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
696 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
697 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
698 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
699 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
700 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
702 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
703 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
705 0e4002ca 2020-03-21 stsp if [ "$ret" == "0" ]; then
706 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
707 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
711 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
713 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
715 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
716 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
721 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
722 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
724 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
726 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
727 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
728 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
732 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
734 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
735 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
736 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
740 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
742 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
743 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
744 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
745 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
746 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
747 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
748 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
749 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
750 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
752 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
754 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
755 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
761 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
762 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
763 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
764 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
766 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
768 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
769 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
770 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
774 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
775 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
777 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
779 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
780 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
781 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
783 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
785 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
786 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
791 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
792 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
794 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
795 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
796 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
800 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
801 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
803 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
805 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
806 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
807 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
811 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
813 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
814 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
815 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
817 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
819 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
820 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
822 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
826 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
827 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
828 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
829 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
831 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
833 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
834 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
835 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
839 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
841 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
842 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
843 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
844 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
845 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
846 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
848 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
850 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
851 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
856 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
857 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
858 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
860 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
861 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
862 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
864 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
866 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
867 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
868 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
872 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
874 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
876 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
877 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
878 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
879 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
880 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
881 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
882 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
883 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
884 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
886 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
888 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
889 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
891 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
894 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
895 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
896 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
897 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
899 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
901 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
902 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
903 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
907 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
909 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
910 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
911 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
912 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
913 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
914 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
916 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
918 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
919 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
920 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
924 bcf34b0e 2020-03-26 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD
926 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
928 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
929 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
930 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
933 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
935 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
936 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
937 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
938 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
939 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
940 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
941 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
943 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
945 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
946 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
948 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
951 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
952 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
953 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
954 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
956 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
957 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
958 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
960 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
962 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
963 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
964 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
968 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
969 50b0790e 2020-09-11 stsp remote "foobar" {
970 50b0790e 2020-09-11 stsp protocol ssh
971 50b0790e 2020-09-11 stsp server 127.0.0.1
972 50b0790e 2020-09-11 stsp repository "$testroot/repo"
975 50b0790e 2020-09-11 stsp remote "barbaz" {
976 50b0790e 2020-09-11 stsp protocol ssh
977 50b0790e 2020-09-11 stsp server 127.0.0.1
978 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
981 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
982 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
983 54eb00d5 2020-10-20 stsp (cd $testroot/repo-clone && got fetch nonexistent \
984 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
986 54eb00d5 2020-10-20 stsp if [ "$ret" == "0" ]; then
987 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
988 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
989 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
993 50b0790e 2020-09-11 stsp (cd $testroot/repo-clone && got fetch -l foobar \
994 50b0790e 2020-09-11 stsp > $testroot/stdout)
996 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
997 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
998 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1002 50b0790e 2020-09-11 stsp echo "Connecting to \"foobar\" 127.0.0.1" > $testroot/stdout.expected
1003 50b0790e 2020-09-11 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
1005 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1007 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
1008 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1009 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1013 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1015 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1016 50b0790e 2020-09-11 stsp remote "barbaz" {
1017 50b0790e 2020-09-11 stsp protocol ssh
1018 50b0790e 2020-09-11 stsp server 127.0.0.1
1019 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1022 50b0790e 2020-09-11 stsp (cd $testroot/wt && got fetch -l barbaz > $testroot/stdout)
1024 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1025 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1026 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1030 50b0790e 2020-09-11 stsp echo "Connecting to \"barbaz\" 127.0.0.1" > $testroot/stdout.expected
1031 50b0790e 2020-09-11 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
1033 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1035 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1036 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1038 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1042 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1043 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1044 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1045 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1046 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1047 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1048 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1049 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1050 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1051 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1052 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1053 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1054 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo