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 bf1c78e5 2023-02-18 mark # foo is now the default HEAD branch in $testroot/repo and should be
192 bf1c78e5 2023-02-18 mark # fetched as the clone's remote HEAD symref target no longer matches
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 bf1c78e5 2023-02-18 mark echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
215 188f8dcf 2023-02-07 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
216 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
217 188f8dcf 2023-02-07 stsp >> $testroot/stdout.expected
218 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/foo: $commit_id3" \
219 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
220 188f8dcf 2023-02-07 stsp echo "refs/remotes/origin/master: $commit_id2" \
221 188f8dcf 2023-02-07 stsp >> $testroot/stdout.expected
222 188f8dcf 2023-02-07 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
223 188f8dcf 2023-02-07 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
224 188f8dcf 2023-02-07 stsp
225 188f8dcf 2023-02-07 stsp cmp -s $testroot/stdout $testroot/stdout.expected
226 188f8dcf 2023-02-07 stsp ret=$?
227 188f8dcf 2023-02-07 stsp if [ $ret -ne 0 ]; then
228 188f8dcf 2023-02-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 188f8dcf 2023-02-07 stsp test_done "$testroot" "$ret"
230 188f8dcf 2023-02-07 stsp return 1
231 188f8dcf 2023-02-07 stsp fi
232 188f8dcf 2023-02-07 stsp
233 188f8dcf 2023-02-07 stsp # fetch branch foo via command-line switch
234 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $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 188f8dcf 2023-02-07 stsp echo "refs/remotes/origin/master: $commit_id2" \
261 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
262 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
263 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
264 c8c71e6e 2020-03-21 stsp
265 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
266 49c543a6 2022-03-31 naddy ret=$?
267 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
268 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
269 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
270 c8c71e6e 2020-03-21 stsp return 1
271 c8c71e6e 2020-03-21 stsp fi
272 c8c71e6e 2020-03-21 stsp
273 ccbbf026 2023-02-06 stsp # got.conf tells us to fetch the 'master' branch by default
274 ccbbf026 2023-02-06 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout
275 49c543a6 2022-03-31 naddy ret=$?
276 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
277 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
278 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
279 c8c71e6e 2020-03-21 stsp return 1
280 c8c71e6e 2020-03-21 stsp fi
281 c8c71e6e 2020-03-21 stsp
282 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
283 c8c71e6e 2020-03-21 stsp
284 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
285 49c543a6 2022-03-31 naddy ret=$?
286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
287 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
288 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
289 c8c71e6e 2020-03-21 stsp return 1
290 c8c71e6e 2020-03-21 stsp fi
291 c8c71e6e 2020-03-21 stsp
292 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
293 c8c71e6e 2020-03-21 stsp
294 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
295 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
296 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
297 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
298 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
299 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
300 0c091d87 2023-02-02 stsp echo "refs/remotes/origin/master: $commit_id2" \
301 0c091d87 2023-02-02 stsp >> $testroot/stdout.expected
302 0c091d87 2023-02-02 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
303 0c091d87 2023-02-02 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
304 0c091d87 2023-02-02 stsp
305 0c091d87 2023-02-02 stsp cmp -s $testroot/stdout $testroot/stdout.expected
306 0c091d87 2023-02-02 stsp ret=$?
307 0c091d87 2023-02-02 stsp if [ $ret -ne 0 ]; then
308 0c091d87 2023-02-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 0c091d87 2023-02-02 stsp test_done "$testroot" "$ret"
310 0c091d87 2023-02-02 stsp return 1
311 0c091d87 2023-02-02 stsp fi
312 0c091d87 2023-02-02 stsp
313 0c091d87 2023-02-02 stsp echo "modified beta on foo" > $testroot/repo/beta
314 0c091d87 2023-02-02 stsp git_commit $testroot/repo -m "modified beta"
315 0c091d87 2023-02-02 stsp local commit_id4=`git_show_head $testroot/repo`
316 0c091d87 2023-02-02 stsp
317 ccbbf026 2023-02-06 stsp # set the default HEAD branch back to master
318 ccbbf026 2023-02-06 stsp (cd $testroot/repo && git checkout -q master)
319 ccbbf026 2023-02-06 stsp
320 0c091d87 2023-02-02 stsp got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
321 0c091d87 2023-02-02 stsp
322 0c091d87 2023-02-02 stsp # fetch new commits on branch 'foo', implicitly obtaining the
323 0c091d87 2023-02-02 stsp # branch name from a work tree
324 0c091d87 2023-02-02 stsp (cd $testroot/wt && got fetch -q > $testroot/stdout)
325 0c091d87 2023-02-02 stsp
326 0c091d87 2023-02-02 stsp echo -n > $testroot/stdout.expected
327 0c091d87 2023-02-02 stsp
328 0c091d87 2023-02-02 stsp cmp -s $testroot/stdout $testroot/stdout.expected
329 0c091d87 2023-02-02 stsp ret=$?
330 0c091d87 2023-02-02 stsp if [ $ret -ne 0 ]; then
331 0c091d87 2023-02-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 0c091d87 2023-02-02 stsp test_done "$testroot" "$ret"
333 0c091d87 2023-02-02 stsp return 1
334 0c091d87 2023-02-02 stsp fi
335 0c091d87 2023-02-02 stsp
336 0c091d87 2023-02-02 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
337 0c091d87 2023-02-02 stsp cut -d ':' -f 2 | tr -d ' ')`
338 0c091d87 2023-02-02 stsp
339 0c091d87 2023-02-02 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
340 0c091d87 2023-02-02 stsp
341 0c091d87 2023-02-02 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
342 0c091d87 2023-02-02 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
343 0c091d87 2023-02-02 stsp >> $testroot/stdout.expected
344 0c091d87 2023-02-02 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
345 0c091d87 2023-02-02 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
346 ccbbf026 2023-02-06 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
347 0c091d87 2023-02-02 stsp >> $testroot/stdout.expected
348 0c091d87 2023-02-02 stsp echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
349 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
350 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
351 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
352 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
353 c8c71e6e 2020-03-21 stsp
354 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
355 49c543a6 2022-03-31 naddy ret=$?
356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
357 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
358 188f8dcf 2023-02-07 stsp test_done "$testroot" "$ret"
359 188f8dcf 2023-02-07 stsp return 1
360 c8c71e6e 2020-03-21 stsp fi
361 188f8dcf 2023-02-07 stsp
362 188f8dcf 2023-02-07 stsp # remove default branch information from got.conf
363 188f8dcf 2023-02-07 stsp sed -i -e "/branch {/d" $testroot/repo-clone/got.conf
364 188f8dcf 2023-02-07 stsp
365 188f8dcf 2023-02-07 stsp # make another change on 'foo' and fetch it without got.conf
366 188f8dcf 2023-02-07 stsp (cd $testroot/repo && git checkout -q foo)
367 188f8dcf 2023-02-07 stsp echo "modified beta on foo agan" > $testroot/repo/beta
368 188f8dcf 2023-02-07 stsp git_commit $testroot/repo -m "modified beta"
369 188f8dcf 2023-02-07 stsp local commit_id5=`git_show_head $testroot/repo`
370 188f8dcf 2023-02-07 stsp (cd $testroot/repo && git checkout -q master)
371 188f8dcf 2023-02-07 stsp
372 188f8dcf 2023-02-07 stsp # fetch new commits on branch 'foo', implicitly obtaining the
373 188f8dcf 2023-02-07 stsp # branch name from a work tree
374 188f8dcf 2023-02-07 stsp (cd $testroot/wt && got fetch -q > $testroot/stdout)
375 188f8dcf 2023-02-07 stsp
376 188f8dcf 2023-02-07 stsp echo -n > $testroot/stdout.expected
377 188f8dcf 2023-02-07 stsp
378 188f8dcf 2023-02-07 stsp cmp -s $testroot/stdout $testroot/stdout.expected
379 188f8dcf 2023-02-07 stsp ret=$?
380 188f8dcf 2023-02-07 stsp if [ $ret -ne 0 ]; then
381 188f8dcf 2023-02-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
382 188f8dcf 2023-02-07 stsp test_done "$testroot" "$ret"
383 188f8dcf 2023-02-07 stsp return 1
384 188f8dcf 2023-02-07 stsp fi
385 188f8dcf 2023-02-07 stsp
386 188f8dcf 2023-02-07 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
387 188f8dcf 2023-02-07 stsp cut -d ':' -f 2 | tr -d ' ')`
388 188f8dcf 2023-02-07 stsp
389 188f8dcf 2023-02-07 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
390 188f8dcf 2023-02-07 stsp
391 188f8dcf 2023-02-07 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
392 188f8dcf 2023-02-07 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
393 188f8dcf 2023-02-07 stsp >> $testroot/stdout.expected
394 188f8dcf 2023-02-07 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
395 188f8dcf 2023-02-07 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
396 188f8dcf 2023-02-07 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
397 188f8dcf 2023-02-07 stsp >> $testroot/stdout.expected
398 188f8dcf 2023-02-07 stsp echo "refs/remotes/origin/foo: $commit_id5" >> $testroot/stdout.expected
399 188f8dcf 2023-02-07 stsp echo "refs/remotes/origin/master: $commit_id2" \
400 188f8dcf 2023-02-07 stsp >> $testroot/stdout.expected
401 188f8dcf 2023-02-07 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
402 188f8dcf 2023-02-07 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
403 188f8dcf 2023-02-07 stsp
404 188f8dcf 2023-02-07 stsp cmp -s $testroot/stdout $testroot/stdout.expected
405 188f8dcf 2023-02-07 stsp ret=$?
406 188f8dcf 2023-02-07 stsp if [ $ret -ne 0 ]; then
407 188f8dcf 2023-02-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 188f8dcf 2023-02-07 stsp fi
409 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
410 c8c71e6e 2020-03-21 stsp }
411 c8c71e6e 2020-03-21 stsp
412 f6cae3ed 2020-09-13 naddy test_fetch_all() {
413 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
414 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
415 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
416 c8c71e6e 2020-03-21 stsp
417 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
418 49c543a6 2022-03-31 naddy ret=$?
419 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
420 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
421 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
422 c8c71e6e 2020-03-21 stsp return 1
423 c8c71e6e 2020-03-21 stsp fi
424 c8c71e6e 2020-03-21 stsp
425 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
426 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
427 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
428 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
429 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
430 c8c71e6e 2020-03-21 stsp
431 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
432 c8c71e6e 2020-03-21 stsp
433 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
434 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
435 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
436 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
437 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
438 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
439 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
440 c8c71e6e 2020-03-21 stsp
441 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
442 49c543a6 2022-03-31 naddy ret=$?
443 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
444 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
445 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
446 c8c71e6e 2020-03-21 stsp return 1
447 c8c71e6e 2020-03-21 stsp fi
448 c8c71e6e 2020-03-21 stsp
449 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
450 49c543a6 2022-03-31 naddy ret=$?
451 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
452 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
453 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
454 c8c71e6e 2020-03-21 stsp return 1
455 c8c71e6e 2020-03-21 stsp fi
456 c8c71e6e 2020-03-21 stsp
457 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
458 c8c71e6e 2020-03-21 stsp
459 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
460 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
461 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
462 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
463 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
464 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
465 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
466 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
467 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
468 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
469 c8c71e6e 2020-03-21 stsp
470 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
471 49c543a6 2022-03-31 naddy ret=$?
472 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
473 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
474 c8c71e6e 2020-03-21 stsp fi
475 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
476 c8c71e6e 2020-03-21 stsp }
477 c8c71e6e 2020-03-21 stsp
478 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
479 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
480 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
481 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
482 c8c71e6e 2020-03-21 stsp
483 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
484 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
485 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
486 c8c71e6e 2020-03-21 stsp
487 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
488 49c543a6 2022-03-31 naddy ret=$?
489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
490 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
491 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
492 c8c71e6e 2020-03-21 stsp return 1
493 c8c71e6e 2020-03-21 stsp fi
494 c8c71e6e 2020-03-21 stsp
495 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
496 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
497 c8c71e6e 2020-03-21 stsp
498 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
499 c8c71e6e 2020-03-21 stsp
500 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
501 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
502 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
503 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
504 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
505 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
506 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
507 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
508 c8c71e6e 2020-03-21 stsp
509 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
510 49c543a6 2022-03-31 naddy ret=$?
511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
512 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
513 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
514 c8c71e6e 2020-03-21 stsp return 1
515 c8c71e6e 2020-03-21 stsp fi
516 c8c71e6e 2020-03-21 stsp
517 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
518 49c543a6 2022-03-31 naddy ret=$?
519 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
520 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
521 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
522 c8c71e6e 2020-03-21 stsp return 1
523 c8c71e6e 2020-03-21 stsp fi
524 c8c71e6e 2020-03-21 stsp
525 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
526 c8c71e6e 2020-03-21 stsp
527 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
529 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
530 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
531 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
532 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
533 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
534 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
535 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
536 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
537 c8c71e6e 2020-03-21 stsp
538 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
539 49c543a6 2022-03-31 naddy ret=$?
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
542 c8c71e6e 2020-03-21 stsp fi
543 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
544 c8c71e6e 2020-03-21 stsp }
545 c8c71e6e 2020-03-21 stsp
546 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
547 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
548 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
549 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
550 c8c71e6e 2020-03-21 stsp
551 c8c71e6e 2020-03-21 stsp
552 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
553 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
554 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
555 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
556 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
557 c8c71e6e 2020-03-21 stsp
558 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
559 49c543a6 2022-03-31 naddy ret=$?
560 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
561 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
562 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
563 c8c71e6e 2020-03-21 stsp return 1
564 c8c71e6e 2020-03-21 stsp fi
565 c8c71e6e 2020-03-21 stsp
566 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
567 c8c71e6e 2020-03-21 stsp
568 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
569 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
570 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
571 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
572 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
573 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
574 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
575 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
576 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
577 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
578 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
579 c8c71e6e 2020-03-21 stsp
580 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
581 49c543a6 2022-03-31 naddy ret=$?
582 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
583 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
584 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
585 c8c71e6e 2020-03-21 stsp return 1
586 c8c71e6e 2020-03-21 stsp fi
587 c8c71e6e 2020-03-21 stsp
588 978a28a1 2021-09-04 naddy got branch -r $testroot/repo -d foo >/dev/null
589 c8c71e6e 2020-03-21 stsp
590 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
591 49c543a6 2022-03-31 naddy ret=$?
592 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
593 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
594 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
595 c8c71e6e 2020-03-21 stsp return 1
596 c8c71e6e 2020-03-21 stsp fi
597 c8c71e6e 2020-03-21 stsp
598 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
599 c8c71e6e 2020-03-21 stsp
600 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
601 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
602 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
603 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
604 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
605 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
606 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
607 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
608 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
609 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
610 c8c71e6e 2020-03-21 stsp
611 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
612 49c543a6 2022-03-31 naddy ret=$?
613 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
614 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
615 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
616 c8c71e6e 2020-03-21 stsp return 1
617 c8c71e6e 2020-03-21 stsp fi
618 c8c71e6e 2020-03-21 stsp
619 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
620 49c543a6 2022-03-31 naddy ret=$?
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
623 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
624 c8c71e6e 2020-03-21 stsp return 1
625 c8c71e6e 2020-03-21 stsp fi
626 c8c71e6e 2020-03-21 stsp
627 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
628 c8c71e6e 2020-03-21 stsp
629 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
630 49c543a6 2022-03-31 naddy ret=$?
631 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
632 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
633 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
634 c8c71e6e 2020-03-21 stsp return 1
635 c8c71e6e 2020-03-21 stsp fi
636 c8c71e6e 2020-03-21 stsp
637 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
638 c8c71e6e 2020-03-21 stsp
639 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
640 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
641 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
642 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
643 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
644 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
645 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
646 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
647 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
648 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
649 c8c71e6e 2020-03-21 stsp
650 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
651 49c543a6 2022-03-31 naddy ret=$?
652 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
653 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
654 c8c71e6e 2020-03-21 stsp fi
655 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
656 c8c71e6e 2020-03-21 stsp
657 c8c71e6e 2020-03-21 stsp }
658 1b796c3f 2021-09-11 stsp
659 1b796c3f 2021-09-11 stsp test_fetch_delete_branch_mirror() {
660 1b796c3f 2021-09-11 stsp local testroot=`test_init fetch_delete_branch_mirror`
661 1b796c3f 2021-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
662 1b796c3f 2021-09-11 stsp local commit_id=`git_show_head $testroot/repo`
663 1b796c3f 2021-09-11 stsp
664 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
665 1b796c3f 2021-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
666 1b796c3f 2021-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
667 1b796c3f 2021-09-11 stsp local tag_id=`got ref -r $testroot/repo -l \
668 1b796c3f 2021-09-11 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
669 1b796c3f 2021-09-11 stsp
670 1b796c3f 2021-09-11 stsp got clone -a -m -q $testurl/repo $testroot/repo-clone
671 49c543a6 2022-03-31 naddy ret=$?
672 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
673 1b796c3f 2021-09-11 stsp echo "got clone command failed unexpectedly" >&2
674 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
675 1b796c3f 2021-09-11 stsp return 1
676 1b796c3f 2021-09-11 stsp fi
677 1b796c3f 2021-09-11 stsp
678 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
679 1b796c3f 2021-09-11 stsp
680 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
681 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
682 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
683 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
684 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
685 db6d8ad8 2020-03-21 stsp
686 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
687 49c543a6 2022-03-31 naddy ret=$?
688 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
689 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
690 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
691 1b796c3f 2021-09-11 stsp return 1
692 1b796c3f 2021-09-11 stsp fi
693 1b796c3f 2021-09-11 stsp
694 1b796c3f 2021-09-11 stsp got branch -r $testroot/repo -d foo >/dev/null
695 1b796c3f 2021-09-11 stsp
696 1b796c3f 2021-09-11 stsp got fetch -q -r $testroot/repo-clone
697 49c543a6 2022-03-31 naddy ret=$?
698 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
699 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
700 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
701 1b796c3f 2021-09-11 stsp return 1
702 1b796c3f 2021-09-11 stsp fi
703 1b796c3f 2021-09-11 stsp
704 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
705 1b796c3f 2021-09-11 stsp
706 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
707 1b796c3f 2021-09-11 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
708 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
709 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
710 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
711 1b796c3f 2021-09-11 stsp
712 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
713 49c543a6 2022-03-31 naddy ret=$?
714 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
715 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
716 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
717 1b796c3f 2021-09-11 stsp return 1
718 1b796c3f 2021-09-11 stsp fi
719 1b796c3f 2021-09-11 stsp
720 1b796c3f 2021-09-11 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
721 49c543a6 2022-03-31 naddy ret=$?
722 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
723 1b796c3f 2021-09-11 stsp echo "got fetch command failed unexpectedly" >&2
724 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
725 1b796c3f 2021-09-11 stsp return 1
726 1b796c3f 2021-09-11 stsp fi
727 1b796c3f 2021-09-11 stsp
728 1b796c3f 2021-09-11 stsp echo -n > $testroot/stdout.expected
729 1b796c3f 2021-09-11 stsp
730 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
731 49c543a6 2022-03-31 naddy ret=$?
732 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
733 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
734 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
735 1b796c3f 2021-09-11 stsp return 1
736 1b796c3f 2021-09-11 stsp fi
737 1b796c3f 2021-09-11 stsp
738 1b796c3f 2021-09-11 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
739 1b796c3f 2021-09-11 stsp
740 1b796c3f 2021-09-11 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
741 1b796c3f 2021-09-11 stsp # refs/heads/foo is now deleted
742 1b796c3f 2021-09-11 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
743 1b796c3f 2021-09-11 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
744 1b796c3f 2021-09-11 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
745 1b796c3f 2021-09-11 stsp
746 1b796c3f 2021-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
747 49c543a6 2022-03-31 naddy ret=$?
748 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
749 1b796c3f 2021-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
750 1b796c3f 2021-09-11 stsp fi
751 1b796c3f 2021-09-11 stsp test_done "$testroot" "$ret"
752 1b796c3f 2021-09-11 stsp
753 1b796c3f 2021-09-11 stsp }
754 1b796c3f 2021-09-11 stsp
755 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
756 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
757 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
758 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
759 db6d8ad8 2020-03-21 stsp
760 db6d8ad8 2020-03-21 stsp
761 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
762 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
763 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
764 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
765 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
766 db6d8ad8 2020-03-21 stsp
767 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
768 49c543a6 2022-03-31 naddy ret=$?
769 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
770 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
771 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
772 db6d8ad8 2020-03-21 stsp return 1
773 db6d8ad8 2020-03-21 stsp fi
774 db6d8ad8 2020-03-21 stsp
775 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
776 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
777 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
778 db6d8ad8 2020-03-21 stsp
779 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
780 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
781 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
782 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
783 db6d8ad8 2020-03-21 stsp
784 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
785 db6d8ad8 2020-03-21 stsp
786 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
787 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
788 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
789 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
790 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
791 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
792 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
793 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
794 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
795 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
796 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
797 c8c71e6e 2020-03-21 stsp
798 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
799 49c543a6 2022-03-31 naddy ret=$?
800 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
801 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
802 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
803 db6d8ad8 2020-03-21 stsp return 1
804 db6d8ad8 2020-03-21 stsp fi
805 db6d8ad8 2020-03-21 stsp
806 98f64f14 2021-01-05 stsp got fetch -a -q -r $testroot/repo-clone
807 49c543a6 2022-03-31 naddy ret=$?
808 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
809 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
810 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
811 db6d8ad8 2020-03-21 stsp return 1
812 db6d8ad8 2020-03-21 stsp fi
813 db6d8ad8 2020-03-21 stsp
814 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
815 db6d8ad8 2020-03-21 stsp
816 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
817 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
818 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
819 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
820 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
821 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
822 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
823 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
824 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
825 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
826 db6d8ad8 2020-03-21 stsp
827 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
828 49c543a6 2022-03-31 naddy ret=$?
829 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
830 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
832 db6d8ad8 2020-03-21 stsp return 1
833 db6d8ad8 2020-03-21 stsp fi
834 db6d8ad8 2020-03-21 stsp
835 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
836 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
837 49c543a6 2022-03-31 naddy ret=$?
838 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
839 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
840 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
841 db6d8ad8 2020-03-21 stsp return 1
842 db6d8ad8 2020-03-21 stsp fi
843 db6d8ad8 2020-03-21 stsp
844 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
845 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
846 db6d8ad8 2020-03-21 stsp
847 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
848 49c543a6 2022-03-31 naddy ret=$?
849 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
850 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
852 db6d8ad8 2020-03-21 stsp return 1
853 db6d8ad8 2020-03-21 stsp fi
854 db6d8ad8 2020-03-21 stsp
855 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
856 db6d8ad8 2020-03-21 stsp
857 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
858 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
859 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
860 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
861 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
862 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
863 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
864 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
865 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
866 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
867 db6d8ad8 2020-03-21 stsp
868 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
869 49c543a6 2022-03-31 naddy ret=$?
870 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
871 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
872 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
873 db6d8ad8 2020-03-21 stsp return 1
874 db6d8ad8 2020-03-21 stsp fi
875 db6d8ad8 2020-03-21 stsp
876 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
877 49c543a6 2022-03-31 naddy ret=$?
878 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
879 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
880 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
881 db6d8ad8 2020-03-21 stsp return 1
882 db6d8ad8 2020-03-21 stsp fi
883 db6d8ad8 2020-03-21 stsp
884 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
885 db6d8ad8 2020-03-21 stsp
886 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
887 49c543a6 2022-03-31 naddy ret=$?
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
890 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
891 db6d8ad8 2020-03-21 stsp return 1
892 db6d8ad8 2020-03-21 stsp fi
893 db6d8ad8 2020-03-21 stsp
894 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
895 db6d8ad8 2020-03-21 stsp
896 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
897 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
898 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
899 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
900 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
901 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
902 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
903 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
904 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
905 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
906 db6d8ad8 2020-03-21 stsp
907 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
908 49c543a6 2022-03-31 naddy ret=$?
909 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
910 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
911 db6d8ad8 2020-03-21 stsp fi
912 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
913 db6d8ad8 2020-03-21 stsp }
914 0e4002ca 2020-03-21 stsp
915 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
916 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
917 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
918 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
919 db6d8ad8 2020-03-21 stsp
920 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
921 49c543a6 2022-03-31 naddy ret=$?
922 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
923 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
924 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
925 0e4002ca 2020-03-21 stsp return 1
926 0e4002ca 2020-03-21 stsp fi
927 0e4002ca 2020-03-21 stsp
928 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
929 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
930 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
931 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
932 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
933 0e4002ca 2020-03-21 stsp
934 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
935 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
936 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
937 0e4002ca 2020-03-21 stsp
938 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
939 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
940 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
941 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
942 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
943 0e4002ca 2020-03-21 stsp
944 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
945 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
948 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
949 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
950 0e4002ca 2020-03-21 stsp return 1
951 0e4002ca 2020-03-21 stsp fi
952 0e4002ca 2020-03-21 stsp
953 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
954 0e4002ca 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 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
960 0e4002ca 2020-03-21 stsp return 1
961 0e4002ca 2020-03-21 stsp fi
962 0e4002ca 2020-03-21 stsp
963 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
964 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
965 0e4002ca 2020-03-21 stsp
966 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
967 49c543a6 2022-03-31 naddy ret=$?
968 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
969 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
970 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
971 0e4002ca 2020-03-21 stsp return 1
972 0e4002ca 2020-03-21 stsp fi
973 0e4002ca 2020-03-21 stsp
974 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
975 49c543a6 2022-03-31 naddy ret=$?
976 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
977 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
978 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
979 0e4002ca 2020-03-21 stsp return 1
980 0e4002ca 2020-03-21 stsp fi
981 0e4002ca 2020-03-21 stsp
982 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
983 0e4002ca 2020-03-21 stsp
984 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
985 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
986 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
987 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
988 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
989 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
990 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
991 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
992 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
993 e8a967e0 2020-03-21 stsp
994 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
995 49c543a6 2022-03-31 naddy ret=$?
996 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
997 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
998 e8a967e0 2020-03-21 stsp fi
999 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1000 e8a967e0 2020-03-21 stsp
1001 e8a967e0 2020-03-21 stsp }
1002 e8a967e0 2020-03-21 stsp
1003 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
1004 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
1005 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
1006 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
1007 e8a967e0 2020-03-21 stsp
1008 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
1009 49c543a6 2022-03-31 naddy ret=$?
1010 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1011 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
1012 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1013 e8a967e0 2020-03-21 stsp return 1
1014 e8a967e0 2020-03-21 stsp fi
1015 e8a967e0 2020-03-21 stsp
1016 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1017 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
1018 e8a967e0 2020-03-21 stsp
1019 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1020 e8a967e0 2020-03-21 stsp
1021 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1022 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1023 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
1024 e8a967e0 2020-03-21 stsp
1025 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1026 49c543a6 2022-03-31 naddy ret=$?
1027 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1028 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1029 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1030 e8a967e0 2020-03-21 stsp return 1
1031 e8a967e0 2020-03-21 stsp fi
1032 0e4002ca 2020-03-21 stsp
1033 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
1034 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
1035 49c543a6 2022-03-31 naddy ret=$?
1036 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1037 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
1038 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1039 e8a967e0 2020-03-21 stsp return 1
1040 e8a967e0 2020-03-21 stsp fi
1041 e8a967e0 2020-03-21 stsp
1042 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
1043 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
1044 e8a967e0 2020-03-21 stsp
1045 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1046 49c543a6 2022-03-31 naddy ret=$?
1047 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1048 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1049 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
1050 e8a967e0 2020-03-21 stsp return 1
1051 0e4002ca 2020-03-21 stsp fi
1052 e8a967e0 2020-03-21 stsp
1053 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1054 e8a967e0 2020-03-21 stsp
1055 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1056 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1057 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
1058 f1bcca34 2020-03-25 stsp
1059 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1060 49c543a6 2022-03-31 naddy ret=$?
1061 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1062 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1063 f1bcca34 2020-03-25 stsp fi
1064 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1065 f1bcca34 2020-03-25 stsp
1066 f1bcca34 2020-03-25 stsp }
1067 f1bcca34 2020-03-25 stsp
1068 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
1069 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
1070 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
1071 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
1072 f1bcca34 2020-03-25 stsp
1073 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
1077 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1078 f1bcca34 2020-03-25 stsp return 1
1079 f1bcca34 2020-03-25 stsp fi
1080 f1bcca34 2020-03-25 stsp
1081 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1082 f1bcca34 2020-03-25 stsp
1083 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1084 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1085 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1086 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1087 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1088 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1089 f1bcca34 2020-03-25 stsp
1090 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1091 49c543a6 2022-03-31 naddy ret=$?
1092 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1093 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1094 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1095 f1bcca34 2020-03-25 stsp return 1
1096 f1bcca34 2020-03-25 stsp fi
1097 e8a967e0 2020-03-21 stsp
1098 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
1099 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
1100 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
1101 f1bcca34 2020-03-25 stsp
1102 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
1103 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1104 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1105 f1bcca34 2020-03-25 stsp
1106 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1107 49c543a6 2022-03-31 naddy ret=$?
1108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1109 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1110 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
1111 f1bcca34 2020-03-25 stsp return 1
1112 e8a967e0 2020-03-21 stsp fi
1113 f1bcca34 2020-03-25 stsp
1114 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
1115 f1bcca34 2020-03-25 stsp
1116 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1117 f1bcca34 2020-03-25 stsp
1118 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1119 bf1c78e5 2023-02-18 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1120 4bff57b4 2023-02-14 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1121 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1122 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1123 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/foo: $commit_id" \
1124 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
1125 15d3c221 2021-01-05 stsp echo "refs/remotes/origin/master: $commit_id" \
1126 15d3c221 2021-01-05 stsp >> $testroot/stdout.expected
1127 15d3c221 2021-01-05 stsp
1128 15d3c221 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1129 49c543a6 2022-03-31 naddy ret=$?
1130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1131 15d3c221 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1132 15d3c221 2021-01-05 stsp test_done "$testroot" "$ret"
1133 15d3c221 2021-01-05 stsp return 1
1134 15d3c221 2021-01-05 stsp fi
1135 15d3c221 2021-01-05 stsp
1136 15d3c221 2021-01-05 stsp got fetch -q -r $testroot/repo-clone -a
1137 15d3c221 2021-01-05 stsp
1138 15d3c221 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1139 15d3c221 2021-01-05 stsp
1140 15d3c221 2021-01-05 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1141 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1142 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1143 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
1144 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1145 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
1146 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1147 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
1148 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
1149 f1bcca34 2020-03-25 stsp
1150 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1151 49c543a6 2022-03-31 naddy ret=$?
1152 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1153 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1154 f1bcca34 2020-03-25 stsp fi
1155 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
1156 bcf34b0e 2020-03-26 stsp }
1157 bcf34b0e 2020-03-26 stsp
1158 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
1159 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
1160 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
1161 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
1162 bcf34b0e 2020-03-26 stsp
1163 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1164 49c543a6 2022-03-31 naddy ret=$?
1165 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1166 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
1167 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1168 bcf34b0e 2020-03-26 stsp return 1
1169 bcf34b0e 2020-03-26 stsp fi
1170 bcf34b0e 2020-03-26 stsp
1171 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1172 0e4002ca 2020-03-21 stsp
1173 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1174 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1175 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1176 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1177 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1178 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1179 bcf34b0e 2020-03-26 stsp
1180 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1181 49c543a6 2022-03-31 naddy ret=$?
1182 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1183 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1184 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1185 bcf34b0e 2020-03-26 stsp return 1
1186 bcf34b0e 2020-03-26 stsp fi
1187 bcf34b0e 2020-03-26 stsp
1188 993f033b 2021-07-16 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD > /dev/null
1189 bcf34b0e 2020-03-26 stsp
1190 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
1191 49c543a6 2022-03-31 naddy ret=$?
1192 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1193 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
1194 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1195 bcf34b0e 2020-03-26 stsp return 1
1196 bcf34b0e 2020-03-26 stsp fi
1197 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1198 bcf34b0e 2020-03-26 stsp
1199 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1200 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1201 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
1202 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1203 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1204 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1205 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
1206 50b0790e 2020-09-11 stsp
1207 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1208 49c543a6 2022-03-31 naddy ret=$?
1209 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1210 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1211 50b0790e 2020-09-11 stsp fi
1212 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1213 50b0790e 2020-09-11 stsp }
1214 50b0790e 2020-09-11 stsp
1215 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
1216 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
1217 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
1218 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
1219 50b0790e 2020-09-11 stsp
1220 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
1221 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
1222 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
1223 50b0790e 2020-09-11 stsp
1224 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
1225 49c543a6 2022-03-31 naddy ret=$?
1226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1227 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
1228 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1229 50b0790e 2020-09-11 stsp return 1
1230 50b0790e 2020-09-11 stsp fi
1231 50b0790e 2020-09-11 stsp
1232 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
1233 50b0790e 2020-09-11 stsp remote "foobar" {
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/repo"
1237 50b0790e 2020-09-11 stsp }
1238 50b0790e 2020-09-11 stsp
1239 50b0790e 2020-09-11 stsp remote "barbaz" {
1240 50b0790e 2020-09-11 stsp protocol ssh
1241 50b0790e 2020-09-11 stsp server 127.0.0.1
1242 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
1243 50b0790e 2020-09-11 stsp }
1244 50b0790e 2020-09-11 stsp EOF
1245 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
1246 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
1247 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q nonexistent \
1248 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
1249 49c543a6 2022-03-31 naddy ret=$?
1250 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1251 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
1252 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
1253 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
1254 54eb00d5 2020-10-20 stsp return 1
1255 54eb00d5 2020-10-20 stsp fi
1256 54eb00d5 2020-10-20 stsp
1257 612392ee 2021-01-05 stsp (cd $testroot/repo-clone && got fetch -q -l foobar \
1258 50b0790e 2020-09-11 stsp > $testroot/stdout)
1259 49c543a6 2022-03-31 naddy ret=$?
1260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1261 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1262 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1263 50b0790e 2020-09-11 stsp return 1
1264 50b0790e 2020-09-11 stsp fi
1265 bcf34b0e 2020-03-26 stsp
1266 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1267 50b0790e 2020-09-11 stsp
1268 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1269 49c543a6 2022-03-31 naddy ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1273 50b0790e 2020-09-11 stsp return 1
1274 bcf34b0e 2020-03-26 stsp fi
1275 50b0790e 2020-09-11 stsp
1276 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1277 50b0790e 2020-09-11 stsp
1278 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1279 50b0790e 2020-09-11 stsp remote "barbaz" {
1280 50b0790e 2020-09-11 stsp protocol ssh
1281 50b0790e 2020-09-11 stsp server 127.0.0.1
1282 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1283 50b0790e 2020-09-11 stsp }
1284 50b0790e 2020-09-11 stsp EOF
1285 612392ee 2021-01-05 stsp (cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
1286 49c543a6 2022-03-31 naddy ret=$?
1287 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1288 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1289 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1290 50b0790e 2020-09-11 stsp return 1
1291 50b0790e 2020-09-11 stsp fi
1292 50b0790e 2020-09-11 stsp
1293 612392ee 2021-01-05 stsp got ref -l -r $testroot/repo > $testroot/stdout.expected
1294 50b0790e 2020-09-11 stsp
1295 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1296 49c543a6 2022-03-31 naddy ret=$?
1297 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1298 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1299 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1300 99495ddb 2021-01-10 stsp return 1
1301 99495ddb 2021-01-10 stsp fi
1302 50b0790e 2020-09-11 stsp
1303 99495ddb 2021-01-10 stsp cat > $testroot/repo-clone/got.conf <<EOF
1304 99495ddb 2021-01-10 stsp remote "origin" {
1305 99495ddb 2021-01-10 stsp protocol ssh
1306 99495ddb 2021-01-10 stsp server 127.0.0.1
1307 99495ddb 2021-01-10 stsp repository "$testroot/repo"
1308 99495ddb 2021-01-10 stsp branch { "foo" }
1309 99495ddb 2021-01-10 stsp reference { "hoo/boo/zoo" }
1310 0e4002ca 2020-03-21 stsp }
1311 99495ddb 2021-01-10 stsp EOF
1312 99495ddb 2021-01-10 stsp (cd $testroot/repo-clone && got fetch -q > $testroot/stdout)
1313 0e4002ca 2020-03-21 stsp
1314 99495ddb 2021-01-10 stsp local tag_id=`got ref -r $testroot/repo -l \
1315 99495ddb 2021-01-10 stsp | grep "^refs/tags/1.0" | tr -d ' ' | cut -d: -f2`
1316 99495ddb 2021-01-10 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1317 99495ddb 2021-01-10 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1318 99495ddb 2021-01-10 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1319 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1320 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1321 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/foo: $commit_id" \
1322 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1323 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
1324 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1325 99495ddb 2021-01-10 stsp echo "refs/remotes/origin/master: $commit_id" \
1326 99495ddb 2021-01-10 stsp >> $testroot/stdout.expected
1327 99495ddb 2021-01-10 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1328 99495ddb 2021-01-10 stsp
1329 99495ddb 2021-01-10 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1330 99495ddb 2021-01-10 stsp
1331 99495ddb 2021-01-10 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1332 49c543a6 2022-03-31 naddy ret=$?
1333 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1334 99495ddb 2021-01-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1335 99495ddb 2021-01-10 stsp fi
1336 99495ddb 2021-01-10 stsp test_done "$testroot" "$ret"
1337 99495ddb 2021-01-10 stsp }
1338 99495ddb 2021-01-10 stsp
1339 161728eb 2021-07-24 stsp test_fetch_delete_remote_refs() {
1340 678d8c1f 2021-09-10 stsp local testroot=`test_init fetch_delete_remote_refs`
1341 161728eb 2021-07-24 stsp local testurl=ssh://127.0.0.1/$testroot
1342 161728eb 2021-07-24 stsp local commit_id=`git_show_head $testroot/repo`
1343 161728eb 2021-07-24 stsp
1344 161728eb 2021-07-24 stsp got clone -q $testurl/repo $testroot/repo-clone
1345 49c543a6 2022-03-31 naddy ret=$?
1346 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1347 161728eb 2021-07-24 stsp echo "got clone command failed unexpectedly" >&2
1348 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1349 161728eb 2021-07-24 stsp return 1
1350 161728eb 2021-07-24 stsp fi
1351 161728eb 2021-07-24 stsp
1352 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1353 84246752 2022-06-03 op ret=$?
1354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1355 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1356 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1357 161728eb 2021-07-24 stsp return 1
1358 161728eb 2021-07-24 stsp fi
1359 161728eb 2021-07-24 stsp
1360 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1361 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1362 161728eb 2021-07-24 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1363 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1364 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master: $commit_id" \
1365 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1366 161728eb 2021-07-24 stsp
1367 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1368 49c543a6 2022-03-31 naddy ret=$?
1369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1370 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1371 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1372 161728eb 2021-07-24 stsp return 1
1373 161728eb 2021-07-24 stsp fi
1374 161728eb 2021-07-24 stsp
1375 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X > $testroot/stdout \
1376 161728eb 2021-07-24 stsp 2> $testroot/stderr
1377 49c543a6 2022-03-31 naddy ret=$?
1378 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1379 161728eb 2021-07-24 stsp echo "got fetch command succeeded unexpectedly" >&2
1380 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1381 161728eb 2021-07-24 stsp return 1
1382 161728eb 2021-07-24 stsp fi
1383 161728eb 2021-07-24 stsp
1384 161728eb 2021-07-24 stsp echo "got: -X option requires a remote name" > $testroot/stderr.expected
1385 161728eb 2021-07-24 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1386 49c543a6 2022-03-31 naddy ret=$?
1387 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1388 161728eb 2021-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1389 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1390 161728eb 2021-07-24 stsp return 1
1391 161728eb 2021-07-24 stsp fi
1392 161728eb 2021-07-24 stsp
1393 161728eb 2021-07-24 stsp got fetch -q -r $testroot/repo-clone -X origin > $testroot/stdout \
1394 161728eb 2021-07-24 stsp 2> $testroot/stderr
1395 49c543a6 2022-03-31 naddy ret=$?
1396 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1397 161728eb 2021-07-24 stsp echo "got fetch command failed unexpectedly" >&2
1398 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1399 161728eb 2021-07-24 stsp return 1
1400 161728eb 2021-07-24 stsp fi
1401 161728eb 2021-07-24 stsp
1402 161728eb 2021-07-24 stsp echo -n "Deleted refs/remotes/origin/HEAD: " > $testroot/stdout.expected
1403 161728eb 2021-07-24 stsp echo "refs/remotes/origin/master" >> $testroot/stdout.expected
1404 161728eb 2021-07-24 stsp echo "Deleted refs/remotes/origin/master: $commit_id" \
1405 161728eb 2021-07-24 stsp >> $testroot/stdout.expected
1406 161728eb 2021-07-24 stsp
1407 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1408 49c543a6 2022-03-31 naddy ret=$?
1409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1410 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1411 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1412 161728eb 2021-07-24 stsp return 1
1413 161728eb 2021-07-24 stsp fi
1414 161728eb 2021-07-24 stsp
1415 161728eb 2021-07-24 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1416 84246752 2022-06-03 op ret=$?
1417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1418 161728eb 2021-07-24 stsp echo "got ref command failed unexpectedly" >&2
1419 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1420 161728eb 2021-07-24 stsp return 1
1421 161728eb 2021-07-24 stsp fi
1422 161728eb 2021-07-24 stsp
1423 161728eb 2021-07-24 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1424 161728eb 2021-07-24 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1425 161728eb 2021-07-24 stsp
1426 161728eb 2021-07-24 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1427 49c543a6 2022-03-31 naddy ret=$?
1428 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1429 161728eb 2021-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1430 161728eb 2021-07-24 stsp fi
1431 161728eb 2021-07-24 stsp test_done "$testroot" "$ret"
1432 161728eb 2021-07-24 stsp }
1433 1cb79834 2023-02-13 mark
1434 1cb79834 2023-02-13 mark test_fetch_honor_wt_conf_bflag() {
1435 ac51614e 2023-02-15 mark local testroot=`test_init fetch_honor_wt_conf_bflag`
1436 1cb79834 2023-02-13 mark local testurl=ssh://127.0.0.1/$testroot
1437 1cb79834 2023-02-13 mark
1438 1cb79834 2023-02-13 mark # server will have 'boo', 'hoo', and 'master'
1439 1cb79834 2023-02-13 mark echo "modified alpha on master" > $testroot/repo/alpha
1440 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified alpha"
1441 1cb79834 2023-02-13 mark local commit_id=`git_show_head $testroot/repo`
1442 1cb79834 2023-02-13 mark
1443 1cb79834 2023-02-13 mark got branch -r $testroot/repo -c $commit_id boo
1444 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q boo)
1445 1cb79834 2023-02-13 mark echo "modified beta on boo" > $testroot/repo/beta
1446 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified beta"
1447 1cb79834 2023-02-13 mark local commit_id2=`git_show_head $testroot/repo`
1448 1cb79834 2023-02-13 mark
1449 1cb79834 2023-02-13 mark got branch -r $testroot/repo -c $commit_id2 hoo
1450 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q hoo)
1451 1cb79834 2023-02-13 mark echo "modified delta on hoo" > $testroot/repo/gamma/delta
1452 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified delta"
1453 1cb79834 2023-02-13 mark local commit_id3=`git_show_head $testroot/repo`
1454 1cb79834 2023-02-13 mark
1455 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q master)
1456 1cb79834 2023-02-13 mark got clone -q $testurl/repo $testroot/repo-clone
1457 1cb79834 2023-02-13 mark ret=$?
1458 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1459 1cb79834 2023-02-13 mark echo "got clone command failed unexpectedly" >&2
1460 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1461 1cb79834 2023-02-13 mark return 1
1462 1cb79834 2023-02-13 mark fi
1463 1cb79834 2023-02-13 mark
1464 1cb79834 2023-02-13 mark # only clone will have foo and bar
1465 1cb79834 2023-02-13 mark got branch -r $testroot/repo-clone -c $commit_id foo
1466 1cb79834 2023-02-13 mark got branch -r $testroot/repo-clone -c $commit_id bar
1467 1cb79834 2023-02-13 mark
1468 1cb79834 2023-02-13 mark got fetch -q -r $testroot/repo-clone > $testroot/stdout
1469 1cb79834 2023-02-13 mark ret=$?
1470 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1471 1cb79834 2023-02-13 mark echo "got fetch command failed unexpectedly" >&2
1472 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1473 1cb79834 2023-02-13 mark return 1
1474 1cb79834 2023-02-13 mark fi
1475 1cb79834 2023-02-13 mark
1476 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1477 1cb79834 2023-02-13 mark
1478 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1479 1cb79834 2023-02-13 mark ret=$?
1480 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1481 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1482 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1483 1cb79834 2023-02-13 mark return 1
1484 1cb79834 2023-02-13 mark fi
1485 1cb79834 2023-02-13 mark
1486 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1487 1cb79834 2023-02-13 mark
1488 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1489 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1490 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1491 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1492 1cb79834 2023-02-13 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1493 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1494 1cb79834 2023-02-13 mark echo "refs/remotes/origin/master: $commit_id" \
1495 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1496 1cb79834 2023-02-13 mark
1497 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1498 1cb79834 2023-02-13 mark ret=$?
1499 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1500 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1501 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1502 1cb79834 2023-02-13 mark return 1
1503 1cb79834 2023-02-13 mark fi
1504 1cb79834 2023-02-13 mark
1505 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q boo)
1506 bf1c78e5 2023-02-18 mark # clone has remote/origin/HEAD symref with "master" as its target
1507 bf1c78e5 2023-02-18 mark # but the repo has changed HEAD to "boo", so we should fetch "boo"
1508 bf1c78e5 2023-02-18 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1509 bf1c78e5 2023-02-18 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1510 bf1c78e5 2023-02-18 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1511 bf1c78e5 2023-02-18 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1512 bf1c78e5 2023-02-18 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1513 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1514 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
1515 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/boo: $commit_id2" \
1516 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
1517 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/master: $commit_id" \
1518 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
1519 bf1c78e5 2023-02-18 mark
1520 bf1c78e5 2023-02-18 mark got fetch -q -r $testroot/repo-clone > $testroot/stdout
1521 1cb79834 2023-02-13 mark ret=$?
1522 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1523 1cb79834 2023-02-13 mark echo "got fetch command failed unexpectedly" >&2
1524 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1525 1cb79834 2023-02-13 mark return 1
1526 1cb79834 2023-02-13 mark fi
1527 1cb79834 2023-02-13 mark
1528 bf1c78e5 2023-02-18 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1529 1cb79834 2023-02-13 mark
1530 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1531 1cb79834 2023-02-13 mark ret=$?
1532 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1533 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1534 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1535 1cb79834 2023-02-13 mark return 1
1536 1cb79834 2023-02-13 mark fi
1537 1cb79834 2023-02-13 mark
1538 bf1c78e5 2023-02-18 mark # from repo: fetch -b hoo
1539 1cb79834 2023-02-13 mark got fetch -q -r $testroot/repo-clone -b hoo > $testroot/stdout
1540 1cb79834 2023-02-13 mark ret=$?
1541 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1542 1cb79834 2023-02-13 mark echo "got fetch command failed unexpectedly" >&2
1543 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1544 1cb79834 2023-02-13 mark return 1
1545 1cb79834 2023-02-13 mark fi
1546 161728eb 2021-07-24 stsp
1547 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1548 161728eb 2021-07-24 stsp
1549 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1550 1cb79834 2023-02-13 mark ret=$?
1551 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1552 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1553 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1554 1cb79834 2023-02-13 mark return 1
1555 1cb79834 2023-02-13 mark fi
1556 1cb79834 2023-02-13 mark
1557 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1558 1cb79834 2023-02-13 mark
1559 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1560 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1561 bf1c78e5 2023-02-18 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1562 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1563 1cb79834 2023-02-13 mark echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1564 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1565 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1566 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1567 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/boo: $commit_id2" \
1568 bf1c78e5 2023-02-18 mark >> $testroot/stdout.expected
1569 1cb79834 2023-02-13 mark echo "refs/remotes/origin/hoo: $commit_id3" \
1570 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1571 4bff57b4 2023-02-14 stsp echo "refs/remotes/origin/master: $commit_id" \
1572 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1573 1cb79834 2023-02-13 mark
1574 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1575 1cb79834 2023-02-13 mark ret=$?
1576 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1577 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1578 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1579 1cb79834 2023-02-13 mark return 1
1580 1cb79834 2023-02-13 mark fi
1581 1cb79834 2023-02-13 mark
1582 1cb79834 2023-02-13 mark # from repo: fetch -b foo which doesn't exist on the server but
1583 1cb79834 2023-02-13 mark # do not fallback to repo HEAD "boo" because we used the -b flag
1584 1cb79834 2023-02-13 mark got fetch -r $testroot/repo-clone -b foo > $testroot/stdout \
1585 1cb79834 2023-02-13 mark 2> $testroot/stderr
1586 1cb79834 2023-02-13 mark
1587 1cb79834 2023-02-13 mark echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1588 1cb79834 2023-02-13 mark > $testroot/stdout.expected
1589 f72ce919 2023-02-13 mark echo "got-fetch-pack: branch \"foo\" not found on server" \
1590 1cb79834 2023-02-13 mark > $testroot/stderr.expected
1591 1cb79834 2023-02-13 mark echo "got: could not find any branches to fetch" \
1592 1cb79834 2023-02-13 mark >> $testroot/stderr.expected
1593 1cb79834 2023-02-13 mark
1594 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1595 1cb79834 2023-02-13 mark ret=$?
1596 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1597 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1598 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1599 1cb79834 2023-02-13 mark return 1
1600 1cb79834 2023-02-13 mark fi
1601 1cb79834 2023-02-13 mark
1602 1cb79834 2023-02-13 mark cmp -s $testroot/stderr $testroot/stderr.expected
1603 1cb79834 2023-02-13 mark ret=$?
1604 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1605 1cb79834 2023-02-13 mark diff -u $testroot/stderr.expected $testroot/stderr
1606 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1607 1cb79834 2023-02-13 mark return 1
1608 1cb79834 2023-02-13 mark fi
1609 1cb79834 2023-02-13 mark
1610 4bff57b4 2023-02-14 stsp # from repo: fetch got.conf branch which doesn't exist, so fallback
1611 4bff57b4 2023-02-14 stsp # to repo HEAD "boo"
1612 1cb79834 2023-02-13 mark # change default branch in got.conf from "master" to "foo"
1613 1cb79834 2023-02-13 mark sed -i "s/master/foo/" $testroot/repo-clone/got.conf
1614 1cb79834 2023-02-13 mark
1615 1cb79834 2023-02-13 mark got fetch -q -r $testroot/repo-clone > $testroot/stdout
1616 1cb79834 2023-02-13 mark ret=$?
1617 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1618 1cb79834 2023-02-13 mark echo "got fetch command failed unexpectedly" >&2
1619 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1620 1cb79834 2023-02-13 mark return 1
1621 1cb79834 2023-02-13 mark fi
1622 1cb79834 2023-02-13 mark
1623 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1624 1cb79834 2023-02-13 mark
1625 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1626 1cb79834 2023-02-13 mark ret=$?
1627 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1628 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1629 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1630 1cb79834 2023-02-13 mark return 1
1631 1cb79834 2023-02-13 mark fi
1632 1cb79834 2023-02-13 mark
1633 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1634 1cb79834 2023-02-13 mark
1635 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1636 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1637 1cb79834 2023-02-13 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1638 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1639 1cb79834 2023-02-13 mark echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1640 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1641 1cb79834 2023-02-13 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1642 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1643 4bff57b4 2023-02-14 stsp echo "refs/remotes/origin/boo: $commit_id2" \
1644 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1645 1cb79834 2023-02-13 mark echo "refs/remotes/origin/hoo: $commit_id3" \
1646 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1647 4bff57b4 2023-02-14 stsp echo "refs/remotes/origin/master: $commit_id" \
1648 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1649 1cb79834 2023-02-13 mark
1650 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1651 1cb79834 2023-02-13 mark ret=$?
1652 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1653 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1654 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1655 1cb79834 2023-02-13 mark return 1
1656 1cb79834 2023-02-13 mark fi
1657 1cb79834 2023-02-13 mark
1658 4bff57b4 2023-02-14 stsp # from wt: fetch got.conf "foo", which doesn't exist on the server,
1659 4bff57b4 2023-02-14 stsp # and implicit wt branch "boo", not repo HEAD "master"
1660 1cb79834 2023-02-13 mark echo "modified delta on boo" > $testroot/repo/gamma/delta
1661 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified delta"
1662 1cb79834 2023-02-13 mark local commit_id4=`git_show_head $testroot/repo`
1663 1cb79834 2023-02-13 mark
1664 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q master)
1665 1cb79834 2023-02-13 mark
1666 1cb79834 2023-02-13 mark got checkout -b boo $testroot/repo-clone $testroot/wt > /dev/null
1667 1cb79834 2023-02-13 mark (cd $testroot/wt && got fetch -q > $testroot/stdout)
1668 1cb79834 2023-02-13 mark
1669 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1670 1cb79834 2023-02-13 mark
1671 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1672 1cb79834 2023-02-13 mark ret=$?
1673 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1674 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1675 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1676 1cb79834 2023-02-13 mark return 1
1677 1cb79834 2023-02-13 mark fi
1678 1cb79834 2023-02-13 mark
1679 1cb79834 2023-02-13 mark local wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1680 1cb79834 2023-02-13 mark cut -d ':' -f 2 | tr -d ' ')`
1681 1cb79834 2023-02-13 mark
1682 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1683 1cb79834 2023-02-13 mark
1684 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1685 1cb79834 2023-02-13 mark echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1686 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1687 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1688 1cb79834 2023-02-13 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1689 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1690 1cb79834 2023-02-13 mark echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1691 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1692 1cb79834 2023-02-13 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1693 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1694 1cb79834 2023-02-13 mark echo "refs/remotes/origin/boo: $commit_id4" \
1695 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1696 1cb79834 2023-02-13 mark echo "refs/remotes/origin/hoo: $commit_id3" \
1697 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1698 4bff57b4 2023-02-14 stsp echo "refs/remotes/origin/master: $commit_id" \
1699 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1700 1cb79834 2023-02-13 mark
1701 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1702 1cb79834 2023-02-13 mark ret=$?
1703 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1704 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1705 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1706 1cb79834 2023-02-13 mark return 1
1707 1cb79834 2023-02-13 mark fi
1708 1cb79834 2023-02-13 mark
1709 bf1c78e5 2023-02-18 mark # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD
1710 bf1c78e5 2023-02-18 mark # "hoo" as it no longer matches our remote HEAD symref target "master"
1711 1cb79834 2023-02-13 mark sed -i "s/foo/master/" $testroot/repo-clone/got.conf
1712 1cb79834 2023-02-13 mark echo "modified delta on master" > $testroot/repo/gamma/delta
1713 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified delta on master"
1714 1cb79834 2023-02-13 mark local commit_id5=`git_show_head $testroot/repo`
1715 1cb79834 2023-02-13 mark
1716 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q boo)
1717 1cb79834 2023-02-13 mark echo "modified alpha on boo" > $testroot/repo/alpha
1718 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified alpha on boo"
1719 1cb79834 2023-02-13 mark local commit_id6=`git_show_head $testroot/repo`
1720 1cb79834 2023-02-13 mark
1721 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q hoo)
1722 1cb79834 2023-02-13 mark echo "modified beta on hoo" > $testroot/repo/beta
1723 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified beta on hoo"
1724 1cb79834 2023-02-13 mark local commit_id7=`git_show_head $testroot/repo`
1725 1cb79834 2023-02-13 mark
1726 1cb79834 2023-02-13 mark (cd $testroot/wt && got fetch -q > $testroot/stdout)
1727 1cb79834 2023-02-13 mark
1728 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1729 1cb79834 2023-02-13 mark
1730 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1731 1cb79834 2023-02-13 mark ret=$?
1732 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1733 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1734 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1735 1cb79834 2023-02-13 mark return 1
1736 1cb79834 2023-02-13 mark fi
1737 1cb79834 2023-02-13 mark
1738 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1739 1cb79834 2023-02-13 mark
1740 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1741 1cb79834 2023-02-13 mark echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1742 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1743 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1744 1cb79834 2023-02-13 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1745 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1746 1cb79834 2023-02-13 mark echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1747 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1748 1cb79834 2023-02-13 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/hoo" \
1749 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1750 1cb79834 2023-02-13 mark echo "refs/remotes/origin/boo: $commit_id6" \
1751 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1752 bf1c78e5 2023-02-18 mark echo "refs/remotes/origin/hoo: $commit_id7" \
1753 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1754 1cb79834 2023-02-13 mark echo "refs/remotes/origin/master: $commit_id5" \
1755 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1756 1cb79834 2023-02-13 mark
1757 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1758 1cb79834 2023-02-13 mark ret=$?
1759 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1760 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1761 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1762 1cb79834 2023-02-13 mark return 1
1763 1cb79834 2023-02-13 mark fi
1764 1cb79834 2023-02-13 mark
1765 1cb79834 2023-02-13 mark # from wt: fetch -b hoo not got.conf "master" or wt "boo" or
1766 1cb79834 2023-02-13 mark # repo HEAD "boo"
1767 1cb79834 2023-02-13 mark (cd $testroot/repo && git checkout -q boo)
1768 1cb79834 2023-02-13 mark echo "modified alpha again on boo" > $testroot/repo/alpha
1769 1cb79834 2023-02-13 mark git_commit $testroot/repo -m "modified alpha again on boo"
1770 1cb79834 2023-02-13 mark local commit_id8=`git_show_head $testroot/repo`
1771 1cb79834 2023-02-13 mark
1772 1cb79834 2023-02-13 mark (cd $testroot/wt && got fetch -q -b hoo > $testroot/stdout)
1773 1cb79834 2023-02-13 mark
1774 1cb79834 2023-02-13 mark echo -n > $testroot/stdout.expected
1775 1cb79834 2023-02-13 mark
1776 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1777 1cb79834 2023-02-13 mark ret=$?
1778 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1779 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1780 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1781 1cb79834 2023-02-13 mark return 1
1782 1cb79834 2023-02-13 mark fi
1783 1cb79834 2023-02-13 mark
1784 1cb79834 2023-02-13 mark got ref -l -r $testroot/repo-clone > $testroot/stdout
1785 1cb79834 2023-02-13 mark
1786 1cb79834 2023-02-13 mark echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1787 1cb79834 2023-02-13 mark echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1788 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1789 1cb79834 2023-02-13 mark echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
1790 1cb79834 2023-02-13 mark echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected
1791 1cb79834 2023-02-13 mark echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1792 1cb79834 2023-02-13 mark echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected
1793 1cb79834 2023-02-13 mark echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1794 1cb79834 2023-02-13 mark echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \
1795 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1796 1cb79834 2023-02-13 mark echo "refs/remotes/origin/boo: $commit_id6" \
1797 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1798 4bff57b4 2023-02-14 stsp echo "refs/remotes/origin/hoo: $commit_id7" \
1799 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1800 1cb79834 2023-02-13 mark echo "refs/remotes/origin/master: $commit_id5" \
1801 1cb79834 2023-02-13 mark >> $testroot/stdout.expected
1802 1cb79834 2023-02-13 mark
1803 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1804 1cb79834 2023-02-13 mark ret=$?
1805 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1806 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1807 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1808 1cb79834 2023-02-13 mark return 1
1809 1cb79834 2023-02-13 mark fi
1810 1cb79834 2023-02-13 mark
1811 1cb79834 2023-02-13 mark # from wt: fetch -b bar that doesn't exist on the server but
1812 1cb79834 2023-02-13 mark # do not fetch got.conf "master" or wt "boo" or repo HEAD "boo"
1813 1cb79834 2023-02-13 mark (cd $testroot/wt && got fetch -b bar > $testroot/stdout \
1814 1cb79834 2023-02-13 mark 2> $testroot/stderr)
1815 1cb79834 2023-02-13 mark
1816 1cb79834 2023-02-13 mark echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \
1817 1cb79834 2023-02-13 mark > $testroot/stdout.expected
1818 f72ce919 2023-02-13 mark echo "got-fetch-pack: branch \"bar\" not found on server" \
1819 1cb79834 2023-02-13 mark > $testroot/stderr.expected
1820 1cb79834 2023-02-13 mark echo "got: could not find any branches to fetch" \
1821 1cb79834 2023-02-13 mark >> $testroot/stderr.expected
1822 1cb79834 2023-02-13 mark
1823 1cb79834 2023-02-13 mark cmp -s $testroot/stderr $testroot/stderr.expected
1824 1cb79834 2023-02-13 mark ret=$?
1825 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1826 1cb79834 2023-02-13 mark diff -u $testroot/stderr.expected $testroot/stderr
1827 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1828 1cb79834 2023-02-13 mark return 1
1829 1cb79834 2023-02-13 mark fi
1830 1cb79834 2023-02-13 mark
1831 1cb79834 2023-02-13 mark cmp -s $testroot/stdout $testroot/stdout.expected
1832 1cb79834 2023-02-13 mark ret=$?
1833 1cb79834 2023-02-13 mark if [ $ret -ne 0 ]; then
1834 1cb79834 2023-02-13 mark diff -u $testroot/stdout.expected $testroot/stdout
1835 1cb79834 2023-02-13 mark fi
1836 1cb79834 2023-02-13 mark test_done "$testroot" "$ret"
1837 1cb79834 2023-02-13 mark }
1838 1a0d06a3 2023-02-20 stsp
1839 1a0d06a3 2023-02-20 stsp test_fetch_from_out_of_date_remote() {
1840 1a0d06a3 2023-02-20 stsp local testroot=`test_init fetch_from_out_of_date_remote`
1841 1a0d06a3 2023-02-20 stsp local testurl=ssh://127.0.0.1/$testroot
1842 1a0d06a3 2023-02-20 stsp local commit_id=`git_show_head $testroot/repo`
1843 1a0d06a3 2023-02-20 stsp
1844 1a0d06a3 2023-02-20 stsp got clone -q $testurl/repo $testroot/repo-clone
1845 1a0d06a3 2023-02-20 stsp ret=$?
1846 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1847 1a0d06a3 2023-02-20 stsp echo "got clone command failed unexpectedly" >&2
1848 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1849 1a0d06a3 2023-02-20 stsp return 1
1850 1a0d06a3 2023-02-20 stsp fi
1851 1cb79834 2023-02-13 mark
1852 1a0d06a3 2023-02-20 stsp echo "modified alpha" > $testroot/repo/alpha
1853 1a0d06a3 2023-02-20 stsp git_commit $testroot/repo -m "modified alpha"
1854 1a0d06a3 2023-02-20 stsp local commit_id2=`git_show_head $testroot/repo`
1855 1a0d06a3 2023-02-20 stsp
1856 1a0d06a3 2023-02-20 stsp got clone -q $testurl/repo $testroot/repo-clone2 \
1857 1a0d06a3 2023-02-20 stsp > $testroot/stdout 2> $testroot/stderr
1858 1a0d06a3 2023-02-20 stsp ret=$?
1859 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1860 1a0d06a3 2023-02-20 stsp echo "got clone command failed unexpectedly" >&2
1861 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1862 1a0d06a3 2023-02-20 stsp return 1
1863 1a0d06a3 2023-02-20 stsp fi
1864 1a0d06a3 2023-02-20 stsp
1865 1a0d06a3 2023-02-20 stsp got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1866 1a0d06a3 2023-02-20 stsp ret=$?
1867 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1868 1a0d06a3 2023-02-20 stsp echo "got ref command failed unexpectedly" >&2
1869 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1870 1a0d06a3 2023-02-20 stsp return 1
1871 1a0d06a3 2023-02-20 stsp fi
1872 1a0d06a3 2023-02-20 stsp
1873 1a0d06a3 2023-02-20 stsp cat > $testroot/stdout.expected <<EOF
1874 1a0d06a3 2023-02-20 stsp HEAD: refs/heads/master
1875 1a0d06a3 2023-02-20 stsp refs/heads/master: $commit_id2
1876 1a0d06a3 2023-02-20 stsp refs/remotes/origin/HEAD: refs/remotes/origin/master
1877 1a0d06a3 2023-02-20 stsp refs/remotes/origin/master: $commit_id2
1878 1a0d06a3 2023-02-20 stsp EOF
1879 1a0d06a3 2023-02-20 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1880 1a0d06a3 2023-02-20 stsp ret=$?
1881 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1882 1a0d06a3 2023-02-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
1883 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1884 1a0d06a3 2023-02-20 stsp return 1
1885 1a0d06a3 2023-02-20 stsp fi
1886 1a0d06a3 2023-02-20 stsp
1887 1a0d06a3 2023-02-20 stsp cat >> $testroot/repo-clone2/got.conf <<EOF
1888 1a0d06a3 2023-02-20 stsp remote "other" {
1889 1a0d06a3 2023-02-20 stsp server "127.0.0.1"
1890 1a0d06a3 2023-02-20 stsp protocol ssh
1891 1a0d06a3 2023-02-20 stsp repository "$testroot/repo-clone"
1892 1a0d06a3 2023-02-20 stsp branch { "master" }
1893 1a0d06a3 2023-02-20 stsp }
1894 1a0d06a3 2023-02-20 stsp EOF
1895 1a0d06a3 2023-02-20 stsp got fetch -q -r $testroot/repo-clone2 other \
1896 1a0d06a3 2023-02-20 stsp > $testroot/stdout 2> $testroot/stderr
1897 1a0d06a3 2023-02-20 stsp ret=$?
1898 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1899 1a0d06a3 2023-02-20 stsp echo "got fetch command failed unexpectedly" >&2
1900 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1901 1a0d06a3 2023-02-20 stsp return 1
1902 1a0d06a3 2023-02-20 stsp fi
1903 1a0d06a3 2023-02-20 stsp
1904 1a0d06a3 2023-02-20 stsp got ref -l -r $testroot/repo-clone2 > $testroot/stdout
1905 1a0d06a3 2023-02-20 stsp ret=$?
1906 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1907 1a0d06a3 2023-02-20 stsp echo "got ref command failed unexpectedly" >&2
1908 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1909 1a0d06a3 2023-02-20 stsp return 1
1910 1a0d06a3 2023-02-20 stsp fi
1911 1a0d06a3 2023-02-20 stsp
1912 1a0d06a3 2023-02-20 stsp cat > $testroot/stdout.expected <<EOF
1913 1a0d06a3 2023-02-20 stsp HEAD: refs/heads/master
1914 1a0d06a3 2023-02-20 stsp refs/heads/master: $commit_id2
1915 1a0d06a3 2023-02-20 stsp refs/remotes/origin/HEAD: refs/remotes/origin/master
1916 1a0d06a3 2023-02-20 stsp refs/remotes/origin/master: $commit_id2
1917 1a0d06a3 2023-02-20 stsp refs/remotes/other/HEAD: refs/remotes/other/master
1918 1a0d06a3 2023-02-20 stsp refs/remotes/other/master: $commit_id
1919 1a0d06a3 2023-02-20 stsp EOF
1920 1a0d06a3 2023-02-20 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1921 1a0d06a3 2023-02-20 stsp ret=$?
1922 1a0d06a3 2023-02-20 stsp if [ $ret -ne 0 ]; then
1923 1a0d06a3 2023-02-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
1924 1a0d06a3 2023-02-20 stsp fi
1925 1a0d06a3 2023-02-20 stsp test_done "$testroot" "$ret"
1926 1a0d06a3 2023-02-20 stsp
1927 1a0d06a3 2023-02-20 stsp }
1928 1a0d06a3 2023-02-20 stsp
1929 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1930 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1931 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1932 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1933 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1934 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1935 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1936 1b796c3f 2021-09-11 stsp run_test test_fetch_delete_branch_mirror
1937 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1938 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1939 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1940 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1941 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1942 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo
1943 161728eb 2021-07-24 stsp run_test test_fetch_delete_remote_refs
1944 1cb79834 2023-02-13 mark run_test test_fetch_honor_wt_conf_bflag
1945 1a0d06a3 2023-02-20 stsp run_test test_fetch_from_out_of_date_remote