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