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 fc414659 2022-04-16 thomas if [ $ret -ne 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
38 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
39 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
40 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
44 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout \
45 c8c71e6e 2020-03-21 stsp 2> $testroot/stderr
47 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
48 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
49 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
53 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
55 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
57 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
58 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
59 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
63 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo
65 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
66 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
67 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
70 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
72 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
73 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
74 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
77 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
79 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
80 c8c71e6e 2020-03-21 stsp echo "log -p output of cloned repository differs" >&2
81 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
85 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo > $testroot/stdout
87 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
88 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
89 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
93 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
94 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
96 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
98 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
99 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
100 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
104 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
106 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
107 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
108 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
112 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
113 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
114 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
115 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
116 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
117 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
119 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
121 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
122 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
127 f6cae3ed 2020-09-13 naddy test_fetch_list() {
128 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_list`
129 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
130 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
132 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
133 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
134 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
136 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
138 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
139 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
140 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
144 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l \
145 c8c71e6e 2020-03-21 stsp > $testroot/stdout 2>$testroot/stderr)
147 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
148 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
149 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
153 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
155 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
157 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
158 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
160 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
163 f6cae3ed 2020-09-13 naddy test_fetch_branch() {
164 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_branch`
165 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
166 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
168 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
170 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
171 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
172 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
176 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
177 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
178 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
179 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
180 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
182 c8c71e6e 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
183 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
184 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
186 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q foo
187 c8c71e6e 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
188 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
189 c8c71e6e 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
191 49e8d4dc 2023-02-20 thomas # foo is now the default HEAD branch in $testroot/repo and should be
192 49e8d4dc 2023-02-20 thomas # fetched as the clone's remote HEAD symref target no longer matches
193 9d0a7ee3 2023-02-07 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
195 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
196 9d0a7ee3 2023-02-07 thomas echo "got fetch command failed unexpectedly" >&2
197 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
201 9d0a7ee3 2023-02-07 thomas echo -n > $testroot/stdout.expected
203 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
205 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
206 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
207 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
211 9d0a7ee3 2023-02-07 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
213 9d0a7ee3 2023-02-07 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
214 49e8d4dc 2023-02-20 thomas echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
215 9d0a7ee3 2023-02-07 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
216 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
217 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
218 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/foo: $commit_id3" \
219 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
220 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
221 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
222 9d0a7ee3 2023-02-07 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
223 9d0a7ee3 2023-02-07 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
225 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
227 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
228 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
229 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
233 9d0a7ee3 2023-02-07 thomas # fetch branch foo via command-line switch
234 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
236 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
237 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
238 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
242 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
244 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
246 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
247 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
248 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
252 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
254 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
255 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
256 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
257 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
258 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
259 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
260 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
261 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
262 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
263 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
265 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
267 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
268 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
269 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
273 8d0dceb3 2023-02-07 thomas # got.conf tells us to fetch the 'master' branch by default
274 8d0dceb3 2023-02-07 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
276 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
277 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
278 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
282 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
284 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
286 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
287 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
288 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
292 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
294 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
295 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
296 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
297 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
298 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
299 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
300 91b10dd2 2023-02-03 thomas echo "refs/remotes/origin/master: $commit_id2" \
301 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
302 91b10dd2 2023-02-03 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
303 91b10dd2 2023-02-03 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
305 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
307 91b10dd2 2023-02-03 thomas if [ $ret -ne 0 ]; then
308 91b10dd2 2023-02-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
309 91b10dd2 2023-02-03 thomas test_done "$testroot" "$ret"
313 91b10dd2 2023-02-03 thomas echo "modified beta on foo" > $testroot/repo/beta
314 91b10dd2 2023-02-03 thomas git_commit $testroot/repo -m "modified beta"
315 91b10dd2 2023-02-03 thomas local commit_id4=`git_show_head $testroot/repo`
317 8d0dceb3 2023-02-07 thomas # set the default HEAD branch back to master
318 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
320 91b10dd2 2023-02-03 thomas got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
322 91b10dd2 2023-02-03 thomas # fetch new commits on branch 'foo', implicitly obtaining the
323 91b10dd2 2023-02-03 thomas # branch name from a work tree
324 91b10dd2 2023-02-03 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
326 91b10dd2 2023-02-03 thomas echo -n > $testroot/stdout.expected
328 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
330 91b10dd2 2023-02-03 thomas if [ $ret -ne 0 ]; then
331 91b10dd2 2023-02-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
332 91b10dd2 2023-02-03 thomas test_done "$testroot" "$ret"
336 91b10dd2 2023-02-03 thomas wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
337 91b10dd2 2023-02-03 thomas cut -d ':' -f 2 | tr -d ' ')`
339 91b10dd2 2023-02-03 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
341 91b10dd2 2023-02-03 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
342 91b10dd2 2023-02-03 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
343 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
344 91b10dd2 2023-02-03 thomas echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
345 91b10dd2 2023-02-03 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
346 8d0dceb3 2023-02-07 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
347 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
348 91b10dd2 2023-02-03 thomas echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
349 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
350 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
351 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
352 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
354 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
356 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
357 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
358 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
362 9d0a7ee3 2023-02-07 thomas # remove default branch information from got.conf
363 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
364 ac3cdf31 2023-03-06 thomas g/branch {/d
368 9d0a7ee3 2023-02-07 thomas # make another change on 'foo' and fetch it without got.conf
369 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q foo
370 9d0a7ee3 2023-02-07 thomas echo "modified beta on foo agan" > $testroot/repo/beta
371 9d0a7ee3 2023-02-07 thomas git_commit $testroot/repo -m "modified beta"
372 9d0a7ee3 2023-02-07 thomas local commit_id5=`git_show_head $testroot/repo`
373 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
375 9d0a7ee3 2023-02-07 thomas # fetch new commits on branch 'foo', implicitly obtaining the
376 9d0a7ee3 2023-02-07 thomas # branch name from a work tree
377 9d0a7ee3 2023-02-07 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
379 9d0a7ee3 2023-02-07 thomas echo -n > $testroot/stdout.expected
381 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
383 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
384 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
385 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
389 9d0a7ee3 2023-02-07 thomas wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
390 9d0a7ee3 2023-02-07 thomas cut -d ':' -f 2 | tr -d ' ')`
392 9d0a7ee3 2023-02-07 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
394 9d0a7ee3 2023-02-07 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
395 9d0a7ee3 2023-02-07 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
396 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
397 9d0a7ee3 2023-02-07 thomas echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
398 9d0a7ee3 2023-02-07 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
399 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
400 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
401 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
402 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
403 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
404 9d0a7ee3 2023-02-07 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
405 9d0a7ee3 2023-02-07 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
407 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
409 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
410 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
412 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
415 f6cae3ed 2020-09-13 naddy test_fetch_all() {
416 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
417 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
418 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
420 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
422 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
423 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
424 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
428 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
430 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
431 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
432 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
433 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
434 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
435 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
437 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
439 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
440 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
441 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
445 0097ceb4 2023-10-01 thomas got branch -r $testroot/repo -c $commit_id foo
446 0097ceb4 2023-10-01 thomas got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
447 0097ceb4 2023-10-01 thomas got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
448 0097ceb4 2023-10-01 thomas local tag_id=`got ref -r $testroot/repo -l \
449 0097ceb4 2023-10-01 thomas | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
451 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
453 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
454 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
455 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
459 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
461 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
462 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
463 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
464 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
465 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
466 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
467 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
468 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
469 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
470 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
472 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
474 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
475 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
478 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q foo
479 d7a689ea 2023-10-01 thomas echo "modified beta on foo" > $testroot/repo/beta
480 d7a689ea 2023-10-01 thomas git_commit $testroot/repo -m "modified beta"
481 d7a689ea 2023-10-01 thomas local commit_id2=`git_show_head $testroot/repo`
483 d7a689ea 2023-10-01 thomas # set the default HEAD branch back to master
484 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
486 d7a689ea 2023-10-01 thomas # remove default branch from got.conf, fetch all branches
487 d7a689ea 2023-10-01 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
488 d7a689ea 2023-10-01 thomas /branch {/c
489 d7a689ea 2023-10-01 thomas fetch_all_branches yes
494 d7a689ea 2023-10-01 thomas got fetch -q -r $testroot/repo-clone
496 d7a689ea 2023-10-01 thomas if [ $ret -ne 0 ]; then
497 d7a689ea 2023-10-01 thomas echo "got fetch command failed unexpectedly" >&2
498 d7a689ea 2023-10-01 thomas test_done "$testroot" "$ret"
502 d7a689ea 2023-10-01 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
504 d7a689ea 2023-10-01 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
505 d7a689ea 2023-10-01 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
506 d7a689ea 2023-10-01 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
507 d7a689ea 2023-10-01 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
508 d7a689ea 2023-10-01 thomas >> $testroot/stdout.expected
509 d7a689ea 2023-10-01 thomas echo "refs/remotes/origin/foo: $commit_id2" >> $testroot/stdout.expected
510 d7a689ea 2023-10-01 thomas echo "refs/remotes/origin/master: $commit_id" \
511 d7a689ea 2023-10-01 thomas >> $testroot/stdout.expected
512 d7a689ea 2023-10-01 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
513 d7a689ea 2023-10-01 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
515 d7a689ea 2023-10-01 thomas cmp -s $testroot/stdout $testroot/stdout.expected
517 d7a689ea 2023-10-01 thomas if [ $ret -ne 0 ]; then
518 d7a689ea 2023-10-01 thomas diff -u $testroot/stdout.expected $testroot/stdout
520 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
523 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
524 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
525 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
526 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
528 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
529 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
530 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
532 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
534 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
535 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
536 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
540 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
541 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
543 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
545 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
546 c8c71e6e 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 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
550 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
551 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
552 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
554 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
556 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
557 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
558 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
562 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
564 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
565 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
566 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
570 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
572 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
573 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
574 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
575 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
576 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
577 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
578 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
579 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
580 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
581 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
583 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
585 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
586 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
591 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
592 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
593 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
594 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
597 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
598 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
599 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
600 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
601 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
603 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
605 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
606 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
607 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
611 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
613 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
614 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
615 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
616 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
617 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
618 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
619 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
620 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
621 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
622 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
623 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
625 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
627 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
628 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
633 978a28a1 2021-09-04 naddy got branch -r $testroot/repo -d foo >/dev/null
635 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
637 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
638 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
639 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
643 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
645 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
646 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
647 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
648 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
649 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
650 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
651 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
652 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
653 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
654 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
656 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
658 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
659 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
660 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
664 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
666 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
667 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
668 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
672 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
674 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
676 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
677 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
682 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
684 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
685 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
686 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
687 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
688 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
689 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
690 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
691 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
692 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
693 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
695 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
697 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
698 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
700 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
704 1b796c3f 2021-09-11 stsp test_fetch_delete_branch_mirror() {
705 1b796c3f 2021-09-11 stsp local testroot=`test_init fetch_delete_branch_mirror`
706 1b796c3f 2021-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
707 1b796c3f 2021-09-11 stsp local commit_id=`git_show_head $testroot/repo`
709 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
710 1b796c3f 2021-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
711 1b796c3f 2021-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
712 1b796c3f 2021-09-11 stsp local tag_id=`got ref -r $testroot/repo -l \
713 1b796c3f 2021-09-11 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
715 1b796c3f 2021-09-11 stsp got clone -a -m -q $testurl/repo $testroot/repo-clone
717 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
718 1b796c3f 2021-09-11 stsp echo "got clone command failed unexpectedly" >&2
719 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
723 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
725 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
726 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
727 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
728 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
729 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
731 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
733 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
734 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
735 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
739 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -d foo >/dev/null
741 1b796c3f 2021-09-11 stsp got fetch -q -r $testroot/repo-clone
743 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
744 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
745 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
749 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
751 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
752 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
753 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
754 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
755 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
757 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
759 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
760 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
761 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
765 1b796c3f 2021-09-11 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
767 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
768 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
769 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
773 1b796c3f 2021-09-11 stsp echo -n > $testroot/stdout.expected
775 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
777 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
778 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
779 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
783 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
785 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
786 1b796c3f 2021-09-11 stsp # refs/heads/foo is now deleted
787 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
788 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
789 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
791 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
793 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
794 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
796 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
800 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
801 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
802 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
803 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
806 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
807 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
808 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
809 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
810 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
812 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
814 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
815 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
816 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
820 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
821 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
822 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
824 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
825 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
826 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
827 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
829 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
831 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
832 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
833 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
834 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
835 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
836 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
837 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
838 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
839 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
840 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
841 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
843 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
845 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
846 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
847 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
851 98f64f14 2021-01-05 stsp got fetch -a -q -r $testroot/repo-clone
853 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
854 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
855 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
859 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
861 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
862 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
863 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
864 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
865 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
866 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
867 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
868 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
869 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
870 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
872 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
874 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
875 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
876 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
880 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
881 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
883 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
884 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
885 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
889 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
890 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
892 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
894 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
895 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
896 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
900 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
902 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
903 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
904 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
905 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
906 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
907 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
908 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
909 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
910 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
911 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
913 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
915 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
916 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
917 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
921 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
923 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
924 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
925 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
929 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
931 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
933 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
934 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
935 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
939 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
941 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
942 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
943 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
944 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
945 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
946 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
947 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
948 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
949 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
950 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
952 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
954 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
955 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
957 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
960 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
961 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
962 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
963 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
965 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
967 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
968 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
969 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
973 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
974 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
975 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
976 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
977 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
979 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
980 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
981 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
983 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q foo
984 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
985 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
986 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
987 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
989 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
990 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
992 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
993 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
994 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
998 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
1000 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1002 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1003 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1004 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1008 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
1009 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
1011 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1013 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1014 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1015 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1019 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
1021 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1022 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
1023 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1027 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1029 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1030 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1031 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1032 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
1033 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1034 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
1035 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
1036 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
1037 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1039 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1041 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1042 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1048 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
1049 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
1050 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
1051 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
1053 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
1055 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1056 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
1057 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1061 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1062 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1064 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1066 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1067 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1068 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1070 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1072 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1073 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1074 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1078 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
1079 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1081 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1082 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
1083 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1087 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1088 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
1090 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1092 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1093 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1094 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1098 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1100 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1101 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1102 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1104 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1106 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1107 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1109 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1113 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
1114 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
1115 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
1116 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
1118 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
1120 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1121 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
1122 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1126 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1128 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1129 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1130 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1131 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1132 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1133 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1135 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1138 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1139 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1143 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1144 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
1145 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
1147 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1148 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1149 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1151 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1153 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1154 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1155 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1159 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
1161 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1163 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1164 49e8d4dc 2023-02-20 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1165 7917d6d5 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1166 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1167 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1168 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/foo: $commit_id" \
1169 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1170 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/master: $commit_id" \
1171 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1173 15d3c221 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1175 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1176 15d3c221 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1177 15d3c221 2021-01-05 stsp test_done "$testroot" "$ret"
1181 15d3c221 2021-01-05 stsp got fetch -q -r $testroot/repo-clone -a
1183 15d3c221 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1185 15d3c221 2021-01-05 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1186 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1187 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1188 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1189 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1190 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
1191 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1192 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1193 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1195 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1197 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1198 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1200 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1203 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
1204 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
1205 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
1206 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
1208 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1211 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
1212 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1216 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1218 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1219 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1220 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1221 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1222 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1223 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1225 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1227 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1228 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1229 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1233 993f033b 2021-07-16 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1235 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
1237 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1238 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
1239 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1242 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1244 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1245 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1246 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
1247 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1248 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1249 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1250 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1252 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1254 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1255 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1257 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1260 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
1261 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
1262 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
1263 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
1265 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
1266 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1267 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1269 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
1271 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1272 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
1273 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1277 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
1278 50b0790e 2020-09-11 stsp remote "foobar" {
1279 50b0790e 2020-09-11 stsp protocol ssh
1280 50b0790e 2020-09-11 stsp server 127.0.0.1
1281 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1284 50b0790e 2020-09-11 stsp remote "barbaz" {
1285 50b0790e 2020-09-11 stsp protocol ssh
1286 50b0790e 2020-09-11 stsp server 127.0.0.1
1287 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
1290 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
1291 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
1292 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q nonexistent \
1293 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
1295 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1296 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
1297 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
1298 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
1302 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l foobar \
1303 50b0790e 2020-09-11 stsp > $testroot/stdout)
1305 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1306 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1307 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1311 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1313 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1315 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1316 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1317 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1321 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1323 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1324 50b0790e 2020-09-11 stsp remote "barbaz" {
1325 50b0790e 2020-09-11 stsp protocol ssh
1326 50b0790e 2020-09-11 stsp server 127.0.0.1
1327 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1330 612392ee 2021-01-05 stsp (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1332 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1333 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1334 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1338 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1340 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1342 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1343 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1344 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1348 99495ddb 2021-01-10 stsp cat > $testroot/repo-clone/got.conf <<EOF
1349 99495ddb 2021-01-10 stsp remote "origin" {
1350 99495ddb 2021-01-10 stsp protocol ssh
1351 99495ddb 2021-01-10 stsp server 127.0.0.1
1352 99495ddb 2021-01-10 stsp repository "$testroot/repo"
1353 99495ddb 2021-01-10 stsp branch { "foo" }
1354 99495ddb 2021-01-10 stsp reference { "hoo/boo/zoo" }
1357 99495ddb 2021-01-10 stsp (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1359 99495ddb 2021-01-10 stsp local tag_id=`got ref -r $testroot/repo -l \
1360 99495ddb 2021-01-10 stsp | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1361 99495ddb 2021-01-10 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1362 99495ddb 2021-01-10 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1363 99495ddb 2021-01-10 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1364 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1365 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1366 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/foo: $commit_id" \
1367 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1368 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1369 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1370 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/master: $commit_id" \
1371 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1372 99495ddb 2021-01-10 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1374 99495ddb 2021-01-10 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1376 2eb6139c 2024-01-26 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1378 2eb6139c 2024-01-26 thomas if [ $ret -ne 0 ]; then
1379 2eb6139c 2024-01-26 thomas diff -u $testroot/stdout.expected $testroot/stdout
1381 2eb6139c 2024-01-26 thomas test_done "$testroot" "$ret"
1384 2eb6139c 2024-01-26 thomas test_fetch_gitconfig_remote_repo() {
1385 2eb6139c 2024-01-26 thomas local testroot=`test_init fetch_gotconfig_remote_repo`
1386 2eb6139c 2024-01-26 thomas local testurl=ssh://127.0.0.1/$testroot
1387 2eb6139c 2024-01-26 thomas local commit_id=`git_show_head $testroot/repo`
1389 2eb6139c 2024-01-26 thomas make_single_file_repo $testroot/alternate-repo foo
1390 2eb6139c 2024-01-26 thomas local alt_commit_id=`git_show_head $testroot/alternate-repo`
1392 2eb6139c 2024-01-26 thomas cat >> $testroot/repo/.git/config <<EOF
1393 2eb6139c 2024-01-26 thomas [remote "hasnourl"]
1394 2eb6139c 2024-01-26 thomas unrelated = setting
1395 2eb6139c 2024-01-26 thomas [remote "alt"]
1396 2eb6139c 2024-01-26 thomas url = $testurl/alternate-repo
1397 2eb6139c 2024-01-26 thomas [remote "another"]
1398 2eb6139c 2024-01-26 thomas url = $testurl/some-other-repo
1401 2eb6139c 2024-01-26 thomas # unset in a subshell to avoid affecting our environment
1402 2eb6139c 2024-01-26 thomas (unset GOT_IGNORE_GITCONFIG && cd $testroot/repo && got fetch -q alt)
1404 2eb6139c 2024-01-26 thomas if [ $ret -ne 0 ]; then
1405 2eb6139c 2024-01-26 thomas echo "got fetch command failed unexpectedly" >&2
1406 2eb6139c 2024-01-26 thomas test_done "$testroot" "$ret"
1407 2eb6139c 2024-01-26 thomas return 1
1410 2eb6139c 2024-01-26 thomas got ref -l -r $testroot/repo > $testroot/stdout
1412 2eb6139c 2024-01-26 thomas cat > $testroot/stdout.expected <<-EOF
1413 2eb6139c 2024-01-26 thomas HEAD: refs/heads/master
1414 2eb6139c 2024-01-26 thomas refs/heads/master: $commit_id
1415 2eb6139c 2024-01-26 thomas refs/remotes/alt/HEAD: refs/remotes/alt/master
1416 2eb6139c 2024-01-26 thomas refs/remotes/alt/master: $alt_commit_id
1419 99495ddb 2021-01-10 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1421 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1422 99495ddb 2021-01-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1424 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1427 161728eb 2021-07-24 stsp test_fetch_delete_remote_refs() {
1428 678d8c1f 2021-09-10 stsp local testroot=`test_init fetch_delete_remote_refs`
1429 161728eb 2021-07-24 stsp local testurl=ssh://127.0.0.1/$testroot
1430 161728eb 2021-07-24 stsp local commit_id=`git_show_head $testroot/repo`
1432 161728eb 2021-07-24 stsp got clone -q $testurl/repo $testroot/repo-clone
1434 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1435 161728eb 2021-07-24 stsp echo "got clone command failed unexpectedly" >&2
1436 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1440 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1442 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1443 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1444 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1448 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1449 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1450 161728eb 2021-07-24 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1451 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1452 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master: $commit_id" \
1453 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1455 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1457 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1458 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1459 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1463 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1464 161728eb 2021-07-24 stsp 2> $testroot/stderr
1466 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1467 161728eb 2021-07-24 stsp echo "got fetch command succeeded unexpectedly" >&2
1468 0b477035 2023-06-22 thomas test_done "$testroot" "1"
1472 161728eb 2021-07-24 stsp echo "got: -X option requires a remote name" > $testroot/stderr.expected
1473 161728eb 2021-07-24 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1475 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1476 161728eb 2021-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1477 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1481 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1482 161728eb 2021-07-24 stsp 2> $testroot/stderr
1484 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1485 161728eb 2021-07-24 stsp echo "got fetch command failed unexpectedly" >&2
1486 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1490 161728eb 2021-07-24 stsp echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1491 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1492 161728eb 2021-07-24 stsp echo "Deleted refs/remotes/origin/master: $commit_id" \
1493 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1495 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1497 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1498 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1499 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1503 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1505 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1506 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1507 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1511 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1512 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1514 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1516 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1517 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1519 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1522 31b44417 2023-02-17 thomas test_fetch_honor_wt_conf_bflag() {
1523 0c66b6d4 2023-02-17 thomas local testroot=`test_init fetch_honor_wt_conf_bflag`
1524 31b44417 2023-02-17 thomas local testurl=ssh://127.0.0.1/$testroot
1526 31b44417 2023-02-17 thomas # server will have 'boo', 'hoo', and 'master'
1527 31b44417 2023-02-17 thomas echo "modified alpha on master" > $testroot/repo/alpha
1528 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha"
1529 31b44417 2023-02-17 thomas local commit_id=`git_show_head $testroot/repo`
1531 31b44417 2023-02-17 thomas got branch -r $testroot/repo -c $commit_id boo
1532 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q boo
1533 31b44417 2023-02-17 thomas echo "modified beta on boo" > $testroot/repo/beta
1534 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified beta"
1535 31b44417 2023-02-17 thomas local commit_id2=`git_show_head $testroot/repo`
1537 31b44417 2023-02-17 thomas got branch -r $testroot/repo -c $commit_id2 hoo
1538 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q hoo
1539 31b44417 2023-02-17 thomas echo "modified delta on hoo" > $testroot/repo/gamma/delta
1540 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta"
1541 31b44417 2023-02-17 thomas local commit_id3=`git_show_head $testroot/repo`
1543 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
1544 31b44417 2023-02-17 thomas got clone -q $testurl/repo $testroot/repo-clone
1546 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1547 31b44417 2023-02-17 thomas echo "got clone command failed unexpectedly" >&2
1548 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1549 31b44417 2023-02-17 thomas return 1
1552 31b44417 2023-02-17 thomas # only clone will have foo and bar
1553 31b44417 2023-02-17 thomas got branch -r $testroot/repo-clone -c $commit_id foo
1554 31b44417 2023-02-17 thomas got branch -r $testroot/repo-clone -c $commit_id bar
1556 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1558 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1559 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1560 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1561 31b44417 2023-02-17 thomas return 1
1564 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1566 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1568 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1569 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1570 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1571 31b44417 2023-02-17 thomas return 1
1574 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1576 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1577 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1578 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1579 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1580 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1581 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1582 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1583 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1585 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1587 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1588 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1589 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1590 31b44417 2023-02-17 thomas return 1
1593 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q boo
1594 49e8d4dc 2023-02-20 thomas # clone has remote/origin/HEAD symref with "master" as its target
1595 49e8d4dc 2023-02-20 thomas # but the repo has changed HEAD to "boo", so we should fetch "boo"
1596 49e8d4dc 2023-02-20 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1597 49e8d4dc 2023-02-20 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1598 49e8d4dc 2023-02-20 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1599 49e8d4dc 2023-02-20 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1600 49e8d4dc 2023-02-20 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1601 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1602 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1603 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1604 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1605 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/master: $commit_id" \
1606 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1608 49e8d4dc 2023-02-20 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1610 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1611 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1612 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1613 31b44417 2023-02-17 thomas return 1
1616 49e8d4dc 2023-02-20 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1618 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1620 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1621 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1622 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1623 31b44417 2023-02-17 thomas return 1
1626 49e8d4dc 2023-02-20 thomas # from repo: fetch -b hoo
1627 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone -b hoo > $testroot/stdout
1629 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1630 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1631 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1632 31b44417 2023-02-17 thomas return 1
1635 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1637 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1639 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1640 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1641 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1642 31b44417 2023-02-17 thomas return 1
1645 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1647 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1648 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1649 49e8d4dc 2023-02-20 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1650 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1651 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1652 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1653 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1654 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1655 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1656 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1657 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1658 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1659 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1660 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1662 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1664 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1665 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1666 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1667 31b44417 2023-02-17 thomas return 1
1670 31b44417 2023-02-17 thomas # from repo: fetch -b foo which doesn't exist on the server but
1671 31b44417 2023-02-17 thomas # do not fallback to repo HEAD "boo" because we used the -b flag
1672 31b44417 2023-02-17 thomas got fetch -r $testroot/repo-clone -b foo > $testroot/stdout \
1673 31b44417 2023-02-17 thomas 2> $testroot/stderr
1675 31b44417 2023-02-17 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1676 31b44417 2023-02-17 thomas > $testroot/stdout.expected
1677 d392cc0a 2023-02-17 thomas echo "got-fetch-pack: branch \"foo\" not found on server" \
1678 31b44417 2023-02-17 thomas > $testroot/stderr.expected
1679 31b44417 2023-02-17 thomas echo "got: could not find any branches to fetch" \
1680 31b44417 2023-02-17 thomas >> $testroot/stderr.expected
1682 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1684 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1685 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1686 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1687 31b44417 2023-02-17 thomas return 1
1690 31b44417 2023-02-17 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1692 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1693 31b44417 2023-02-17 thomas diff -u $testroot/stderr.expected $testroot/stderr
1694 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1695 31b44417 2023-02-17 thomas return 1
1698 7917d6d5 2023-02-17 thomas # from repo: fetch got.conf branch which doesn't exist, so fallback
1699 7917d6d5 2023-02-17 thomas # to repo HEAD "boo"
1700 31b44417 2023-02-17 thomas # change default branch in got.conf from "master" to "foo"
1701 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
1702 ac3cdf31 2023-03-06 thomas ,s/master/foo/
1706 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1708 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1709 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1710 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1711 31b44417 2023-02-17 thomas return 1
1714 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1716 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1718 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1719 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1720 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1721 31b44417 2023-02-17 thomas return 1
1724 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1726 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1727 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1728 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1729 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1730 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1731 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1732 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1733 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1734 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1735 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1736 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1737 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1738 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1739 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1741 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1743 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1744 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1745 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1746 31b44417 2023-02-17 thomas return 1
1749 7917d6d5 2023-02-17 thomas # from wt: fetch got.conf "foo", which doesn't exist on the server,
1750 7917d6d5 2023-02-17 thomas # and implicit wt branch "boo", not repo HEAD "master"
1751 31b44417 2023-02-17 thomas echo "modified delta on boo" > $testroot/repo/gamma/delta
1752 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta"
1753 31b44417 2023-02-17 thomas local commit_id4=`git_show_head $testroot/repo`
1755 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
1757 31b44417 2023-02-17 thomas got checkout -b boo $testroot/repo-clone $testroot/wt > /dev/null
1758 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
1760 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1762 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1764 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1765 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1766 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1767 31b44417 2023-02-17 thomas return 1
1770 31b44417 2023-02-17 thomas local wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1771 31b44417 2023-02-17 thomas cut -d ':' -f 2 | tr -d ' ')`
1773 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1775 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1776 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1777 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1778 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1779 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1780 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1781 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1782 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1783 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1784 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1785 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id4" \
1786 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1787 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1788 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1789 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1790 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1792 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1794 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1795 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1796 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1797 31b44417 2023-02-17 thomas return 1
1800 49e8d4dc 2023-02-20 thomas # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD
1801 49e8d4dc 2023-02-20 thomas # "hoo" as it no longer matches our remote HEAD symref target "master"
1802 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
1803 ac3cdf31 2023-03-06 thomas ,s/foo/master/
1806 31b44417 2023-02-17 thomas echo "modified delta on master" > $testroot/repo/gamma/delta
1807 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta on master"
1808 31b44417 2023-02-17 thomas local commit_id5=`git_show_head $testroot/repo`
1810 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q boo
1811 31b44417 2023-02-17 thomas echo "modified alpha on boo" > $testroot/repo/alpha
1812 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha on boo"
1813 31b44417 2023-02-17 thomas local commit_id6=`git_show_head $testroot/repo`
1815 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q hoo
1816 31b44417 2023-02-17 thomas echo "modified beta on hoo" > $testroot/repo/beta
1817 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified beta on hoo"
1818 31b44417 2023-02-17 thomas local commit_id7=`git_show_head $testroot/repo`
1820 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
1822 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1824 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1826 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1827 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1828 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1829 31b44417 2023-02-17 thomas return 1
1832 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1834 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1835 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1836 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1837 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1838 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1839 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1840 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1841 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1842 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/hoo" \
1843 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1844 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id6" \
1845 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1846 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/hoo: $commit_id7" \
1847 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1848 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id5" \
1849 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1851 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1853 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1854 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1855 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1856 31b44417 2023-02-17 thomas return 1
1859 31b44417 2023-02-17 thomas # from wt: fetch -b hoo not got.conf "master" or wt "boo" or
1860 31b44417 2023-02-17 thomas # repo HEAD "boo"
1861 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q boo
1862 31b44417 2023-02-17 thomas echo "modified alpha again on boo" > $testroot/repo/alpha
1863 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha again on boo"
1864 31b44417 2023-02-17 thomas local commit_id8=`git_show_head $testroot/repo`
1866 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q -b hoo > $testroot/stdout)
1868 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1870 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1872 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1873 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1874 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1875 31b44417 2023-02-17 thomas return 1
1878 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1880 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1881 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1882 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1883 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1884 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1885 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1886 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1887 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1888 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1889 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1890 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id6" \
1891 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1892 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id7" \
1893 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1894 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id5" \
1895 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1897 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1899 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1900 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1901 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1902 31b44417 2023-02-17 thomas return 1
1905 31b44417 2023-02-17 thomas # from wt: fetch -b bar that doesn't exist on the server but
1906 31b44417 2023-02-17 thomas # do not fetch got.conf "master" or wt "boo" or repo HEAD "boo"
1907 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -b bar > $testroot/stdout \
1908 31b44417 2023-02-17 thomas 2> $testroot/stderr)
1910 31b44417 2023-02-17 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1911 31b44417 2023-02-17 thomas > $testroot/stdout.expected
1912 d392cc0a 2023-02-17 thomas echo "got-fetch-pack: branch \"bar\" not found on server" \
1913 31b44417 2023-02-17 thomas > $testroot/stderr.expected
1914 31b44417 2023-02-17 thomas echo "got: could not find any branches to fetch" \
1915 31b44417 2023-02-17 thomas >> $testroot/stderr.expected
1917 31b44417 2023-02-17 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1919 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1920 31b44417 2023-02-17 thomas diff -u $testroot/stderr.expected $testroot/stderr
1921 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1922 31b44417 2023-02-17 thomas return 1
1925 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1927 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1928 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1930 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1933 c12ab9ad 2023-02-21 thomas test_fetch_from_out_of_date_remote() {
1934 c12ab9ad 2023-02-21 thomas local testroot=`test_init fetch_from_out_of_date_remote`
1935 c12ab9ad 2023-02-21 thomas local testurl=ssh://127.0.0.1/$testroot
1936 c12ab9ad 2023-02-21 thomas local commit_id=`git_show_head $testroot/repo`
1938 c12ab9ad 2023-02-21 thomas got clone -q $testurl/repo $testroot/repo-clone
1940 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1941 c12ab9ad 2023-02-21 thomas echo "got clone command failed unexpectedly" >&2
1942 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1943 c12ab9ad 2023-02-21 thomas return 1
1946 c12ab9ad 2023-02-21 thomas echo "modified alpha" > $testroot/repo/alpha
1947 c12ab9ad 2023-02-21 thomas git_commit $testroot/repo -m "modified alpha"
1948 c12ab9ad 2023-02-21 thomas local commit_id2=`git_show_head $testroot/repo`
1950 c12ab9ad 2023-02-21 thomas got clone -q $testurl/repo $testroot/repo-clone2 \
1951 c12ab9ad 2023-02-21 thomas > $testroot/stdout 2> $testroot/stderr
1953 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1954 c12ab9ad 2023-02-21 thomas echo "got clone command failed unexpectedly" >&2
1955 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1956 c12ab9ad 2023-02-21 thomas return 1
1959 c12ab9ad 2023-02-21 thomas got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1961 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1962 c12ab9ad 2023-02-21 thomas echo "got ref command failed unexpectedly" >&2
1963 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1964 c12ab9ad 2023-02-21 thomas return 1
1967 c12ab9ad 2023-02-21 thomas cat > $testroot/stdout.expected <<EOF
1968 c12ab9ad 2023-02-21 thomas HEAD: refs/heads/master
1969 c12ab9ad 2023-02-21 thomas refs/heads/master: $commit_id2
1970 c12ab9ad 2023-02-21 thomas refs/remotes/origin/HEAD: refs/remotes/origin/master
1971 c12ab9ad 2023-02-21 thomas refs/remotes/origin/master: $commit_id2
1973 c12ab9ad 2023-02-21 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1975 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1976 c12ab9ad 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1977 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1978 c12ab9ad 2023-02-21 thomas return 1
1981 c12ab9ad 2023-02-21 thomas cat >> $testroot/repo-clone2/got.conf <<EOF
1982 c12ab9ad 2023-02-21 thomas remote "other" {
1983 c12ab9ad 2023-02-21 thomas server "127.0.0.1"
1984 c12ab9ad 2023-02-21 thomas protocol ssh
1985 c12ab9ad 2023-02-21 thomas repository "$testroot/repo-clone"
1986 c12ab9ad 2023-02-21 thomas branch { "master" }
1989 c12ab9ad 2023-02-21 thomas got fetch -q -r $testroot/repo-clone2 other \
1990 c12ab9ad 2023-02-21 thomas > $testroot/stdout 2> $testroot/stderr
1992 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1993 c12ab9ad 2023-02-21 thomas echo "got fetch command failed unexpectedly" >&2
1994 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1995 c12ab9ad 2023-02-21 thomas return 1
1998 c12ab9ad 2023-02-21 thomas got ref -l -r $testroot/repo-clone2 > $testroot/stdout
2000 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
2001 c12ab9ad 2023-02-21 thomas echo "got ref command failed unexpectedly" >&2
2002 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
2003 c12ab9ad 2023-02-21 thomas return 1
2006 c12ab9ad 2023-02-21 thomas cat > $testroot/stdout.expected <<EOF
2007 c12ab9ad 2023-02-21 thomas HEAD: refs/heads/master
2008 c12ab9ad 2023-02-21 thomas refs/heads/master: $commit_id2
2009 c12ab9ad 2023-02-21 thomas refs/remotes/origin/HEAD: refs/remotes/origin/master
2010 c12ab9ad 2023-02-21 thomas refs/remotes/origin/master: $commit_id2
2011 c12ab9ad 2023-02-21 thomas refs/remotes/other/HEAD: refs/remotes/other/master
2012 c12ab9ad 2023-02-21 thomas refs/remotes/other/master: $commit_id
2014 c12ab9ad 2023-02-21 thomas cmp -s $testroot/stdout $testroot/stdout.expected
2016 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
2017 c12ab9ad 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
2019 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
2023 7e73edb2 2024-04-25 thomas.ad test_fetch_basic_http() {
2024 66f0e755 2024-04-25 thomas.ad local testroot=`test_init fetch_basic_http`
2025 7e73edb2 2024-04-25 thomas.ad local testurl=http://127.0.0.1:$GOT_TEST_HTTP_PORT
2026 7e73edb2 2024-04-25 thomas.ad local commit_id=`git_show_head $testroot/repo`
2028 7e73edb2 2024-04-25 thomas.ad timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
2029 7e73edb2 2024-04-25 thomas.ad > $testroot/http-server.log &
2030 cc66d754 2024-04-25 thomas.ad trap "kill %1" HUP INT QUIT PIPE TERM
2032 7e73edb2 2024-04-25 thomas.ad sleep 1 # server starts up
2034 7e73edb2 2024-04-25 thomas.ad got clone -q $testurl/repo $testroot/repo-clone
2035 7e73edb2 2024-04-25 thomas.ad ret=$?
2036 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2037 7e73edb2 2024-04-25 thomas.ad echo "got clone command failed unexpectedly" >&2
2038 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2039 7e73edb2 2024-04-25 thomas.ad return 1
2042 7e73edb2 2024-04-25 thomas.ad echo "modified alpha" > $testroot/repo/alpha
2043 7e73edb2 2024-04-25 thomas.ad git_commit $testroot/repo -m "modified alpha"
2044 7e73edb2 2024-04-25 thomas.ad local commit_id2=`git_show_head $testroot/repo`
2046 7e73edb2 2024-04-25 thomas.ad got ref -l -r $testroot/repo-clone > $testroot/stdout
2047 7e73edb2 2024-04-25 thomas.ad ret=$?
2048 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2049 7e73edb2 2024-04-25 thomas.ad echo "got ref command failed unexpectedly" >&2
2050 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2051 7e73edb2 2024-04-25 thomas.ad return 1
2054 7e73edb2 2024-04-25 thomas.ad got fetch -q -r $testroot/repo-clone > $testroot/stdout \
2055 7e73edb2 2024-04-25 thomas.ad 2> $testroot/stderr
2056 7e73edb2 2024-04-25 thomas.ad ret=$?
2057 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2058 7e73edb2 2024-04-25 thomas.ad echo "got fetch command failed unexpectedly" >&2
2059 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2060 7e73edb2 2024-04-25 thomas.ad return 1
2063 7e73edb2 2024-04-25 thomas.ad kill %1
2064 7e73edb2 2024-04-25 thomas.ad wait %1 # wait for http-server
2066 7e73edb2 2024-04-25 thomas.ad echo -n > $testroot/stdout.expected
2068 7e73edb2 2024-04-25 thomas.ad cmp -s $testroot/stdout $testroot/stdout.expected
2069 7e73edb2 2024-04-25 thomas.ad ret=$?
2070 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2071 7e73edb2 2024-04-25 thomas.ad diff -u $testroot/stdout.expected $testroot/stdout
2072 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2073 7e73edb2 2024-04-25 thomas.ad return 1
2076 7e73edb2 2024-04-25 thomas.ad got log -l0 -p -r $testroot/repo > $testroot/log-repo
2077 7e73edb2 2024-04-25 thomas.ad ret=$?
2078 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2079 7e73edb2 2024-04-25 thomas.ad echo "got log command failed unexpectedly" >&2
2080 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2081 7e73edb2 2024-04-25 thomas.ad return 1
2083 7e73edb2 2024-04-25 thomas.ad got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
2084 7e73edb2 2024-04-25 thomas.ad ret=$?
2085 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2086 7e73edb2 2024-04-25 thomas.ad echo "got log command failed unexpectedly" >&2
2087 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2088 7e73edb2 2024-04-25 thomas.ad return 1
2090 7e73edb2 2024-04-25 thomas.ad cmp -s $testroot/log-repo $testroot/log-repo-clone
2091 7e73edb2 2024-04-25 thomas.ad ret=$?
2092 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2093 7e73edb2 2024-04-25 thomas.ad echo "log -p output of cloned repository differs" >&2
2094 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2095 7e73edb2 2024-04-25 thomas.ad return 1
2098 7e73edb2 2024-04-25 thomas.ad got ref -l -r $testroot/repo > $testroot/stdout
2099 7e73edb2 2024-04-25 thomas.ad ret=$?
2100 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2101 7e73edb2 2024-04-25 thomas.ad echo "got ref command failed unexpectedly" >&2
2102 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2103 7e73edb2 2024-04-25 thomas.ad return 1
2106 7e73edb2 2024-04-25 thomas.ad echo "HEAD: refs/heads/master" > $testroot/stdout.expected
2107 7e73edb2 2024-04-25 thomas.ad echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
2109 7e73edb2 2024-04-25 thomas.ad cmp -s $testroot/stdout $testroot/stdout.expected
2110 7e73edb2 2024-04-25 thomas.ad ret=$?
2111 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2112 7e73edb2 2024-04-25 thomas.ad diff -u $testroot/stdout.expected $testroot/stdout
2113 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2114 7e73edb2 2024-04-25 thomas.ad return 1
2117 7e73edb2 2024-04-25 thomas.ad got ref -l -r $testroot/repo-clone > $testroot/stdout
2118 7e73edb2 2024-04-25 thomas.ad ret=$?
2119 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2120 7e73edb2 2024-04-25 thomas.ad echo "got ref command failed unexpectedly" >&2
2121 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2122 7e73edb2 2024-04-25 thomas.ad return 1
2125 7e73edb2 2024-04-25 thomas.ad echo "HEAD: refs/heads/master" > $testroot/stdout.expected
2126 7e73edb2 2024-04-25 thomas.ad echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
2127 7e73edb2 2024-04-25 thomas.ad echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
2128 7e73edb2 2024-04-25 thomas.ad >> $testroot/stdout.expected
2129 7e73edb2 2024-04-25 thomas.ad echo "refs/remotes/origin/master: $commit_id2" \
2130 7e73edb2 2024-04-25 thomas.ad >> $testroot/stdout.expected
2132 7e73edb2 2024-04-25 thomas.ad cmp -s $testroot/stdout $testroot/stdout.expected
2133 7e73edb2 2024-04-25 thomas.ad ret=$?
2134 7e73edb2 2024-04-25 thomas.ad if [ $ret -ne 0 ]; then
2135 7e73edb2 2024-04-25 thomas.ad diff -u $testroot/stdout.expected $testroot/stdout
2137 7e73edb2 2024-04-25 thomas.ad test_done "$testroot" "$ret"
2140 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2141 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
2142 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
2143 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
2144 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
2145 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
2146 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
2147 1b796c3f 2021-09-11 stsp run_test test_fetch_delete_branch_mirror
2148 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
2149 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
2150 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
2151 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
2152 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
2153 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo
2154 2eb6139c 2024-01-26 thomas run_test test_fetch_gitconfig_remote_repo
2155 161728eb 2021-07-24 stsp run_test test_fetch_delete_remote_refs
2156 31b44417 2023-02-17 thomas run_test test_fetch_honor_wt_conf_bflag
2157 c12ab9ad 2023-02-21 thomas run_test test_fetch_from_out_of_date_remote
2158 7e73edb2 2024-04-25 thomas.ad run_test test_fetch_basic_http