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