Blame


1 c8c71e6e 2020-03-21 stsp #!/bin/sh
2 c8c71e6e 2020-03-21 stsp #
3 c8c71e6e 2020-03-21 stsp # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
4 c8c71e6e 2020-03-21 stsp #
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.
8 c8c71e6e 2020-03-21 stsp #
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.
16 c8c71e6e 2020-03-21 stsp
17 c8c71e6e 2020-03-21 stsp . ./common.sh
18 c8c71e6e 2020-03-21 stsp
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`
23 c8c71e6e 2020-03-21 stsp
24 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
25 fc414659 2022-04-16 thomas ret=$?
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"
29 c8c71e6e 2020-03-21 stsp return 1
30 c8c71e6e 2020-03-21 stsp fi
31 c8c71e6e 2020-03-21 stsp
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`
35 c8c71e6e 2020-03-21 stsp
36 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
37 21850702 2022-06-13 thomas ret=$?
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"
41 c8c71e6e 2020-03-21 stsp return 1
42 c8c71e6e 2020-03-21 stsp fi
43 c8c71e6e 2020-03-21 stsp
44 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout \
45 c8c71e6e 2020-03-21 stsp 2> $testroot/stderr
46 fc414659 2022-04-16 thomas ret=$?
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"
50 c8c71e6e 2020-03-21 stsp return 1
51 c8c71e6e 2020-03-21 stsp fi
52 c8c71e6e 2020-03-21 stsp
53 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
54 c8c71e6e 2020-03-21 stsp
55 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
56 fc414659 2022-04-16 thomas ret=$?
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"
60 c8c71e6e 2020-03-21 stsp return 1
61 c8c71e6e 2020-03-21 stsp fi
62 c8c71e6e 2020-03-21 stsp
63 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo
64 21850702 2022-06-13 thomas ret=$?
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"
68 c8c71e6e 2020-03-21 stsp return 1
69 c8c71e6e 2020-03-21 stsp fi
70 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
71 21850702 2022-06-13 thomas ret=$?
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"
75 c8c71e6e 2020-03-21 stsp return 1
76 c8c71e6e 2020-03-21 stsp fi
77 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
78 fc414659 2022-04-16 thomas ret=$?
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"
82 c8c71e6e 2020-03-21 stsp return 1
83 c8c71e6e 2020-03-21 stsp fi
84 c8c71e6e 2020-03-21 stsp
85 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo > $testroot/stdout
86 21850702 2022-06-13 thomas ret=$?
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"
90 c8c71e6e 2020-03-21 stsp return 1
91 c8c71e6e 2020-03-21 stsp fi
92 c8c71e6e 2020-03-21 stsp
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
95 c8c71e6e 2020-03-21 stsp
96 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
97 fc414659 2022-04-16 thomas ret=$?
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"
101 c8c71e6e 2020-03-21 stsp return 1
102 c8c71e6e 2020-03-21 stsp fi
103 c8c71e6e 2020-03-21 stsp
104 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
105 21850702 2022-06-13 thomas ret=$?
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"
109 c8c71e6e 2020-03-21 stsp return 1
110 c8c71e6e 2020-03-21 stsp fi
111 c8c71e6e 2020-03-21 stsp
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
118 c8c71e6e 2020-03-21 stsp
119 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
120 fc414659 2022-04-16 thomas ret=$?
121 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
122 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
123 c8c71e6e 2020-03-21 stsp fi
124 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
125 c8c71e6e 2020-03-21 stsp }
126 c8c71e6e 2020-03-21 stsp
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`
131 c8c71e6e 2020-03-21 stsp
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
135 c8c71e6e 2020-03-21 stsp
136 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
137 fc414659 2022-04-16 thomas ret=$?
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"
141 c8c71e6e 2020-03-21 stsp return 1
142 c8c71e6e 2020-03-21 stsp fi
143 c8c71e6e 2020-03-21 stsp
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)
146 fc414659 2022-04-16 thomas ret=$?
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"
150 c8c71e6e 2020-03-21 stsp return 1
151 c8c71e6e 2020-03-21 stsp fi
152 c8c71e6e 2020-03-21 stsp
153 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
154 c8c71e6e 2020-03-21 stsp
155 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
156 fc414659 2022-04-16 thomas ret=$?
157 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
158 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
159 c8c71e6e 2020-03-21 stsp fi
160 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
161 c8c71e6e 2020-03-21 stsp }
162 c8c71e6e 2020-03-21 stsp
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`
167 c8c71e6e 2020-03-21 stsp
168 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
169 fc414659 2022-04-16 thomas ret=$?
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"
173 c8c71e6e 2020-03-21 stsp return 1
174 c8c71e6e 2020-03-21 stsp fi
175 c8c71e6e 2020-03-21 stsp
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`
181 c8c71e6e 2020-03-21 stsp
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`
185 c8c71e6e 2020-03-21 stsp
186 c8c71e6e 2020-03-21 stsp (cd $testroot/repo && git 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`
190 c8c71e6e 2020-03-21 stsp
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
194 9d0a7ee3 2023-02-07 thomas ret=$?
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"
198 9d0a7ee3 2023-02-07 thomas return 1
199 9d0a7ee3 2023-02-07 thomas fi
200 9d0a7ee3 2023-02-07 thomas
201 9d0a7ee3 2023-02-07 thomas echo -n > $testroot/stdout.expected
202 9d0a7ee3 2023-02-07 thomas
203 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
204 9d0a7ee3 2023-02-07 thomas ret=$?
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"
208 9d0a7ee3 2023-02-07 thomas return 1
209 9d0a7ee3 2023-02-07 thomas fi
210 9d0a7ee3 2023-02-07 thomas
211 9d0a7ee3 2023-02-07 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
212 9d0a7ee3 2023-02-07 thomas
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
224 9d0a7ee3 2023-02-07 thomas
225 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
226 9d0a7ee3 2023-02-07 thomas ret=$?
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"
230 9d0a7ee3 2023-02-07 thomas return 1
231 9d0a7ee3 2023-02-07 thomas fi
232 9d0a7ee3 2023-02-07 thomas
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
235 fc414659 2022-04-16 thomas ret=$?
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"
239 c8c71e6e 2020-03-21 stsp return 1
240 c8c71e6e 2020-03-21 stsp fi
241 c8c71e6e 2020-03-21 stsp
242 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
243 c8c71e6e 2020-03-21 stsp
244 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
245 fc414659 2022-04-16 thomas ret=$?
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"
249 c8c71e6e 2020-03-21 stsp return 1
250 c8c71e6e 2020-03-21 stsp fi
251 c8c71e6e 2020-03-21 stsp
252 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
253 c8c71e6e 2020-03-21 stsp
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
264 c8c71e6e 2020-03-21 stsp
265 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
266 fc414659 2022-04-16 thomas ret=$?
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"
270 c8c71e6e 2020-03-21 stsp return 1
271 c8c71e6e 2020-03-21 stsp fi
272 c8c71e6e 2020-03-21 stsp
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
275 fc414659 2022-04-16 thomas ret=$?
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"
279 c8c71e6e 2020-03-21 stsp return 1
280 c8c71e6e 2020-03-21 stsp fi
281 c8c71e6e 2020-03-21 stsp
282 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
283 c8c71e6e 2020-03-21 stsp
284 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
285 fc414659 2022-04-16 thomas ret=$?
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"
289 c8c71e6e 2020-03-21 stsp return 1
290 c8c71e6e 2020-03-21 stsp fi
291 c8c71e6e 2020-03-21 stsp
292 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
293 c8c71e6e 2020-03-21 stsp
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
304 91b10dd2 2023-02-03 thomas
305 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
306 91b10dd2 2023-02-03 thomas ret=$?
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"
310 91b10dd2 2023-02-03 thomas return 1
311 91b10dd2 2023-02-03 thomas fi
312 91b10dd2 2023-02-03 thomas
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`
316 91b10dd2 2023-02-03 thomas
317 8d0dceb3 2023-02-07 thomas # set the default HEAD branch back to master
318 8d0dceb3 2023-02-07 thomas (cd $testroot/repo && git checkout -q master)
319 8d0dceb3 2023-02-07 thomas
320 91b10dd2 2023-02-03 thomas got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
321 91b10dd2 2023-02-03 thomas
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)
325 91b10dd2 2023-02-03 thomas
326 91b10dd2 2023-02-03 thomas echo -n > $testroot/stdout.expected
327 91b10dd2 2023-02-03 thomas
328 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
329 91b10dd2 2023-02-03 thomas ret=$?
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"
333 91b10dd2 2023-02-03 thomas return 1
334 91b10dd2 2023-02-03 thomas fi
335 91b10dd2 2023-02-03 thomas
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 ' ')`
338 91b10dd2 2023-02-03 thomas
339 91b10dd2 2023-02-03 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
340 91b10dd2 2023-02-03 thomas
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
353 c8c71e6e 2020-03-21 stsp
354 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
355 fc414659 2022-04-16 thomas ret=$?
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"
359 9d0a7ee3 2023-02-07 thomas return 1
360 c8c71e6e 2020-03-21 stsp fi
361 9d0a7ee3 2023-02-07 thomas
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
365 ac3cdf31 2023-03-06 thomas w
366 ac3cdf31 2023-03-06 thomas EOF
367 9d0a7ee3 2023-02-07 thomas
368 9d0a7ee3 2023-02-07 thomas # make another change on 'foo' and fetch it without got.conf
369 9d0a7ee3 2023-02-07 thomas (cd $testroot/repo && git 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 9d0a7ee3 2023-02-07 thomas (cd $testroot/repo && git checkout -q master)
374 9d0a7ee3 2023-02-07 thomas
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)
378 9d0a7ee3 2023-02-07 thomas
379 9d0a7ee3 2023-02-07 thomas echo -n > $testroot/stdout.expected
380 9d0a7ee3 2023-02-07 thomas
381 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
382 9d0a7ee3 2023-02-07 thomas ret=$?
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"
386 9d0a7ee3 2023-02-07 thomas return 1
387 9d0a7ee3 2023-02-07 thomas fi
388 9d0a7ee3 2023-02-07 thomas
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 ' ')`
391 9d0a7ee3 2023-02-07 thomas
392 9d0a7ee3 2023-02-07 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
393 9d0a7ee3 2023-02-07 thomas
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
406 9d0a7ee3 2023-02-07 thomas
407 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
408 9d0a7ee3 2023-02-07 thomas ret=$?
409 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
410 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
411 9d0a7ee3 2023-02-07 thomas fi
412 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
413 c8c71e6e 2020-03-21 stsp }
414 c8c71e6e 2020-03-21 stsp
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`
419 c8c71e6e 2020-03-21 stsp
420 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
421 fc414659 2022-04-16 thomas ret=$?
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"
425 c8c71e6e 2020-03-21 stsp return 1
426 c8c71e6e 2020-03-21 stsp fi
427 c8c71e6e 2020-03-21 stsp
428 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
429 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
430 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
431 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
432 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
433 c8c71e6e 2020-03-21 stsp
434 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
435 c8c71e6e 2020-03-21 stsp
436 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
437 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
438 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
439 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
440 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
441 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
442 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
443 c8c71e6e 2020-03-21 stsp
444 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
445 fc414659 2022-04-16 thomas ret=$?
446 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
447 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
449 c8c71e6e 2020-03-21 stsp return 1
450 c8c71e6e 2020-03-21 stsp fi
451 c8c71e6e 2020-03-21 stsp
452 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
453 fc414659 2022-04-16 thomas ret=$?
454 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
455 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
456 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
457 c8c71e6e 2020-03-21 stsp return 1
458 c8c71e6e 2020-03-21 stsp fi
459 c8c71e6e 2020-03-21 stsp
460 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
461 c8c71e6e 2020-03-21 stsp
462 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
463 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
464 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
465 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
466 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
467 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
468 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
469 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
470 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
471 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
472 c8c71e6e 2020-03-21 stsp
473 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
474 fc414659 2022-04-16 thomas ret=$?
475 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
476 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 c8c71e6e 2020-03-21 stsp fi
478 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
479 c8c71e6e 2020-03-21 stsp }
480 c8c71e6e 2020-03-21 stsp
481 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
482 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
483 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
484 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
485 c8c71e6e 2020-03-21 stsp
486 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
487 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
488 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
489 c8c71e6e 2020-03-21 stsp
490 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
491 fc414659 2022-04-16 thomas ret=$?
492 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
493 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
494 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
495 c8c71e6e 2020-03-21 stsp return 1
496 c8c71e6e 2020-03-21 stsp fi
497 c8c71e6e 2020-03-21 stsp
498 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
499 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
500 c8c71e6e 2020-03-21 stsp
501 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
502 c8c71e6e 2020-03-21 stsp
503 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
504 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
505 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
506 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
507 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
508 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
509 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
510 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
511 c8c71e6e 2020-03-21 stsp
512 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
513 fc414659 2022-04-16 thomas ret=$?
514 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
515 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
516 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
517 c8c71e6e 2020-03-21 stsp return 1
518 c8c71e6e 2020-03-21 stsp fi
519 c8c71e6e 2020-03-21 stsp
520 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
521 fc414659 2022-04-16 thomas ret=$?
522 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
523 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
524 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
525 c8c71e6e 2020-03-21 stsp return 1
526 c8c71e6e 2020-03-21 stsp fi
527 c8c71e6e 2020-03-21 stsp
528 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
529 c8c71e6e 2020-03-21 stsp
530 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
531 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
532 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
533 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
534 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
535 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
536 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
537 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
538 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
539 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
540 c8c71e6e 2020-03-21 stsp
541 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
542 fc414659 2022-04-16 thomas ret=$?
543 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
544 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 c8c71e6e 2020-03-21 stsp fi
546 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
547 c8c71e6e 2020-03-21 stsp }
548 c8c71e6e 2020-03-21 stsp
549 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
550 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
551 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
552 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
553 c8c71e6e 2020-03-21 stsp
554 c8c71e6e 2020-03-21 stsp
555 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
556 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
557 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
558 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
559 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
560 c8c71e6e 2020-03-21 stsp
561 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
562 fc414659 2022-04-16 thomas ret=$?
563 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
564 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
565 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
566 c8c71e6e 2020-03-21 stsp return 1
567 c8c71e6e 2020-03-21 stsp fi
568 c8c71e6e 2020-03-21 stsp
569 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
570 c8c71e6e 2020-03-21 stsp
571 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
572 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
573 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
574 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
575 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
576 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
577 c8c71e6e 2020-03-21 stsp >> $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
582 c8c71e6e 2020-03-21 stsp
583 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
584 fc414659 2022-04-16 thomas ret=$?
585 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
586 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
587 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
588 c8c71e6e 2020-03-21 stsp return 1
589 c8c71e6e 2020-03-21 stsp fi
590 c8c71e6e 2020-03-21 stsp
591 978a28a1 2021-09-04 naddy got branch -r $testroot/repo -d foo >/dev/null
592 c8c71e6e 2020-03-21 stsp
593 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
594 fc414659 2022-04-16 thomas ret=$?
595 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
596 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
597 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
598 c8c71e6e 2020-03-21 stsp return 1
599 c8c71e6e 2020-03-21 stsp fi
600 c8c71e6e 2020-03-21 stsp
601 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
602 c8c71e6e 2020-03-21 stsp
603 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
604 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
605 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
606 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
607 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
608 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
609 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
610 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
611 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
612 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
613 c8c71e6e 2020-03-21 stsp
614 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
615 fc414659 2022-04-16 thomas ret=$?
616 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
617 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
618 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
619 c8c71e6e 2020-03-21 stsp return 1
620 c8c71e6e 2020-03-21 stsp fi
621 c8c71e6e 2020-03-21 stsp
622 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
623 fc414659 2022-04-16 thomas ret=$?
624 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
625 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
626 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
627 c8c71e6e 2020-03-21 stsp return 1
628 c8c71e6e 2020-03-21 stsp fi
629 c8c71e6e 2020-03-21 stsp
630 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
631 c8c71e6e 2020-03-21 stsp
632 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
633 fc414659 2022-04-16 thomas ret=$?
634 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
635 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
636 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
637 c8c71e6e 2020-03-21 stsp return 1
638 c8c71e6e 2020-03-21 stsp fi
639 c8c71e6e 2020-03-21 stsp
640 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
641 c8c71e6e 2020-03-21 stsp
642 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
643 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
644 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
645 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
646 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
647 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
648 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
649 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
650 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
651 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
652 c8c71e6e 2020-03-21 stsp
653 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
654 fc414659 2022-04-16 thomas ret=$?
655 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
656 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
657 c8c71e6e 2020-03-21 stsp fi
658 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
659 c8c71e6e 2020-03-21 stsp
660 c8c71e6e 2020-03-21 stsp }
661 1b796c3f 2021-09-11 stsp
662 1b796c3f 2021-09-11 stsp test_fetch_delete_branch_mirror() {
663 1b796c3f 2021-09-11 stsp local testroot=`test_init fetch_delete_branch_mirror`
664 1b796c3f 2021-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
665 1b796c3f 2021-09-11 stsp local commit_id=`git_show_head $testroot/repo`
666 1b796c3f 2021-09-11 stsp
667 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
668 1b796c3f 2021-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
669 1b796c3f 2021-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
670 1b796c3f 2021-09-11 stsp local tag_id=`got ref -r $testroot/repo -l \
671 1b796c3f 2021-09-11 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
672 1b796c3f 2021-09-11 stsp
673 1b796c3f 2021-09-11 stsp got clone -a -m -q $testurl/repo $testroot/repo-clone
674 fc414659 2022-04-16 thomas ret=$?
675 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
676 1b796c3f 2021-09-11 stsp echo "got clone command failed unexpectedly" >&2
677 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
678 1b796c3f 2021-09-11 stsp return 1
679 1b796c3f 2021-09-11 stsp fi
680 1b796c3f 2021-09-11 stsp
681 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
682 1b796c3f 2021-09-11 stsp
683 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
684 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
685 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
686 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
687 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
688 db6d8ad8 2020-03-21 stsp
689 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
690 fc414659 2022-04-16 thomas ret=$?
691 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
692 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
693 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
694 1b796c3f 2021-09-11 stsp return 1
695 1b796c3f 2021-09-11 stsp fi
696 1b796c3f 2021-09-11 stsp
697 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -d foo >/dev/null
698 1b796c3f 2021-09-11 stsp
699 1b796c3f 2021-09-11 stsp got fetch -q -r $testroot/repo-clone
700 fc414659 2022-04-16 thomas ret=$?
701 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
702 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
703 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
704 1b796c3f 2021-09-11 stsp return 1
705 1b796c3f 2021-09-11 stsp fi
706 1b796c3f 2021-09-11 stsp
707 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
708 1b796c3f 2021-09-11 stsp
709 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
710 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
711 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
712 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
713 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
714 1b796c3f 2021-09-11 stsp
715 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
716 fc414659 2022-04-16 thomas ret=$?
717 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
718 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
719 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
720 1b796c3f 2021-09-11 stsp return 1
721 1b796c3f 2021-09-11 stsp fi
722 1b796c3f 2021-09-11 stsp
723 1b796c3f 2021-09-11 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
724 fc414659 2022-04-16 thomas ret=$?
725 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
726 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
727 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
728 1b796c3f 2021-09-11 stsp return 1
729 1b796c3f 2021-09-11 stsp fi
730 1b796c3f 2021-09-11 stsp
731 1b796c3f 2021-09-11 stsp echo -n > $testroot/stdout.expected
732 1b796c3f 2021-09-11 stsp
733 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
734 fc414659 2022-04-16 thomas ret=$?
735 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
736 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
737 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
738 1b796c3f 2021-09-11 stsp return 1
739 1b796c3f 2021-09-11 stsp fi
740 1b796c3f 2021-09-11 stsp
741 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
742 1b796c3f 2021-09-11 stsp
743 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
744 1b796c3f 2021-09-11 stsp # refs/heads/foo is now deleted
745 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
746 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
747 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
748 1b796c3f 2021-09-11 stsp
749 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
750 fc414659 2022-04-16 thomas ret=$?
751 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
752 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
753 1b796c3f 2021-09-11 stsp fi
754 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
755 1b796c3f 2021-09-11 stsp
756 1b796c3f 2021-09-11 stsp }
757 1b796c3f 2021-09-11 stsp
758 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
759 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
760 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
761 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
762 db6d8ad8 2020-03-21 stsp
763 db6d8ad8 2020-03-21 stsp
764 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
765 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
766 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
767 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
768 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
769 db6d8ad8 2020-03-21 stsp
770 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
771 fc414659 2022-04-16 thomas ret=$?
772 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
773 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
774 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
775 db6d8ad8 2020-03-21 stsp return 1
776 db6d8ad8 2020-03-21 stsp fi
777 db6d8ad8 2020-03-21 stsp
778 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
779 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
780 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
781 db6d8ad8 2020-03-21 stsp
782 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
783 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
784 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
785 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
786 db6d8ad8 2020-03-21 stsp
787 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
788 db6d8ad8 2020-03-21 stsp
789 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
790 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
791 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
792 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
793 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
794 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
795 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
796 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
797 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
798 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
799 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
800 c8c71e6e 2020-03-21 stsp
801 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
802 fc414659 2022-04-16 thomas ret=$?
803 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
804 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
805 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
806 db6d8ad8 2020-03-21 stsp return 1
807 db6d8ad8 2020-03-21 stsp fi
808 db6d8ad8 2020-03-21 stsp
809 98f64f14 2021-01-05 stsp got fetch -a -q -r $testroot/repo-clone
810 fc414659 2022-04-16 thomas ret=$?
811 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
812 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
813 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
814 db6d8ad8 2020-03-21 stsp return 1
815 db6d8ad8 2020-03-21 stsp fi
816 db6d8ad8 2020-03-21 stsp
817 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
818 db6d8ad8 2020-03-21 stsp
819 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
820 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
821 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
822 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
823 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
824 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
825 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
826 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
827 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
828 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
829 db6d8ad8 2020-03-21 stsp
830 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
831 fc414659 2022-04-16 thomas ret=$?
832 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
833 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
834 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
835 db6d8ad8 2020-03-21 stsp return 1
836 db6d8ad8 2020-03-21 stsp fi
837 db6d8ad8 2020-03-21 stsp
838 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
839 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
840 fc414659 2022-04-16 thomas ret=$?
841 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
842 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
843 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
844 db6d8ad8 2020-03-21 stsp return 1
845 db6d8ad8 2020-03-21 stsp fi
846 db6d8ad8 2020-03-21 stsp
847 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
848 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
849 db6d8ad8 2020-03-21 stsp
850 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
851 fc414659 2022-04-16 thomas ret=$?
852 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
853 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
854 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
855 db6d8ad8 2020-03-21 stsp return 1
856 db6d8ad8 2020-03-21 stsp fi
857 db6d8ad8 2020-03-21 stsp
858 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
859 db6d8ad8 2020-03-21 stsp
860 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
861 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
862 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
863 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
864 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
865 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
866 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
867 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
868 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
869 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
870 db6d8ad8 2020-03-21 stsp
871 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
872 fc414659 2022-04-16 thomas ret=$?
873 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
874 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
875 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
876 db6d8ad8 2020-03-21 stsp return 1
877 db6d8ad8 2020-03-21 stsp fi
878 db6d8ad8 2020-03-21 stsp
879 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
880 fc414659 2022-04-16 thomas ret=$?
881 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
882 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
883 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
884 db6d8ad8 2020-03-21 stsp return 1
885 db6d8ad8 2020-03-21 stsp fi
886 db6d8ad8 2020-03-21 stsp
887 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
888 db6d8ad8 2020-03-21 stsp
889 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
890 fc414659 2022-04-16 thomas ret=$?
891 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
892 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
893 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
894 db6d8ad8 2020-03-21 stsp return 1
895 db6d8ad8 2020-03-21 stsp fi
896 db6d8ad8 2020-03-21 stsp
897 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
898 db6d8ad8 2020-03-21 stsp
899 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
900 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
901 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
902 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
903 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
904 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
905 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
906 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
907 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
908 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
909 db6d8ad8 2020-03-21 stsp
910 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
911 fc414659 2022-04-16 thomas ret=$?
912 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
913 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
914 db6d8ad8 2020-03-21 stsp fi
915 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
916 db6d8ad8 2020-03-21 stsp }
917 0e4002ca 2020-03-21 stsp
918 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
919 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
920 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
921 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
922 db6d8ad8 2020-03-21 stsp
923 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
924 fc414659 2022-04-16 thomas ret=$?
925 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
926 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
927 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
928 0e4002ca 2020-03-21 stsp return 1
929 0e4002ca 2020-03-21 stsp fi
930 0e4002ca 2020-03-21 stsp
931 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
932 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
933 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
934 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
935 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
936 0e4002ca 2020-03-21 stsp
937 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
938 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
939 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
940 0e4002ca 2020-03-21 stsp
941 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
942 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
943 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
944 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
945 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
946 0e4002ca 2020-03-21 stsp
947 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
948 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
949 fc414659 2022-04-16 thomas ret=$?
950 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
951 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
952 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
953 0e4002ca 2020-03-21 stsp return 1
954 0e4002ca 2020-03-21 stsp fi
955 0e4002ca 2020-03-21 stsp
956 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
957 0e4002ca 2020-03-21 stsp
958 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
959 fc414659 2022-04-16 thomas ret=$?
960 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
961 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
963 0e4002ca 2020-03-21 stsp return 1
964 0e4002ca 2020-03-21 stsp fi
965 0e4002ca 2020-03-21 stsp
966 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
967 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
968 0e4002ca 2020-03-21 stsp
969 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
970 fc414659 2022-04-16 thomas ret=$?
971 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
972 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
973 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
974 0e4002ca 2020-03-21 stsp return 1
975 0e4002ca 2020-03-21 stsp fi
976 0e4002ca 2020-03-21 stsp
977 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
978 fc414659 2022-04-16 thomas ret=$?
979 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
980 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
981 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
982 0e4002ca 2020-03-21 stsp return 1
983 0e4002ca 2020-03-21 stsp fi
984 0e4002ca 2020-03-21 stsp
985 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
986 0e4002ca 2020-03-21 stsp
987 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
988 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
989 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
990 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
991 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
992 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
993 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
994 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
995 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
996 e8a967e0 2020-03-21 stsp
997 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
998 fc414659 2022-04-16 thomas ret=$?
999 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1000 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1001 e8a967e0 2020-03-21 stsp fi
1002 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1003 e8a967e0 2020-03-21 stsp
1004 e8a967e0 2020-03-21 stsp }
1005 e8a967e0 2020-03-21 stsp
1006 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
1007 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
1008 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
1009 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
1010 e8a967e0 2020-03-21 stsp
1011 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
1012 fc414659 2022-04-16 thomas ret=$?
1013 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1014 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
1015 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1016 e8a967e0 2020-03-21 stsp return 1
1017 e8a967e0 2020-03-21 stsp fi
1018 e8a967e0 2020-03-21 stsp
1019 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1020 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1021 e8a967e0 2020-03-21 stsp
1022 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1023 e8a967e0 2020-03-21 stsp
1024 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1025 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1026 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1027 e8a967e0 2020-03-21 stsp
1028 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1029 fc414659 2022-04-16 thomas ret=$?
1030 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1031 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1033 e8a967e0 2020-03-21 stsp return 1
1034 e8a967e0 2020-03-21 stsp fi
1035 0e4002ca 2020-03-21 stsp
1036 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
1037 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1038 fc414659 2022-04-16 thomas ret=$?
1039 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1040 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
1041 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1042 e8a967e0 2020-03-21 stsp return 1
1043 e8a967e0 2020-03-21 stsp fi
1044 e8a967e0 2020-03-21 stsp
1045 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1046 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
1047 e8a967e0 2020-03-21 stsp
1048 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1049 fc414659 2022-04-16 thomas ret=$?
1050 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1051 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1052 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1053 e8a967e0 2020-03-21 stsp return 1
1054 0e4002ca 2020-03-21 stsp fi
1055 e8a967e0 2020-03-21 stsp
1056 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1057 e8a967e0 2020-03-21 stsp
1058 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1059 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1060 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1061 f1bcca34 2020-03-25 stsp
1062 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1063 fc414659 2022-04-16 thomas ret=$?
1064 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1065 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1066 f1bcca34 2020-03-25 stsp fi
1067 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1068 f1bcca34 2020-03-25 stsp
1069 f1bcca34 2020-03-25 stsp }
1070 f1bcca34 2020-03-25 stsp
1071 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
1072 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
1073 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
1074 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
1075 f1bcca34 2020-03-25 stsp
1076 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
1077 fc414659 2022-04-16 thomas ret=$?
1078 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1079 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
1080 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1081 f1bcca34 2020-03-25 stsp return 1
1082 f1bcca34 2020-03-25 stsp fi
1083 f1bcca34 2020-03-25 stsp
1084 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1085 f1bcca34 2020-03-25 stsp
1086 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1087 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1088 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1089 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1090 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1091 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1092 f1bcca34 2020-03-25 stsp
1093 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1094 fc414659 2022-04-16 thomas ret=$?
1095 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1096 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1097 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1098 f1bcca34 2020-03-25 stsp return 1
1099 f1bcca34 2020-03-25 stsp fi
1100 e8a967e0 2020-03-21 stsp
1101 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1102 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
1103 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
1104 f1bcca34 2020-03-25 stsp
1105 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1106 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1107 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1108 f1bcca34 2020-03-25 stsp
1109 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1110 fc414659 2022-04-16 thomas ret=$?
1111 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1112 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1113 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1114 f1bcca34 2020-03-25 stsp return 1
1115 e8a967e0 2020-03-21 stsp fi
1116 f1bcca34 2020-03-25 stsp
1117 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
1118 f1bcca34 2020-03-25 stsp
1119 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1120 f1bcca34 2020-03-25 stsp
1121 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1122 49e8d4dc 2023-02-20 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1123 7917d6d5 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1124 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1125 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1126 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/foo: $commit_id" \
1127 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1128 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/master: $commit_id" \
1129 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1130 15d3c221 2021-01-05 stsp
1131 15d3c221 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1132 fc414659 2022-04-16 thomas ret=$?
1133 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1134 15d3c221 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1135 15d3c221 2021-01-05 stsp test_done "$testroot" "$ret"
1136 15d3c221 2021-01-05 stsp return 1
1137 15d3c221 2021-01-05 stsp fi
1138 15d3c221 2021-01-05 stsp
1139 15d3c221 2021-01-05 stsp got fetch -q -r $testroot/repo-clone -a
1140 15d3c221 2021-01-05 stsp
1141 15d3c221 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1142 15d3c221 2021-01-05 stsp
1143 15d3c221 2021-01-05 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1144 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1145 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1146 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1147 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1148 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
1149 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1150 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1151 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1152 f1bcca34 2020-03-25 stsp
1153 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1154 fc414659 2022-04-16 thomas ret=$?
1155 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1156 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1157 f1bcca34 2020-03-25 stsp fi
1158 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1159 bcf34b0e 2020-03-26 stsp }
1160 bcf34b0e 2020-03-26 stsp
1161 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
1162 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
1163 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
1164 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
1165 bcf34b0e 2020-03-26 stsp
1166 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1167 fc414659 2022-04-16 thomas ret=$?
1168 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1169 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
1170 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1171 bcf34b0e 2020-03-26 stsp return 1
1172 bcf34b0e 2020-03-26 stsp fi
1173 bcf34b0e 2020-03-26 stsp
1174 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1175 0e4002ca 2020-03-21 stsp
1176 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1177 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1178 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1179 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1180 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1181 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1182 bcf34b0e 2020-03-26 stsp
1183 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1184 fc414659 2022-04-16 thomas ret=$?
1185 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1186 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1187 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1188 bcf34b0e 2020-03-26 stsp return 1
1189 bcf34b0e 2020-03-26 stsp fi
1190 bcf34b0e 2020-03-26 stsp
1191 993f033b 2021-07-16 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1192 bcf34b0e 2020-03-26 stsp
1193 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
1194 fc414659 2022-04-16 thomas ret=$?
1195 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1196 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
1197 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1198 bcf34b0e 2020-03-26 stsp return 1
1199 bcf34b0e 2020-03-26 stsp fi
1200 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1201 bcf34b0e 2020-03-26 stsp
1202 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1203 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1204 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
1205 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1206 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1207 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1208 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1209 50b0790e 2020-09-11 stsp
1210 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1211 fc414659 2022-04-16 thomas ret=$?
1212 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1213 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1214 50b0790e 2020-09-11 stsp fi
1215 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1216 50b0790e 2020-09-11 stsp }
1217 50b0790e 2020-09-11 stsp
1218 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
1219 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
1220 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
1221 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
1222 50b0790e 2020-09-11 stsp
1223 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
1224 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1225 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1226 50b0790e 2020-09-11 stsp
1227 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
1228 fc414659 2022-04-16 thomas ret=$?
1229 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1230 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
1231 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1232 50b0790e 2020-09-11 stsp return 1
1233 50b0790e 2020-09-11 stsp fi
1234 50b0790e 2020-09-11 stsp
1235 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
1236 50b0790e 2020-09-11 stsp remote "foobar" {
1237 50b0790e 2020-09-11 stsp protocol ssh
1238 50b0790e 2020-09-11 stsp server 127.0.0.1
1239 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1240 50b0790e 2020-09-11 stsp }
1241 50b0790e 2020-09-11 stsp
1242 50b0790e 2020-09-11 stsp remote "barbaz" {
1243 50b0790e 2020-09-11 stsp protocol ssh
1244 50b0790e 2020-09-11 stsp server 127.0.0.1
1245 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
1246 50b0790e 2020-09-11 stsp }
1247 50b0790e 2020-09-11 stsp EOF
1248 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
1249 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
1250 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q nonexistent \
1251 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
1252 fc414659 2022-04-16 thomas ret=$?
1253 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1254 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
1255 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
1256 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
1257 54eb00d5 2020-10-20 stsp return 1
1258 54eb00d5 2020-10-20 stsp fi
1259 54eb00d5 2020-10-20 stsp
1260 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l foobar \
1261 50b0790e 2020-09-11 stsp > $testroot/stdout)
1262 fc414659 2022-04-16 thomas ret=$?
1263 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1264 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1265 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1266 50b0790e 2020-09-11 stsp return 1
1267 50b0790e 2020-09-11 stsp fi
1268 bcf34b0e 2020-03-26 stsp
1269 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1270 50b0790e 2020-09-11 stsp
1271 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1272 fc414659 2022-04-16 thomas ret=$?
1273 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1274 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1275 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1276 50b0790e 2020-09-11 stsp return 1
1277 bcf34b0e 2020-03-26 stsp fi
1278 50b0790e 2020-09-11 stsp
1279 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1280 50b0790e 2020-09-11 stsp
1281 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1282 50b0790e 2020-09-11 stsp remote "barbaz" {
1283 50b0790e 2020-09-11 stsp protocol ssh
1284 50b0790e 2020-09-11 stsp server 127.0.0.1
1285 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1286 50b0790e 2020-09-11 stsp }
1287 50b0790e 2020-09-11 stsp EOF
1288 612392ee 2021-01-05 stsp (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1289 fc414659 2022-04-16 thomas ret=$?
1290 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1291 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1292 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1293 50b0790e 2020-09-11 stsp return 1
1294 50b0790e 2020-09-11 stsp fi
1295 50b0790e 2020-09-11 stsp
1296 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1297 50b0790e 2020-09-11 stsp
1298 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1299 fc414659 2022-04-16 thomas ret=$?
1300 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1301 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1302 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1303 99495ddb 2021-01-10 stsp return 1
1304 99495ddb 2021-01-10 stsp fi
1305 50b0790e 2020-09-11 stsp
1306 99495ddb 2021-01-10 stsp cat > $testroot/repo-clone/got.conf <<EOF
1307 99495ddb 2021-01-10 stsp remote "origin" {
1308 99495ddb 2021-01-10 stsp protocol ssh
1309 99495ddb 2021-01-10 stsp server 127.0.0.1
1310 99495ddb 2021-01-10 stsp repository "$testroot/repo"
1311 99495ddb 2021-01-10 stsp branch { "foo" }
1312 99495ddb 2021-01-10 stsp reference { "hoo/boo/zoo" }
1313 0e4002ca 2020-03-21 stsp }
1314 99495ddb 2021-01-10 stsp EOF
1315 99495ddb 2021-01-10 stsp (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1316 0e4002ca 2020-03-21 stsp
1317 99495ddb 2021-01-10 stsp local tag_id=`got ref -r $testroot/repo -l \
1318 99495ddb 2021-01-10 stsp | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1319 99495ddb 2021-01-10 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1320 99495ddb 2021-01-10 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1321 99495ddb 2021-01-10 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1322 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1323 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1324 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/foo: $commit_id" \
1325 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1326 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1327 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1328 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/master: $commit_id" \
1329 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1330 99495ddb 2021-01-10 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1331 99495ddb 2021-01-10 stsp
1332 99495ddb 2021-01-10 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1333 99495ddb 2021-01-10 stsp
1334 99495ddb 2021-01-10 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1335 fc414659 2022-04-16 thomas ret=$?
1336 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1337 99495ddb 2021-01-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1338 99495ddb 2021-01-10 stsp fi
1339 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1340 99495ddb 2021-01-10 stsp }
1341 99495ddb 2021-01-10 stsp
1342 161728eb 2021-07-24 stsp test_fetch_delete_remote_refs() {
1343 678d8c1f 2021-09-10 stsp local testroot=`test_init fetch_delete_remote_refs`
1344 161728eb 2021-07-24 stsp local testurl=ssh://127.0.0.1/$testroot
1345 161728eb 2021-07-24 stsp local commit_id=`git_show_head $testroot/repo`
1346 161728eb 2021-07-24 stsp
1347 161728eb 2021-07-24 stsp got clone -q $testurl/repo $testroot/repo-clone
1348 fc414659 2022-04-16 thomas ret=$?
1349 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1350 161728eb 2021-07-24 stsp echo "got clone command failed unexpectedly" >&2
1351 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1352 161728eb 2021-07-24 stsp return 1
1353 161728eb 2021-07-24 stsp fi
1354 161728eb 2021-07-24 stsp
1355 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1356 21850702 2022-06-13 thomas ret=$?
1357 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1358 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1359 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1360 161728eb 2021-07-24 stsp return 1
1361 161728eb 2021-07-24 stsp fi
1362 161728eb 2021-07-24 stsp
1363 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1364 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1365 161728eb 2021-07-24 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1366 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1367 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master: $commit_id" \
1368 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1369 161728eb 2021-07-24 stsp
1370 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1371 fc414659 2022-04-16 thomas ret=$?
1372 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1373 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1374 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1375 161728eb 2021-07-24 stsp return 1
1376 161728eb 2021-07-24 stsp fi
1377 161728eb 2021-07-24 stsp
1378 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1379 161728eb 2021-07-24 stsp 2> $testroot/stderr
1380 fc414659 2022-04-16 thomas ret=$?
1381 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1382 161728eb 2021-07-24 stsp echo "got fetch command succeeded unexpectedly" >&2
1383 0b477035 2023-06-22 thomas test_done "$testroot" "1"
1384 161728eb 2021-07-24 stsp return 1
1385 161728eb 2021-07-24 stsp fi
1386 161728eb 2021-07-24 stsp
1387 161728eb 2021-07-24 stsp echo "got: -X option requires a remote name" > $testroot/stderr.expected
1388 161728eb 2021-07-24 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1389 fc414659 2022-04-16 thomas ret=$?
1390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1391 161728eb 2021-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1392 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1393 161728eb 2021-07-24 stsp return 1
1394 161728eb 2021-07-24 stsp fi
1395 161728eb 2021-07-24 stsp
1396 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1397 161728eb 2021-07-24 stsp 2> $testroot/stderr
1398 fc414659 2022-04-16 thomas ret=$?
1399 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1400 161728eb 2021-07-24 stsp echo "got fetch command failed unexpectedly" >&2
1401 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1402 161728eb 2021-07-24 stsp return 1
1403 161728eb 2021-07-24 stsp fi
1404 161728eb 2021-07-24 stsp
1405 161728eb 2021-07-24 stsp echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1406 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1407 161728eb 2021-07-24 stsp echo "Deleted refs/remotes/origin/master: $commit_id" \
1408 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1409 161728eb 2021-07-24 stsp
1410 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1411 fc414659 2022-04-16 thomas ret=$?
1412 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1413 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1414 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1415 161728eb 2021-07-24 stsp return 1
1416 161728eb 2021-07-24 stsp fi
1417 161728eb 2021-07-24 stsp
1418 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1419 21850702 2022-06-13 thomas ret=$?
1420 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1421 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1422 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1423 161728eb 2021-07-24 stsp return 1
1424 161728eb 2021-07-24 stsp fi
1425 161728eb 2021-07-24 stsp
1426 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1427 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1428 161728eb 2021-07-24 stsp
1429 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1430 fc414659 2022-04-16 thomas ret=$?
1431 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1432 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1433 161728eb 2021-07-24 stsp fi
1434 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1435 161728eb 2021-07-24 stsp }
1436 31b44417 2023-02-17 thomas
1437 31b44417 2023-02-17 thomas test_fetch_honor_wt_conf_bflag() {
1438 0c66b6d4 2023-02-17 thomas local testroot=`test_init fetch_honor_wt_conf_bflag`
1439 31b44417 2023-02-17 thomas local testurl=ssh://127.0.0.1/$testroot
1440 31b44417 2023-02-17 thomas
1441 31b44417 2023-02-17 thomas # server will have 'boo', 'hoo', and 'master'
1442 31b44417 2023-02-17 thomas echo "modified alpha on master" > $testroot/repo/alpha
1443 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha"
1444 31b44417 2023-02-17 thomas local commit_id=`git_show_head $testroot/repo`
1445 31b44417 2023-02-17 thomas
1446 31b44417 2023-02-17 thomas got branch -r $testroot/repo -c $commit_id boo
1447 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q boo)
1448 31b44417 2023-02-17 thomas echo "modified beta on boo" > $testroot/repo/beta
1449 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified beta"
1450 31b44417 2023-02-17 thomas local commit_id2=`git_show_head $testroot/repo`
1451 31b44417 2023-02-17 thomas
1452 31b44417 2023-02-17 thomas got branch -r $testroot/repo -c $commit_id2 hoo
1453 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q hoo)
1454 31b44417 2023-02-17 thomas echo "modified delta on hoo" > $testroot/repo/gamma/delta
1455 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta"
1456 31b44417 2023-02-17 thomas local commit_id3=`git_show_head $testroot/repo`
1457 31b44417 2023-02-17 thomas
1458 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q master)
1459 31b44417 2023-02-17 thomas got clone -q $testurl/repo $testroot/repo-clone
1460 31b44417 2023-02-17 thomas ret=$?
1461 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1462 31b44417 2023-02-17 thomas echo "got clone command failed unexpectedly" >&2
1463 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1464 31b44417 2023-02-17 thomas return 1
1465 31b44417 2023-02-17 thomas fi
1466 31b44417 2023-02-17 thomas
1467 31b44417 2023-02-17 thomas # only clone will have foo and bar
1468 31b44417 2023-02-17 thomas got branch -r $testroot/repo-clone -c $commit_id foo
1469 31b44417 2023-02-17 thomas got branch -r $testroot/repo-clone -c $commit_id bar
1470 31b44417 2023-02-17 thomas
1471 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1472 31b44417 2023-02-17 thomas ret=$?
1473 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1474 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1475 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1476 31b44417 2023-02-17 thomas return 1
1477 31b44417 2023-02-17 thomas fi
1478 31b44417 2023-02-17 thomas
1479 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1480 31b44417 2023-02-17 thomas
1481 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1482 31b44417 2023-02-17 thomas ret=$?
1483 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1484 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1485 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1486 31b44417 2023-02-17 thomas return 1
1487 31b44417 2023-02-17 thomas fi
1488 31b44417 2023-02-17 thomas
1489 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1490 31b44417 2023-02-17 thomas
1491 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1492 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1493 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1494 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1495 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1496 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1497 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1498 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1499 31b44417 2023-02-17 thomas
1500 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1501 31b44417 2023-02-17 thomas ret=$?
1502 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1503 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1504 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1505 31b44417 2023-02-17 thomas return 1
1506 31b44417 2023-02-17 thomas fi
1507 31b44417 2023-02-17 thomas
1508 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q boo)
1509 49e8d4dc 2023-02-20 thomas # clone has remote/origin/HEAD symref with "master" as its target
1510 49e8d4dc 2023-02-20 thomas # but the repo has changed HEAD to "boo", so we should fetch "boo"
1511 49e8d4dc 2023-02-20 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1512 49e8d4dc 2023-02-20 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1513 49e8d4dc 2023-02-20 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1514 49e8d4dc 2023-02-20 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1515 49e8d4dc 2023-02-20 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1516 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1517 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1518 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1519 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1520 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/master: $commit_id" \
1521 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1522 49e8d4dc 2023-02-20 thomas
1523 49e8d4dc 2023-02-20 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1524 31b44417 2023-02-17 thomas ret=$?
1525 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1526 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1527 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1528 31b44417 2023-02-17 thomas return 1
1529 31b44417 2023-02-17 thomas fi
1530 31b44417 2023-02-17 thomas
1531 49e8d4dc 2023-02-20 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1532 31b44417 2023-02-17 thomas
1533 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1534 31b44417 2023-02-17 thomas ret=$?
1535 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1536 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1537 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1538 31b44417 2023-02-17 thomas return 1
1539 31b44417 2023-02-17 thomas fi
1540 31b44417 2023-02-17 thomas
1541 49e8d4dc 2023-02-20 thomas # from repo: fetch -b hoo
1542 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone -b hoo > $testroot/stdout
1543 31b44417 2023-02-17 thomas ret=$?
1544 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1545 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1546 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1547 31b44417 2023-02-17 thomas return 1
1548 31b44417 2023-02-17 thomas fi
1549 161728eb 2021-07-24 stsp
1550 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1551 161728eb 2021-07-24 stsp
1552 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1553 31b44417 2023-02-17 thomas ret=$?
1554 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1555 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1556 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1557 31b44417 2023-02-17 thomas return 1
1558 31b44417 2023-02-17 thomas fi
1559 31b44417 2023-02-17 thomas
1560 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1561 31b44417 2023-02-17 thomas
1562 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1563 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1564 49e8d4dc 2023-02-20 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1565 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1566 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1567 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1568 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1569 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1570 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1571 49e8d4dc 2023-02-20 thomas >> $testroot/stdout.expected
1572 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1573 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1574 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1575 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1576 31b44417 2023-02-17 thomas
1577 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1578 31b44417 2023-02-17 thomas ret=$?
1579 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1580 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1581 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1582 31b44417 2023-02-17 thomas return 1
1583 31b44417 2023-02-17 thomas fi
1584 31b44417 2023-02-17 thomas
1585 31b44417 2023-02-17 thomas # from repo: fetch -b foo which doesn't exist on the server but
1586 31b44417 2023-02-17 thomas # do not fallback to repo HEAD "boo" because we used the -b flag
1587 31b44417 2023-02-17 thomas got fetch -r $testroot/repo-clone -b foo > $testroot/stdout \
1588 31b44417 2023-02-17 thomas 2> $testroot/stderr
1589 31b44417 2023-02-17 thomas
1590 31b44417 2023-02-17 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1591 31b44417 2023-02-17 thomas > $testroot/stdout.expected
1592 d392cc0a 2023-02-17 thomas echo "got-fetch-pack: branch \"foo\" not found on server" \
1593 31b44417 2023-02-17 thomas > $testroot/stderr.expected
1594 31b44417 2023-02-17 thomas echo "got: could not find any branches to fetch" \
1595 31b44417 2023-02-17 thomas >> $testroot/stderr.expected
1596 31b44417 2023-02-17 thomas
1597 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1598 31b44417 2023-02-17 thomas ret=$?
1599 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1600 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1601 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1602 31b44417 2023-02-17 thomas return 1
1603 31b44417 2023-02-17 thomas fi
1604 31b44417 2023-02-17 thomas
1605 31b44417 2023-02-17 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1606 31b44417 2023-02-17 thomas ret=$?
1607 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1608 31b44417 2023-02-17 thomas diff -u $testroot/stderr.expected $testroot/stderr
1609 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1610 31b44417 2023-02-17 thomas return 1
1611 31b44417 2023-02-17 thomas fi
1612 31b44417 2023-02-17 thomas
1613 7917d6d5 2023-02-17 thomas # from repo: fetch got.conf branch which doesn't exist, so fallback
1614 7917d6d5 2023-02-17 thomas # to repo HEAD "boo"
1615 31b44417 2023-02-17 thomas # change default branch in got.conf from "master" to "foo"
1616 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
1617 ac3cdf31 2023-03-06 thomas ,s/master/foo/
1618 ac3cdf31 2023-03-06 thomas w
1619 ac3cdf31 2023-03-06 thomas EOF
1620 31b44417 2023-02-17 thomas
1621 31b44417 2023-02-17 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1622 31b44417 2023-02-17 thomas ret=$?
1623 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1624 31b44417 2023-02-17 thomas echo "got fetch command failed unexpectedly" >&2
1625 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1626 31b44417 2023-02-17 thomas return 1
1627 31b44417 2023-02-17 thomas fi
1628 31b44417 2023-02-17 thomas
1629 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1630 31b44417 2023-02-17 thomas
1631 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1632 31b44417 2023-02-17 thomas ret=$?
1633 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1634 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1635 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1636 31b44417 2023-02-17 thomas return 1
1637 31b44417 2023-02-17 thomas fi
1638 31b44417 2023-02-17 thomas
1639 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1640 31b44417 2023-02-17 thomas
1641 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1642 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1643 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1644 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1645 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1646 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1647 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1648 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1649 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id2" \
1650 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1651 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1652 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1653 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1654 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1655 31b44417 2023-02-17 thomas
1656 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1657 31b44417 2023-02-17 thomas ret=$?
1658 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1659 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1660 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1661 31b44417 2023-02-17 thomas return 1
1662 31b44417 2023-02-17 thomas fi
1663 31b44417 2023-02-17 thomas
1664 7917d6d5 2023-02-17 thomas # from wt: fetch got.conf "foo", which doesn't exist on the server,
1665 7917d6d5 2023-02-17 thomas # and implicit wt branch "boo", not repo HEAD "master"
1666 31b44417 2023-02-17 thomas echo "modified delta on boo" > $testroot/repo/gamma/delta
1667 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta"
1668 31b44417 2023-02-17 thomas local commit_id4=`git_show_head $testroot/repo`
1669 31b44417 2023-02-17 thomas
1670 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q master)
1671 31b44417 2023-02-17 thomas
1672 31b44417 2023-02-17 thomas got checkout -b boo $testroot/repo-clone $testroot/wt > /dev/null
1673 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
1674 31b44417 2023-02-17 thomas
1675 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1676 31b44417 2023-02-17 thomas
1677 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1678 31b44417 2023-02-17 thomas ret=$?
1679 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1680 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1681 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1682 31b44417 2023-02-17 thomas return 1
1683 31b44417 2023-02-17 thomas fi
1684 31b44417 2023-02-17 thomas
1685 31b44417 2023-02-17 thomas local wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1686 31b44417 2023-02-17 thomas cut -d ':' -f 2 | tr -d ' ')`
1687 31b44417 2023-02-17 thomas
1688 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1689 31b44417 2023-02-17 thomas
1690 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1691 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1692 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1693 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1694 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1695 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1696 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1697 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1698 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1699 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1700 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id4" \
1701 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1702 31b44417 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id3" \
1703 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1704 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id" \
1705 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1706 31b44417 2023-02-17 thomas
1707 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1708 31b44417 2023-02-17 thomas ret=$?
1709 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1710 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1711 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1712 31b44417 2023-02-17 thomas return 1
1713 31b44417 2023-02-17 thomas fi
1714 31b44417 2023-02-17 thomas
1715 49e8d4dc 2023-02-20 thomas # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD
1716 49e8d4dc 2023-02-20 thomas # "hoo" as it no longer matches our remote HEAD symref target "master"
1717 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo-clone/got.conf <<-EOF
1718 ac3cdf31 2023-03-06 thomas ,s/foo/master/
1719 ac3cdf31 2023-03-06 thomas w
1720 ac3cdf31 2023-03-06 thomas EOF
1721 31b44417 2023-02-17 thomas echo "modified delta on master" > $testroot/repo/gamma/delta
1722 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified delta on master"
1723 31b44417 2023-02-17 thomas local commit_id5=`git_show_head $testroot/repo`
1724 31b44417 2023-02-17 thomas
1725 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q boo)
1726 31b44417 2023-02-17 thomas echo "modified alpha on boo" > $testroot/repo/alpha
1727 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha on boo"
1728 31b44417 2023-02-17 thomas local commit_id6=`git_show_head $testroot/repo`
1729 31b44417 2023-02-17 thomas
1730 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q hoo)
1731 31b44417 2023-02-17 thomas echo "modified beta on hoo" > $testroot/repo/beta
1732 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified beta on hoo"
1733 31b44417 2023-02-17 thomas local commit_id7=`git_show_head $testroot/repo`
1734 31b44417 2023-02-17 thomas
1735 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
1736 31b44417 2023-02-17 thomas
1737 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1738 31b44417 2023-02-17 thomas
1739 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1740 31b44417 2023-02-17 thomas ret=$?
1741 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1742 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1743 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1744 31b44417 2023-02-17 thomas return 1
1745 31b44417 2023-02-17 thomas fi
1746 31b44417 2023-02-17 thomas
1747 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1748 31b44417 2023-02-17 thomas
1749 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1750 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1751 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1752 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1753 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1754 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1755 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1756 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1757 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/hoo" \
1758 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1759 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id6" \
1760 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1761 49e8d4dc 2023-02-20 thomas echo "refs/remotes/origin/hoo: $commit_id7" \
1762 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1763 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id5" \
1764 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1765 31b44417 2023-02-17 thomas
1766 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1767 31b44417 2023-02-17 thomas ret=$?
1768 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1769 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1770 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1771 31b44417 2023-02-17 thomas return 1
1772 31b44417 2023-02-17 thomas fi
1773 31b44417 2023-02-17 thomas
1774 31b44417 2023-02-17 thomas # from wt: fetch -b hoo not got.conf "master" or wt "boo" or
1775 31b44417 2023-02-17 thomas # repo HEAD "boo"
1776 31b44417 2023-02-17 thomas (cd $testroot/repo && git checkout -q boo)
1777 31b44417 2023-02-17 thomas echo "modified alpha again on boo" > $testroot/repo/alpha
1778 31b44417 2023-02-17 thomas git_commit $testroot/repo -m "modified alpha again on boo"
1779 31b44417 2023-02-17 thomas local commit_id8=`git_show_head $testroot/repo`
1780 31b44417 2023-02-17 thomas
1781 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -q -b hoo > $testroot/stdout)
1782 31b44417 2023-02-17 thomas
1783 31b44417 2023-02-17 thomas echo -n > $testroot/stdout.expected
1784 31b44417 2023-02-17 thomas
1785 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1786 31b44417 2023-02-17 thomas ret=$?
1787 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1788 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1789 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1790 31b44417 2023-02-17 thomas return 1
1791 31b44417 2023-02-17 thomas fi
1792 31b44417 2023-02-17 thomas
1793 31b44417 2023-02-17 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1794 31b44417 2023-02-17 thomas
1795 31b44417 2023-02-17 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1796 31b44417 2023-02-17 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1797 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1798 31b44417 2023-02-17 thomas echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1799 31b44417 2023-02-17 thomas echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1800 31b44417 2023-02-17 thomas echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1801 31b44417 2023-02-17 thomas echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1802 31b44417 2023-02-17 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1803 31b44417 2023-02-17 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1804 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1805 31b44417 2023-02-17 thomas echo "refs/remotes/origin/boo: $commit_id6" \
1806 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1807 7917d6d5 2023-02-17 thomas echo "refs/remotes/origin/hoo: $commit_id7" \
1808 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1809 31b44417 2023-02-17 thomas echo "refs/remotes/origin/master: $commit_id5" \
1810 31b44417 2023-02-17 thomas >> $testroot/stdout.expected
1811 31b44417 2023-02-17 thomas
1812 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1813 31b44417 2023-02-17 thomas ret=$?
1814 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1815 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1816 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1817 31b44417 2023-02-17 thomas return 1
1818 31b44417 2023-02-17 thomas fi
1819 31b44417 2023-02-17 thomas
1820 31b44417 2023-02-17 thomas # from wt: fetch -b bar that doesn't exist on the server but
1821 31b44417 2023-02-17 thomas # do not fetch got.conf "master" or wt "boo" or repo HEAD "boo"
1822 31b44417 2023-02-17 thomas (cd $testroot/wt && got fetch -b bar > $testroot/stdout \
1823 31b44417 2023-02-17 thomas 2> $testroot/stderr)
1824 31b44417 2023-02-17 thomas
1825 31b44417 2023-02-17 thomas echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1826 31b44417 2023-02-17 thomas > $testroot/stdout.expected
1827 d392cc0a 2023-02-17 thomas echo "got-fetch-pack: branch \"bar\" not found on server" \
1828 31b44417 2023-02-17 thomas > $testroot/stderr.expected
1829 31b44417 2023-02-17 thomas echo "got: could not find any branches to fetch" \
1830 31b44417 2023-02-17 thomas >> $testroot/stderr.expected
1831 31b44417 2023-02-17 thomas
1832 31b44417 2023-02-17 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1833 31b44417 2023-02-17 thomas ret=$?
1834 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1835 31b44417 2023-02-17 thomas diff -u $testroot/stderr.expected $testroot/stderr
1836 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1837 31b44417 2023-02-17 thomas return 1
1838 31b44417 2023-02-17 thomas fi
1839 31b44417 2023-02-17 thomas
1840 31b44417 2023-02-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1841 31b44417 2023-02-17 thomas ret=$?
1842 31b44417 2023-02-17 thomas if [ $ret -ne 0 ]; then
1843 31b44417 2023-02-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
1844 31b44417 2023-02-17 thomas fi
1845 31b44417 2023-02-17 thomas test_done "$testroot" "$ret"
1846 31b44417 2023-02-17 thomas }
1847 c12ab9ad 2023-02-21 thomas
1848 c12ab9ad 2023-02-21 thomas test_fetch_from_out_of_date_remote() {
1849 c12ab9ad 2023-02-21 thomas local testroot=`test_init fetch_from_out_of_date_remote`
1850 c12ab9ad 2023-02-21 thomas local testurl=ssh://127.0.0.1/$testroot
1851 c12ab9ad 2023-02-21 thomas local commit_id=`git_show_head $testroot/repo`
1852 c12ab9ad 2023-02-21 thomas
1853 c12ab9ad 2023-02-21 thomas got clone -q $testurl/repo $testroot/repo-clone
1854 c12ab9ad 2023-02-21 thomas ret=$?
1855 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1856 c12ab9ad 2023-02-21 thomas echo "got clone command failed unexpectedly" >&2
1857 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1858 c12ab9ad 2023-02-21 thomas return 1
1859 c12ab9ad 2023-02-21 thomas fi
1860 31b44417 2023-02-17 thomas
1861 c12ab9ad 2023-02-21 thomas echo "modified alpha" > $testroot/repo/alpha
1862 c12ab9ad 2023-02-21 thomas git_commit $testroot/repo -m "modified alpha"
1863 c12ab9ad 2023-02-21 thomas local commit_id2=`git_show_head $testroot/repo`
1864 c12ab9ad 2023-02-21 thomas
1865 c12ab9ad 2023-02-21 thomas got clone -q $testurl/repo $testroot/repo-clone2 \
1866 c12ab9ad 2023-02-21 thomas > $testroot/stdout 2> $testroot/stderr
1867 c12ab9ad 2023-02-21 thomas ret=$?
1868 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1869 c12ab9ad 2023-02-21 thomas echo "got clone command failed unexpectedly" >&2
1870 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1871 c12ab9ad 2023-02-21 thomas return 1
1872 c12ab9ad 2023-02-21 thomas fi
1873 c12ab9ad 2023-02-21 thomas
1874 c12ab9ad 2023-02-21 thomas got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1875 c12ab9ad 2023-02-21 thomas ret=$?
1876 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1877 c12ab9ad 2023-02-21 thomas echo "got ref command failed unexpectedly" >&2
1878 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1879 c12ab9ad 2023-02-21 thomas return 1
1880 c12ab9ad 2023-02-21 thomas fi
1881 c12ab9ad 2023-02-21 thomas
1882 c12ab9ad 2023-02-21 thomas cat > $testroot/stdout.expected <<EOF
1883 c12ab9ad 2023-02-21 thomas HEAD: refs/heads/master
1884 c12ab9ad 2023-02-21 thomas refs/heads/master: $commit_id2
1885 c12ab9ad 2023-02-21 thomas refs/remotes/origin/HEAD: refs/remotes/origin/master
1886 c12ab9ad 2023-02-21 thomas refs/remotes/origin/master: $commit_id2
1887 c12ab9ad 2023-02-21 thomas EOF
1888 c12ab9ad 2023-02-21 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1889 c12ab9ad 2023-02-21 thomas ret=$?
1890 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1891 c12ab9ad 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1892 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1893 c12ab9ad 2023-02-21 thomas return 1
1894 c12ab9ad 2023-02-21 thomas fi
1895 c12ab9ad 2023-02-21 thomas
1896 c12ab9ad 2023-02-21 thomas cat >> $testroot/repo-clone2/got.conf <<EOF
1897 c12ab9ad 2023-02-21 thomas remote "other" {
1898 c12ab9ad 2023-02-21 thomas server "127.0.0.1"
1899 c12ab9ad 2023-02-21 thomas protocol ssh
1900 c12ab9ad 2023-02-21 thomas repository "$testroot/repo-clone"
1901 c12ab9ad 2023-02-21 thomas branch { "master" }
1902 c12ab9ad 2023-02-21 thomas }
1903 c12ab9ad 2023-02-21 thomas EOF
1904 c12ab9ad 2023-02-21 thomas got fetch -q -r $testroot/repo-clone2 other \
1905 c12ab9ad 2023-02-21 thomas > $testroot/stdout 2> $testroot/stderr
1906 c12ab9ad 2023-02-21 thomas ret=$?
1907 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1908 c12ab9ad 2023-02-21 thomas echo "got fetch command failed unexpectedly" >&2
1909 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1910 c12ab9ad 2023-02-21 thomas return 1
1911 c12ab9ad 2023-02-21 thomas fi
1912 c12ab9ad 2023-02-21 thomas
1913 c12ab9ad 2023-02-21 thomas got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1914 c12ab9ad 2023-02-21 thomas ret=$?
1915 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1916 c12ab9ad 2023-02-21 thomas echo "got ref command failed unexpectedly" >&2
1917 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1918 c12ab9ad 2023-02-21 thomas return 1
1919 c12ab9ad 2023-02-21 thomas fi
1920 c12ab9ad 2023-02-21 thomas
1921 c12ab9ad 2023-02-21 thomas cat > $testroot/stdout.expected <<EOF
1922 c12ab9ad 2023-02-21 thomas HEAD: refs/heads/master
1923 c12ab9ad 2023-02-21 thomas refs/heads/master: $commit_id2
1924 c12ab9ad 2023-02-21 thomas refs/remotes/origin/HEAD: refs/remotes/origin/master
1925 c12ab9ad 2023-02-21 thomas refs/remotes/origin/master: $commit_id2
1926 c12ab9ad 2023-02-21 thomas refs/remotes/other/HEAD: refs/remotes/other/master
1927 c12ab9ad 2023-02-21 thomas refs/remotes/other/master: $commit_id
1928 c12ab9ad 2023-02-21 thomas EOF
1929 c12ab9ad 2023-02-21 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1930 c12ab9ad 2023-02-21 thomas ret=$?
1931 c12ab9ad 2023-02-21 thomas if [ $ret -ne 0 ]; then
1932 c12ab9ad 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1933 c12ab9ad 2023-02-21 thomas fi
1934 c12ab9ad 2023-02-21 thomas test_done "$testroot" "$ret"
1935 c12ab9ad 2023-02-21 thomas
1936 c12ab9ad 2023-02-21 thomas }
1937 c12ab9ad 2023-02-21 thomas
1938 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1939 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1940 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1941 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1942 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1943 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1944 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1945 1b796c3f 2021-09-11 stsp run_test test_fetch_delete_branch_mirror
1946 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1947 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1948 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1949 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1950 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1951 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo
1952 161728eb 2021-07-24 stsp run_test test_fetch_delete_remote_refs
1953 31b44417 2023-02-17 thomas run_test test_fetch_honor_wt_conf_bflag
1954 c12ab9ad 2023-02-21 thomas run_test test_fetch_from_out_of_date_remote