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