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