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