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 8d0dceb3 2023-02-07 thomas # foo is now the default HEAD branch in $testroot/repo
192 8d0dceb3 2023-02-07 thomas # but got.conf still says to fetch "master"
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 9d0a7ee3 2023-02-07 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
215 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
216 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
217 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
218 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
219 9d0a7ee3 2023-02-07 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
220 9d0a7ee3 2023-02-07 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
221 9d0a7ee3 2023-02-07 thomas
222 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
223 9d0a7ee3 2023-02-07 thomas ret=$?
224 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
225 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
226 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
227 9d0a7ee3 2023-02-07 thomas return 1
228 9d0a7ee3 2023-02-07 thomas fi
229 9d0a7ee3 2023-02-07 thomas
230 9d0a7ee3 2023-02-07 thomas # fetch branch foo via command-line switch
231 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
232 fc414659 2022-04-16 thomas ret=$?
233 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
234 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
235 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
236 c8c71e6e 2020-03-21 stsp return 1
237 c8c71e6e 2020-03-21 stsp fi
238 c8c71e6e 2020-03-21 stsp
239 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
240 c8c71e6e 2020-03-21 stsp
241 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
242 fc414659 2022-04-16 thomas ret=$?
243 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
244 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
245 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
246 c8c71e6e 2020-03-21 stsp return 1
247 c8c71e6e 2020-03-21 stsp fi
248 c8c71e6e 2020-03-21 stsp
249 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
250 c8c71e6e 2020-03-21 stsp
251 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
254 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
255 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
256 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
257 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
258 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
259 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
260 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
261 c8c71e6e 2020-03-21 stsp
262 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
263 fc414659 2022-04-16 thomas ret=$?
264 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
265 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
267 c8c71e6e 2020-03-21 stsp return 1
268 c8c71e6e 2020-03-21 stsp fi
269 c8c71e6e 2020-03-21 stsp
270 8d0dceb3 2023-02-07 thomas # got.conf tells us to fetch the 'master' branch by default
271 8d0dceb3 2023-02-07 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
272 fc414659 2022-04-16 thomas ret=$?
273 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
274 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
275 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
276 c8c71e6e 2020-03-21 stsp return 1
277 c8c71e6e 2020-03-21 stsp fi
278 c8c71e6e 2020-03-21 stsp
279 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
280 c8c71e6e 2020-03-21 stsp
281 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
282 fc414659 2022-04-16 thomas ret=$?
283 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
284 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
286 c8c71e6e 2020-03-21 stsp return 1
287 c8c71e6e 2020-03-21 stsp fi
288 c8c71e6e 2020-03-21 stsp
289 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
290 c8c71e6e 2020-03-21 stsp
291 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
292 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
293 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
294 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
295 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
296 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
297 91b10dd2 2023-02-03 thomas echo "refs/remotes/origin/master: $commit_id2" \
298 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
299 91b10dd2 2023-02-03 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
300 91b10dd2 2023-02-03 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
301 91b10dd2 2023-02-03 thomas
302 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
303 91b10dd2 2023-02-03 thomas ret=$?
304 91b10dd2 2023-02-03 thomas if [ $ret -ne 0 ]; then
305 91b10dd2 2023-02-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
306 91b10dd2 2023-02-03 thomas test_done "$testroot" "$ret"
307 91b10dd2 2023-02-03 thomas return 1
308 91b10dd2 2023-02-03 thomas fi
309 91b10dd2 2023-02-03 thomas
310 91b10dd2 2023-02-03 thomas echo "modified beta on foo" > $testroot/repo/beta
311 91b10dd2 2023-02-03 thomas git_commit $testroot/repo -m "modified beta"
312 91b10dd2 2023-02-03 thomas local commit_id4=`git_show_head $testroot/repo`
313 91b10dd2 2023-02-03 thomas
314 8d0dceb3 2023-02-07 thomas # set the default HEAD branch back to master
315 8d0dceb3 2023-02-07 thomas (cd $testroot/repo && git checkout -q master)
316 8d0dceb3 2023-02-07 thomas
317 91b10dd2 2023-02-03 thomas got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
318 91b10dd2 2023-02-03 thomas
319 91b10dd2 2023-02-03 thomas # fetch new commits on branch 'foo', implicitly obtaining the
320 91b10dd2 2023-02-03 thomas # branch name from a work tree
321 91b10dd2 2023-02-03 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
322 91b10dd2 2023-02-03 thomas
323 91b10dd2 2023-02-03 thomas echo -n > $testroot/stdout.expected
324 91b10dd2 2023-02-03 thomas
325 91b10dd2 2023-02-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
326 91b10dd2 2023-02-03 thomas ret=$?
327 91b10dd2 2023-02-03 thomas if [ $ret -ne 0 ]; then
328 91b10dd2 2023-02-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
329 91b10dd2 2023-02-03 thomas test_done "$testroot" "$ret"
330 91b10dd2 2023-02-03 thomas return 1
331 91b10dd2 2023-02-03 thomas fi
332 91b10dd2 2023-02-03 thomas
333 91b10dd2 2023-02-03 thomas wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
334 91b10dd2 2023-02-03 thomas cut -d ':' -f 2 | tr -d ' ')`
335 91b10dd2 2023-02-03 thomas
336 91b10dd2 2023-02-03 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
337 91b10dd2 2023-02-03 thomas
338 91b10dd2 2023-02-03 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
339 91b10dd2 2023-02-03 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
340 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
341 91b10dd2 2023-02-03 thomas echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
342 91b10dd2 2023-02-03 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
343 8d0dceb3 2023-02-07 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
344 91b10dd2 2023-02-03 thomas >> $testroot/stdout.expected
345 91b10dd2 2023-02-03 thomas echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
346 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
347 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
348 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
349 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
350 c8c71e6e 2020-03-21 stsp
351 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
352 fc414659 2022-04-16 thomas ret=$?
353 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
354 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
355 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
356 9d0a7ee3 2023-02-07 thomas return 1
357 c8c71e6e 2020-03-21 stsp fi
358 9d0a7ee3 2023-02-07 thomas
359 9d0a7ee3 2023-02-07 thomas # remove default branch information from got.conf
360 9d0a7ee3 2023-02-07 thomas sed -i -e "/branch {/d" $testroot/repo-clone/got.conf
361 9d0a7ee3 2023-02-07 thomas
362 9d0a7ee3 2023-02-07 thomas # make another change on 'foo' and fetch it without got.conf
363 9d0a7ee3 2023-02-07 thomas (cd $testroot/repo && git checkout -q foo)
364 9d0a7ee3 2023-02-07 thomas echo "modified beta on foo agan" > $testroot/repo/beta
365 9d0a7ee3 2023-02-07 thomas git_commit $testroot/repo -m "modified beta"
366 9d0a7ee3 2023-02-07 thomas local commit_id5=`git_show_head $testroot/repo`
367 9d0a7ee3 2023-02-07 thomas (cd $testroot/repo && git checkout -q master)
368 9d0a7ee3 2023-02-07 thomas
369 9d0a7ee3 2023-02-07 thomas # fetch new commits on branch 'foo', implicitly obtaining the
370 9d0a7ee3 2023-02-07 thomas # branch name from a work tree
371 9d0a7ee3 2023-02-07 thomas (cd $testroot/wt && got fetch -q > $testroot/stdout)
372 9d0a7ee3 2023-02-07 thomas
373 9d0a7ee3 2023-02-07 thomas echo -n > $testroot/stdout.expected
374 9d0a7ee3 2023-02-07 thomas
375 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
376 9d0a7ee3 2023-02-07 thomas ret=$?
377 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
378 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
379 9d0a7ee3 2023-02-07 thomas test_done "$testroot" "$ret"
380 9d0a7ee3 2023-02-07 thomas return 1
381 9d0a7ee3 2023-02-07 thomas fi
382 9d0a7ee3 2023-02-07 thomas
383 9d0a7ee3 2023-02-07 thomas wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
384 9d0a7ee3 2023-02-07 thomas cut -d ':' -f 2 | tr -d ' ')`
385 9d0a7ee3 2023-02-07 thomas
386 9d0a7ee3 2023-02-07 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
387 9d0a7ee3 2023-02-07 thomas
388 9d0a7ee3 2023-02-07 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
389 9d0a7ee3 2023-02-07 thomas echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
390 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
391 9d0a7ee3 2023-02-07 thomas echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
392 9d0a7ee3 2023-02-07 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
393 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
394 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
395 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
396 9d0a7ee3 2023-02-07 thomas echo "refs/remotes/origin/master: $commit_id2" \
397 9d0a7ee3 2023-02-07 thomas >> $testroot/stdout.expected
398 9d0a7ee3 2023-02-07 thomas # refs/hoo/boo/zoo is missing because it is outside of refs/heads
399 9d0a7ee3 2023-02-07 thomas echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
400 9d0a7ee3 2023-02-07 thomas
401 9d0a7ee3 2023-02-07 thomas cmp -s $testroot/stdout $testroot/stdout.expected
402 9d0a7ee3 2023-02-07 thomas ret=$?
403 9d0a7ee3 2023-02-07 thomas if [ $ret -ne 0 ]; then
404 9d0a7ee3 2023-02-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
405 9d0a7ee3 2023-02-07 thomas fi
406 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
407 c8c71e6e 2020-03-21 stsp }
408 c8c71e6e 2020-03-21 stsp
409 f6cae3ed 2020-09-13 naddy test_fetch_all() {
410 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
411 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
412 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
413 c8c71e6e 2020-03-21 stsp
414 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
415 fc414659 2022-04-16 thomas ret=$?
416 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
417 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
418 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
419 c8c71e6e 2020-03-21 stsp return 1
420 c8c71e6e 2020-03-21 stsp fi
421 c8c71e6e 2020-03-21 stsp
422 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
423 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
424 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
425 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
426 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
427 c8c71e6e 2020-03-21 stsp
428 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
429 c8c71e6e 2020-03-21 stsp
430 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
431 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
432 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
433 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
434 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
435 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
436 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
437 c8c71e6e 2020-03-21 stsp
438 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
439 fc414659 2022-04-16 thomas ret=$?
440 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
441 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
442 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
443 c8c71e6e 2020-03-21 stsp return 1
444 c8c71e6e 2020-03-21 stsp fi
445 c8c71e6e 2020-03-21 stsp
446 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
447 fc414659 2022-04-16 thomas ret=$?
448 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
449 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
450 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
451 c8c71e6e 2020-03-21 stsp return 1
452 c8c71e6e 2020-03-21 stsp fi
453 c8c71e6e 2020-03-21 stsp
454 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
455 c8c71e6e 2020-03-21 stsp
456 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
457 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
458 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
459 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
460 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
461 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
462 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
463 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
464 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
465 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
466 c8c71e6e 2020-03-21 stsp
467 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
468 fc414659 2022-04-16 thomas ret=$?
469 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
470 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
471 c8c71e6e 2020-03-21 stsp fi
472 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
473 c8c71e6e 2020-03-21 stsp }
474 c8c71e6e 2020-03-21 stsp
475 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
476 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
477 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
478 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
479 c8c71e6e 2020-03-21 stsp
480 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
481 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
482 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
483 c8c71e6e 2020-03-21 stsp
484 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
485 fc414659 2022-04-16 thomas ret=$?
486 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
487 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
488 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
489 c8c71e6e 2020-03-21 stsp return 1
490 c8c71e6e 2020-03-21 stsp fi
491 c8c71e6e 2020-03-21 stsp
492 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
493 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
494 c8c71e6e 2020-03-21 stsp
495 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
496 c8c71e6e 2020-03-21 stsp
497 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
498 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
499 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
500 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
501 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
502 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
503 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
504 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
505 c8c71e6e 2020-03-21 stsp
506 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
507 fc414659 2022-04-16 thomas ret=$?
508 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
509 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
510 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
511 c8c71e6e 2020-03-21 stsp return 1
512 c8c71e6e 2020-03-21 stsp fi
513 c8c71e6e 2020-03-21 stsp
514 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
515 fc414659 2022-04-16 thomas ret=$?
516 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
517 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
518 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
519 c8c71e6e 2020-03-21 stsp return 1
520 c8c71e6e 2020-03-21 stsp fi
521 c8c71e6e 2020-03-21 stsp
522 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
523 c8c71e6e 2020-03-21 stsp
524 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
525 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
526 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
527 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
528 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
529 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
530 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
531 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
532 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
533 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
534 c8c71e6e 2020-03-21 stsp
535 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
536 fc414659 2022-04-16 thomas ret=$?
537 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
538 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 c8c71e6e 2020-03-21 stsp fi
540 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
541 c8c71e6e 2020-03-21 stsp }
542 c8c71e6e 2020-03-21 stsp
543 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
544 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
545 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
546 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
547 c8c71e6e 2020-03-21 stsp
548 c8c71e6e 2020-03-21 stsp
549 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
550 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
551 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
552 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
553 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
554 c8c71e6e 2020-03-21 stsp
555 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
556 fc414659 2022-04-16 thomas ret=$?
557 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
558 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
559 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
560 c8c71e6e 2020-03-21 stsp return 1
561 c8c71e6e 2020-03-21 stsp fi
562 c8c71e6e 2020-03-21 stsp
563 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
564 c8c71e6e 2020-03-21 stsp
565 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
566 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
567 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
568 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
569 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
570 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
571 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
572 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
573 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
574 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
575 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
576 c8c71e6e 2020-03-21 stsp
577 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
578 fc414659 2022-04-16 thomas ret=$?
579 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
580 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
581 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
582 c8c71e6e 2020-03-21 stsp return 1
583 c8c71e6e 2020-03-21 stsp fi
584 c8c71e6e 2020-03-21 stsp
585 978a28a1 2021-09-04 naddy got branch -r $testroot/repo -d foo >/dev/null
586 c8c71e6e 2020-03-21 stsp
587 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
588 fc414659 2022-04-16 thomas ret=$?
589 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
590 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
591 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
592 c8c71e6e 2020-03-21 stsp return 1
593 c8c71e6e 2020-03-21 stsp fi
594 c8c71e6e 2020-03-21 stsp
595 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
596 c8c71e6e 2020-03-21 stsp
597 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
598 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
599 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
600 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
601 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
602 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
603 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
604 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
605 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
606 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
607 c8c71e6e 2020-03-21 stsp
608 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
609 fc414659 2022-04-16 thomas ret=$?
610 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
611 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
612 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
613 c8c71e6e 2020-03-21 stsp return 1
614 c8c71e6e 2020-03-21 stsp fi
615 c8c71e6e 2020-03-21 stsp
616 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
617 fc414659 2022-04-16 thomas ret=$?
618 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
619 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
620 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
621 c8c71e6e 2020-03-21 stsp return 1
622 c8c71e6e 2020-03-21 stsp fi
623 c8c71e6e 2020-03-21 stsp
624 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
625 c8c71e6e 2020-03-21 stsp
626 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
627 fc414659 2022-04-16 thomas ret=$?
628 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
629 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
631 c8c71e6e 2020-03-21 stsp return 1
632 c8c71e6e 2020-03-21 stsp fi
633 c8c71e6e 2020-03-21 stsp
634 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
635 c8c71e6e 2020-03-21 stsp
636 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
637 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
638 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
639 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
640 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
641 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
642 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
643 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
644 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
645 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
646 c8c71e6e 2020-03-21 stsp
647 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
648 fc414659 2022-04-16 thomas ret=$?
649 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
650 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
651 c8c71e6e 2020-03-21 stsp fi
652 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
653 c8c71e6e 2020-03-21 stsp
654 c8c71e6e 2020-03-21 stsp }
655 1b796c3f 2021-09-11 stsp
656 1b796c3f 2021-09-11 stsp test_fetch_delete_branch_mirror() {
657 1b796c3f 2021-09-11 stsp local testroot=`test_init fetch_delete_branch_mirror`
658 1b796c3f 2021-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
659 1b796c3f 2021-09-11 stsp local commit_id=`git_show_head $testroot/repo`
660 1b796c3f 2021-09-11 stsp
661 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
662 1b796c3f 2021-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
663 1b796c3f 2021-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
664 1b796c3f 2021-09-11 stsp local tag_id=`got ref -r $testroot/repo -l \
665 1b796c3f 2021-09-11 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
666 1b796c3f 2021-09-11 stsp
667 1b796c3f 2021-09-11 stsp got clone -a -m -q $testurl/repo $testroot/repo-clone
668 fc414659 2022-04-16 thomas ret=$?
669 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
670 1b796c3f 2021-09-11 stsp echo "got clone command failed unexpectedly" >&2
671 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
672 1b796c3f 2021-09-11 stsp return 1
673 1b796c3f 2021-09-11 stsp fi
674 1b796c3f 2021-09-11 stsp
675 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
676 1b796c3f 2021-09-11 stsp
677 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
678 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
679 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
680 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
681 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
682 db6d8ad8 2020-03-21 stsp
683 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
684 fc414659 2022-04-16 thomas ret=$?
685 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
686 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
687 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
688 1b796c3f 2021-09-11 stsp return 1
689 1b796c3f 2021-09-11 stsp fi
690 1b796c3f 2021-09-11 stsp
691 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -d foo >/dev/null
692 1b796c3f 2021-09-11 stsp
693 1b796c3f 2021-09-11 stsp got fetch -q -r $testroot/repo-clone
694 fc414659 2022-04-16 thomas ret=$?
695 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
696 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
697 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
698 1b796c3f 2021-09-11 stsp return 1
699 1b796c3f 2021-09-11 stsp fi
700 1b796c3f 2021-09-11 stsp
701 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
702 1b796c3f 2021-09-11 stsp
703 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
704 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
705 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
706 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
707 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
708 1b796c3f 2021-09-11 stsp
709 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
710 fc414659 2022-04-16 thomas ret=$?
711 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
712 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
713 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
714 1b796c3f 2021-09-11 stsp return 1
715 1b796c3f 2021-09-11 stsp fi
716 1b796c3f 2021-09-11 stsp
717 1b796c3f 2021-09-11 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
718 fc414659 2022-04-16 thomas ret=$?
719 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
720 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
721 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
722 1b796c3f 2021-09-11 stsp return 1
723 1b796c3f 2021-09-11 stsp fi
724 1b796c3f 2021-09-11 stsp
725 1b796c3f 2021-09-11 stsp echo -n > $testroot/stdout.expected
726 1b796c3f 2021-09-11 stsp
727 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
728 fc414659 2022-04-16 thomas ret=$?
729 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
730 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
731 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
732 1b796c3f 2021-09-11 stsp return 1
733 1b796c3f 2021-09-11 stsp fi
734 1b796c3f 2021-09-11 stsp
735 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
736 1b796c3f 2021-09-11 stsp
737 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
738 1b796c3f 2021-09-11 stsp # refs/heads/foo is now deleted
739 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
740 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
741 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
742 1b796c3f 2021-09-11 stsp
743 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
744 fc414659 2022-04-16 thomas ret=$?
745 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
746 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
747 1b796c3f 2021-09-11 stsp fi
748 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
749 1b796c3f 2021-09-11 stsp
750 1b796c3f 2021-09-11 stsp }
751 1b796c3f 2021-09-11 stsp
752 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
753 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
754 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
755 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
756 db6d8ad8 2020-03-21 stsp
757 db6d8ad8 2020-03-21 stsp
758 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
759 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
760 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
761 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
762 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
763 db6d8ad8 2020-03-21 stsp
764 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
765 fc414659 2022-04-16 thomas ret=$?
766 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
767 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
768 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
769 db6d8ad8 2020-03-21 stsp return 1
770 db6d8ad8 2020-03-21 stsp fi
771 db6d8ad8 2020-03-21 stsp
772 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
773 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
774 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
775 db6d8ad8 2020-03-21 stsp
776 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
777 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
778 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
779 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
780 db6d8ad8 2020-03-21 stsp
781 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
782 db6d8ad8 2020-03-21 stsp
783 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
784 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
785 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
786 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
787 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
788 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
789 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
790 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
791 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
792 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
793 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
794 c8c71e6e 2020-03-21 stsp
795 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
796 fc414659 2022-04-16 thomas ret=$?
797 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
798 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
799 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
800 db6d8ad8 2020-03-21 stsp return 1
801 db6d8ad8 2020-03-21 stsp fi
802 db6d8ad8 2020-03-21 stsp
803 98f64f14 2021-01-05 stsp got fetch -a -q -r $testroot/repo-clone
804 fc414659 2022-04-16 thomas ret=$?
805 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
806 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
807 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
808 db6d8ad8 2020-03-21 stsp return 1
809 db6d8ad8 2020-03-21 stsp fi
810 db6d8ad8 2020-03-21 stsp
811 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
812 db6d8ad8 2020-03-21 stsp
813 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
814 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
815 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
816 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
817 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
818 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
819 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
820 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
821 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
822 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
823 db6d8ad8 2020-03-21 stsp
824 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
825 fc414659 2022-04-16 thomas ret=$?
826 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
827 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
828 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
829 db6d8ad8 2020-03-21 stsp return 1
830 db6d8ad8 2020-03-21 stsp fi
831 db6d8ad8 2020-03-21 stsp
832 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
833 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
834 fc414659 2022-04-16 thomas ret=$?
835 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
836 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
837 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
838 db6d8ad8 2020-03-21 stsp return 1
839 db6d8ad8 2020-03-21 stsp fi
840 db6d8ad8 2020-03-21 stsp
841 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
842 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
843 db6d8ad8 2020-03-21 stsp
844 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
845 fc414659 2022-04-16 thomas ret=$?
846 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
847 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
848 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
849 db6d8ad8 2020-03-21 stsp return 1
850 db6d8ad8 2020-03-21 stsp fi
851 db6d8ad8 2020-03-21 stsp
852 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
853 db6d8ad8 2020-03-21 stsp
854 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
855 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
856 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
857 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
858 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
859 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
860 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
861 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
862 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
863 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
864 db6d8ad8 2020-03-21 stsp
865 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
866 fc414659 2022-04-16 thomas ret=$?
867 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
868 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
869 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
870 db6d8ad8 2020-03-21 stsp return 1
871 db6d8ad8 2020-03-21 stsp fi
872 db6d8ad8 2020-03-21 stsp
873 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
874 fc414659 2022-04-16 thomas ret=$?
875 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
876 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
877 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
878 db6d8ad8 2020-03-21 stsp return 1
879 db6d8ad8 2020-03-21 stsp fi
880 db6d8ad8 2020-03-21 stsp
881 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
882 db6d8ad8 2020-03-21 stsp
883 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
884 fc414659 2022-04-16 thomas ret=$?
885 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
886 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
887 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
888 db6d8ad8 2020-03-21 stsp return 1
889 db6d8ad8 2020-03-21 stsp fi
890 db6d8ad8 2020-03-21 stsp
891 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
892 db6d8ad8 2020-03-21 stsp
893 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
894 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
895 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
896 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
897 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
898 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
899 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
900 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
901 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
902 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
903 db6d8ad8 2020-03-21 stsp
904 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
905 fc414659 2022-04-16 thomas ret=$?
906 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
907 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 db6d8ad8 2020-03-21 stsp fi
909 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
910 db6d8ad8 2020-03-21 stsp }
911 0e4002ca 2020-03-21 stsp
912 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
913 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
914 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
915 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
916 db6d8ad8 2020-03-21 stsp
917 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
918 fc414659 2022-04-16 thomas ret=$?
919 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
920 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
921 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
922 0e4002ca 2020-03-21 stsp return 1
923 0e4002ca 2020-03-21 stsp fi
924 0e4002ca 2020-03-21 stsp
925 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
926 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
927 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
928 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
929 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
930 0e4002ca 2020-03-21 stsp
931 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
932 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
933 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
934 0e4002ca 2020-03-21 stsp
935 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
936 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
937 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
938 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
939 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
940 0e4002ca 2020-03-21 stsp
941 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
942 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
943 fc414659 2022-04-16 thomas ret=$?
944 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
945 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
946 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
947 0e4002ca 2020-03-21 stsp return 1
948 0e4002ca 2020-03-21 stsp fi
949 0e4002ca 2020-03-21 stsp
950 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
951 0e4002ca 2020-03-21 stsp
952 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
953 fc414659 2022-04-16 thomas ret=$?
954 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
955 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
956 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
957 0e4002ca 2020-03-21 stsp return 1
958 0e4002ca 2020-03-21 stsp fi
959 0e4002ca 2020-03-21 stsp
960 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
961 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
962 0e4002ca 2020-03-21 stsp
963 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
964 fc414659 2022-04-16 thomas ret=$?
965 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
966 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
967 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
968 0e4002ca 2020-03-21 stsp return 1
969 0e4002ca 2020-03-21 stsp fi
970 0e4002ca 2020-03-21 stsp
971 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
972 fc414659 2022-04-16 thomas ret=$?
973 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
974 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
975 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
976 0e4002ca 2020-03-21 stsp return 1
977 0e4002ca 2020-03-21 stsp fi
978 0e4002ca 2020-03-21 stsp
979 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
980 0e4002ca 2020-03-21 stsp
981 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
982 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
983 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
984 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
985 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
986 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
987 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
988 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
989 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
990 e8a967e0 2020-03-21 stsp
991 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
992 fc414659 2022-04-16 thomas ret=$?
993 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
994 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
995 e8a967e0 2020-03-21 stsp fi
996 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
997 e8a967e0 2020-03-21 stsp
998 e8a967e0 2020-03-21 stsp }
999 e8a967e0 2020-03-21 stsp
1000 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
1001 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
1002 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
1003 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
1004 e8a967e0 2020-03-21 stsp
1005 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
1006 fc414659 2022-04-16 thomas ret=$?
1007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1008 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
1009 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1010 e8a967e0 2020-03-21 stsp return 1
1011 e8a967e0 2020-03-21 stsp fi
1012 e8a967e0 2020-03-21 stsp
1013 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1014 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1015 e8a967e0 2020-03-21 stsp
1016 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1017 e8a967e0 2020-03-21 stsp
1018 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1019 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1020 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1021 e8a967e0 2020-03-21 stsp
1022 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1023 fc414659 2022-04-16 thomas ret=$?
1024 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1025 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1027 e8a967e0 2020-03-21 stsp return 1
1028 e8a967e0 2020-03-21 stsp fi
1029 0e4002ca 2020-03-21 stsp
1030 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
1031 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1032 fc414659 2022-04-16 thomas ret=$?
1033 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1034 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
1035 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1036 e8a967e0 2020-03-21 stsp return 1
1037 e8a967e0 2020-03-21 stsp fi
1038 e8a967e0 2020-03-21 stsp
1039 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1040 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
1041 e8a967e0 2020-03-21 stsp
1042 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1043 fc414659 2022-04-16 thomas ret=$?
1044 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1045 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1046 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1047 e8a967e0 2020-03-21 stsp return 1
1048 0e4002ca 2020-03-21 stsp fi
1049 e8a967e0 2020-03-21 stsp
1050 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1051 e8a967e0 2020-03-21 stsp
1052 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1053 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1054 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1055 f1bcca34 2020-03-25 stsp
1056 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1057 fc414659 2022-04-16 thomas ret=$?
1058 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1059 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1060 f1bcca34 2020-03-25 stsp fi
1061 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1062 f1bcca34 2020-03-25 stsp
1063 f1bcca34 2020-03-25 stsp }
1064 f1bcca34 2020-03-25 stsp
1065 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
1066 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
1067 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
1068 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
1069 f1bcca34 2020-03-25 stsp
1070 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
1071 fc414659 2022-04-16 thomas ret=$?
1072 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1073 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
1074 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1075 f1bcca34 2020-03-25 stsp return 1
1076 f1bcca34 2020-03-25 stsp fi
1077 f1bcca34 2020-03-25 stsp
1078 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1079 f1bcca34 2020-03-25 stsp
1080 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1081 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1082 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1083 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1084 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1085 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1086 f1bcca34 2020-03-25 stsp
1087 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1088 fc414659 2022-04-16 thomas ret=$?
1089 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1090 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1091 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1092 f1bcca34 2020-03-25 stsp return 1
1093 f1bcca34 2020-03-25 stsp fi
1094 e8a967e0 2020-03-21 stsp
1095 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1096 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
1097 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
1098 f1bcca34 2020-03-25 stsp
1099 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1100 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1101 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1102 f1bcca34 2020-03-25 stsp
1103 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1104 fc414659 2022-04-16 thomas ret=$?
1105 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1106 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1107 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1108 f1bcca34 2020-03-25 stsp return 1
1109 e8a967e0 2020-03-21 stsp fi
1110 f1bcca34 2020-03-25 stsp
1111 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
1112 f1bcca34 2020-03-25 stsp
1113 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1114 f1bcca34 2020-03-25 stsp
1115 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1116 15d3c221 2021-01-05 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1117 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1118 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1119 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/master: $commit_id" \
1120 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1121 15d3c221 2021-01-05 stsp
1122 15d3c221 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1123 fc414659 2022-04-16 thomas ret=$?
1124 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1125 15d3c221 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1126 15d3c221 2021-01-05 stsp test_done "$testroot" "$ret"
1127 15d3c221 2021-01-05 stsp return 1
1128 15d3c221 2021-01-05 stsp fi
1129 15d3c221 2021-01-05 stsp
1130 15d3c221 2021-01-05 stsp got fetch -q -r $testroot/repo-clone -a
1131 15d3c221 2021-01-05 stsp
1132 15d3c221 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1133 15d3c221 2021-01-05 stsp
1134 15d3c221 2021-01-05 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1135 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1136 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1137 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1138 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1139 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
1140 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1141 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1142 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1143 f1bcca34 2020-03-25 stsp
1144 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1145 fc414659 2022-04-16 thomas ret=$?
1146 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1147 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1148 f1bcca34 2020-03-25 stsp fi
1149 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1150 bcf34b0e 2020-03-26 stsp }
1151 bcf34b0e 2020-03-26 stsp
1152 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
1153 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
1154 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
1155 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
1156 bcf34b0e 2020-03-26 stsp
1157 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1158 fc414659 2022-04-16 thomas ret=$?
1159 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1160 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
1161 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1162 bcf34b0e 2020-03-26 stsp return 1
1163 bcf34b0e 2020-03-26 stsp fi
1164 bcf34b0e 2020-03-26 stsp
1165 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1166 0e4002ca 2020-03-21 stsp
1167 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1168 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1169 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1170 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1171 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1172 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1173 bcf34b0e 2020-03-26 stsp
1174 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1175 fc414659 2022-04-16 thomas ret=$?
1176 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1177 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1178 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1179 bcf34b0e 2020-03-26 stsp return 1
1180 bcf34b0e 2020-03-26 stsp fi
1181 bcf34b0e 2020-03-26 stsp
1182 993f033b 2021-07-16 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1183 bcf34b0e 2020-03-26 stsp
1184 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
1185 fc414659 2022-04-16 thomas ret=$?
1186 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1187 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
1188 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1189 bcf34b0e 2020-03-26 stsp return 1
1190 bcf34b0e 2020-03-26 stsp fi
1191 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1192 bcf34b0e 2020-03-26 stsp
1193 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1194 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1195 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
1196 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1197 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1198 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1199 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1200 50b0790e 2020-09-11 stsp
1201 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1202 fc414659 2022-04-16 thomas ret=$?
1203 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1204 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1205 50b0790e 2020-09-11 stsp fi
1206 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1207 50b0790e 2020-09-11 stsp }
1208 50b0790e 2020-09-11 stsp
1209 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
1210 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
1211 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
1212 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
1213 50b0790e 2020-09-11 stsp
1214 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
1215 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1216 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1217 50b0790e 2020-09-11 stsp
1218 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
1219 fc414659 2022-04-16 thomas ret=$?
1220 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1221 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
1222 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1223 50b0790e 2020-09-11 stsp return 1
1224 50b0790e 2020-09-11 stsp fi
1225 50b0790e 2020-09-11 stsp
1226 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
1227 50b0790e 2020-09-11 stsp remote "foobar" {
1228 50b0790e 2020-09-11 stsp protocol ssh
1229 50b0790e 2020-09-11 stsp server 127.0.0.1
1230 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1231 50b0790e 2020-09-11 stsp }
1232 50b0790e 2020-09-11 stsp
1233 50b0790e 2020-09-11 stsp remote "barbaz" {
1234 50b0790e 2020-09-11 stsp protocol ssh
1235 50b0790e 2020-09-11 stsp server 127.0.0.1
1236 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
1237 50b0790e 2020-09-11 stsp }
1238 50b0790e 2020-09-11 stsp EOF
1239 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
1240 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
1241 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q nonexistent \
1242 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
1243 fc414659 2022-04-16 thomas ret=$?
1244 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1245 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
1246 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
1247 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
1248 54eb00d5 2020-10-20 stsp return 1
1249 54eb00d5 2020-10-20 stsp fi
1250 54eb00d5 2020-10-20 stsp
1251 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l foobar \
1252 50b0790e 2020-09-11 stsp > $testroot/stdout)
1253 fc414659 2022-04-16 thomas ret=$?
1254 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1255 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1256 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1257 50b0790e 2020-09-11 stsp return 1
1258 50b0790e 2020-09-11 stsp fi
1259 bcf34b0e 2020-03-26 stsp
1260 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1261 50b0790e 2020-09-11 stsp
1262 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1263 fc414659 2022-04-16 thomas ret=$?
1264 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1265 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1266 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1267 50b0790e 2020-09-11 stsp return 1
1268 bcf34b0e 2020-03-26 stsp fi
1269 50b0790e 2020-09-11 stsp
1270 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1271 50b0790e 2020-09-11 stsp
1272 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1273 50b0790e 2020-09-11 stsp remote "barbaz" {
1274 50b0790e 2020-09-11 stsp protocol ssh
1275 50b0790e 2020-09-11 stsp server 127.0.0.1
1276 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1277 50b0790e 2020-09-11 stsp }
1278 50b0790e 2020-09-11 stsp EOF
1279 612392ee 2021-01-05 stsp (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1280 fc414659 2022-04-16 thomas ret=$?
1281 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1282 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1283 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1284 50b0790e 2020-09-11 stsp return 1
1285 50b0790e 2020-09-11 stsp fi
1286 50b0790e 2020-09-11 stsp
1287 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1288 50b0790e 2020-09-11 stsp
1289 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1290 fc414659 2022-04-16 thomas ret=$?
1291 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1292 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1294 99495ddb 2021-01-10 stsp return 1
1295 99495ddb 2021-01-10 stsp fi
1296 50b0790e 2020-09-11 stsp
1297 99495ddb 2021-01-10 stsp cat > $testroot/repo-clone/got.conf <<EOF
1298 99495ddb 2021-01-10 stsp remote "origin" {
1299 99495ddb 2021-01-10 stsp protocol ssh
1300 99495ddb 2021-01-10 stsp server 127.0.0.1
1301 99495ddb 2021-01-10 stsp repository "$testroot/repo"
1302 99495ddb 2021-01-10 stsp branch { "foo" }
1303 99495ddb 2021-01-10 stsp reference { "hoo/boo/zoo" }
1304 0e4002ca 2020-03-21 stsp }
1305 99495ddb 2021-01-10 stsp EOF
1306 99495ddb 2021-01-10 stsp (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1307 0e4002ca 2020-03-21 stsp
1308 99495ddb 2021-01-10 stsp local tag_id=`got ref -r $testroot/repo -l \
1309 99495ddb 2021-01-10 stsp | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1310 99495ddb 2021-01-10 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1311 99495ddb 2021-01-10 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1312 99495ddb 2021-01-10 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1313 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1314 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1315 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/foo: $commit_id" \
1316 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1317 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1318 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1319 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/master: $commit_id" \
1320 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1321 99495ddb 2021-01-10 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1322 99495ddb 2021-01-10 stsp
1323 99495ddb 2021-01-10 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1324 99495ddb 2021-01-10 stsp
1325 99495ddb 2021-01-10 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1326 fc414659 2022-04-16 thomas ret=$?
1327 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1328 99495ddb 2021-01-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1329 99495ddb 2021-01-10 stsp fi
1330 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1331 99495ddb 2021-01-10 stsp }
1332 99495ddb 2021-01-10 stsp
1333 161728eb 2021-07-24 stsp test_fetch_delete_remote_refs() {
1334 678d8c1f 2021-09-10 stsp local testroot=`test_init fetch_delete_remote_refs`
1335 161728eb 2021-07-24 stsp local testurl=ssh://127.0.0.1/$testroot
1336 161728eb 2021-07-24 stsp local commit_id=`git_show_head $testroot/repo`
1337 161728eb 2021-07-24 stsp
1338 161728eb 2021-07-24 stsp got clone -q $testurl/repo $testroot/repo-clone
1339 fc414659 2022-04-16 thomas ret=$?
1340 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1341 161728eb 2021-07-24 stsp echo "got clone command failed unexpectedly" >&2
1342 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1343 161728eb 2021-07-24 stsp return 1
1344 161728eb 2021-07-24 stsp fi
1345 161728eb 2021-07-24 stsp
1346 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1347 21850702 2022-06-13 thomas ret=$?
1348 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1349 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1350 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1351 161728eb 2021-07-24 stsp return 1
1352 161728eb 2021-07-24 stsp fi
1353 161728eb 2021-07-24 stsp
1354 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1355 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1356 161728eb 2021-07-24 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1357 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1358 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master: $commit_id" \
1359 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1360 161728eb 2021-07-24 stsp
1361 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1362 fc414659 2022-04-16 thomas ret=$?
1363 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1364 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1365 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1366 161728eb 2021-07-24 stsp return 1
1367 161728eb 2021-07-24 stsp fi
1368 161728eb 2021-07-24 stsp
1369 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1370 161728eb 2021-07-24 stsp 2> $testroot/stderr
1371 fc414659 2022-04-16 thomas ret=$?
1372 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1373 161728eb 2021-07-24 stsp echo "got fetch command succeeded unexpectedly" >&2
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 echo "got: -X option requires a remote name" > $testroot/stderr.expected
1379 161728eb 2021-07-24 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1380 fc414659 2022-04-16 thomas ret=$?
1381 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1382 161728eb 2021-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1383 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
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 got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1388 161728eb 2021-07-24 stsp 2> $testroot/stderr
1389 fc414659 2022-04-16 thomas ret=$?
1390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1391 161728eb 2021-07-24 stsp echo "got fetch command failed unexpectedly" >&2
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 echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1397 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1398 161728eb 2021-07-24 stsp echo "Deleted refs/remotes/origin/master: $commit_id" \
1399 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1400 161728eb 2021-07-24 stsp
1401 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1402 fc414659 2022-04-16 thomas ret=$?
1403 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1404 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1405 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1406 161728eb 2021-07-24 stsp return 1
1407 161728eb 2021-07-24 stsp fi
1408 161728eb 2021-07-24 stsp
1409 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1410 21850702 2022-06-13 thomas ret=$?
1411 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1412 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1413 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1414 161728eb 2021-07-24 stsp return 1
1415 161728eb 2021-07-24 stsp fi
1416 161728eb 2021-07-24 stsp
1417 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1418 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1419 161728eb 2021-07-24 stsp
1420 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1421 fc414659 2022-04-16 thomas ret=$?
1422 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1423 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1424 161728eb 2021-07-24 stsp fi
1425 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1426 161728eb 2021-07-24 stsp }
1427 161728eb 2021-07-24 stsp
1428 161728eb 2021-07-24 stsp
1429 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1430 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1431 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1432 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1433 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1434 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1435 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1436 1b796c3f 2021-09-11 stsp run_test test_fetch_delete_branch_mirror
1437 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1438 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1439 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1440 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1441 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1442 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo
1443 161728eb 2021-07-24 stsp run_test test_fetch_delete_remote_refs