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