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