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 c8c71e6e 2020-03-21 stsp function 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 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
110 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
111 c8c71e6e 2020-03-21 stsp
112 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
113 c8c71e6e 2020-03-21 stsp ret="$?"
114 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
115 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
116 c8c71e6e 2020-03-21 stsp fi
117 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
118 c8c71e6e 2020-03-21 stsp }
119 c8c71e6e 2020-03-21 stsp
120 c8c71e6e 2020-03-21 stsp function test_fetch_list {
121 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_list`
122 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
123 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
124 c8c71e6e 2020-03-21 stsp
125 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
126 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
127 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
128 c8c71e6e 2020-03-21 stsp
129 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
130 c8c71e6e 2020-03-21 stsp ret="$?"
131 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
132 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
133 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
134 c8c71e6e 2020-03-21 stsp return 1
135 c8c71e6e 2020-03-21 stsp fi
136 c8c71e6e 2020-03-21 stsp
137 c8c71e6e 2020-03-21 stsp (cd $testroot/repo-clone && got fetch -l \
138 c8c71e6e 2020-03-21 stsp > $testroot/stdout 2>$testroot/stderr)
139 c8c71e6e 2020-03-21 stsp ret="$?"
140 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
141 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
142 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
143 c8c71e6e 2020-03-21 stsp return 1
144 c8c71e6e 2020-03-21 stsp fi
145 c8c71e6e 2020-03-21 stsp
146 c8c71e6e 2020-03-21 stsp echo "Connected to \"origin\" 127.0.0.1" > $testroot/stdout.expected
147 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
148 c8c71e6e 2020-03-21 stsp
149 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
150 c8c71e6e 2020-03-21 stsp ret="$?"
151 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
152 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 c8c71e6e 2020-03-21 stsp fi
154 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
155 c8c71e6e 2020-03-21 stsp }
156 c8c71e6e 2020-03-21 stsp
157 c8c71e6e 2020-03-21 stsp function test_fetch_branch {
158 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_branch`
159 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
160 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
161 c8c71e6e 2020-03-21 stsp
162 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
163 c8c71e6e 2020-03-21 stsp ret="$?"
164 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
165 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
166 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
167 c8c71e6e 2020-03-21 stsp return 1
168 c8c71e6e 2020-03-21 stsp fi
169 c8c71e6e 2020-03-21 stsp
170 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
171 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
172 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
173 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
174 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
175 c8c71e6e 2020-03-21 stsp
176 c8c71e6e 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
177 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
178 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
179 c8c71e6e 2020-03-21 stsp
180 c8c71e6e 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
181 c8c71e6e 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
182 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
183 c8c71e6e 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
184 c8c71e6e 2020-03-21 stsp
185 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
186 c8c71e6e 2020-03-21 stsp ret="$?"
187 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
188 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
189 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
190 c8c71e6e 2020-03-21 stsp return 1
191 c8c71e6e 2020-03-21 stsp fi
192 c8c71e6e 2020-03-21 stsp
193 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
194 c8c71e6e 2020-03-21 stsp
195 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
196 c8c71e6e 2020-03-21 stsp ret="$?"
197 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
198 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
200 c8c71e6e 2020-03-21 stsp return 1
201 c8c71e6e 2020-03-21 stsp fi
202 c8c71e6e 2020-03-21 stsp
203 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
204 c8c71e6e 2020-03-21 stsp
205 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
206 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
207 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
208 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
209 c8c71e6e 2020-03-21 stsp # refs/remotes/origin/master is umodified because it wasn't fetched
210 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
211 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
212 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
213 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
214 c8c71e6e 2020-03-21 stsp
215 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
216 c8c71e6e 2020-03-21 stsp ret="$?"
217 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
218 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
219 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
220 c8c71e6e 2020-03-21 stsp return 1
221 c8c71e6e 2020-03-21 stsp fi
222 c8c71e6e 2020-03-21 stsp
223 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
224 c8c71e6e 2020-03-21 stsp ret="$?"
225 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
226 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
227 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
228 c8c71e6e 2020-03-21 stsp return 1
229 c8c71e6e 2020-03-21 stsp fi
230 c8c71e6e 2020-03-21 stsp
231 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
232 c8c71e6e 2020-03-21 stsp
233 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
234 c8c71e6e 2020-03-21 stsp ret="$?"
235 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
236 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
238 c8c71e6e 2020-03-21 stsp return 1
239 c8c71e6e 2020-03-21 stsp fi
240 c8c71e6e 2020-03-21 stsp
241 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
242 c8c71e6e 2020-03-21 stsp
243 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
244 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
245 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
246 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
247 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
248 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
249 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
250 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
251 c8c71e6e 2020-03-21 stsp
252 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp ret="$?"
254 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
255 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
256 c8c71e6e 2020-03-21 stsp fi
257 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
258 c8c71e6e 2020-03-21 stsp }
259 c8c71e6e 2020-03-21 stsp
260 c8c71e6e 2020-03-21 stsp function test_fetch_all {
261 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
262 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
263 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
264 c8c71e6e 2020-03-21 stsp
265 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
266 c8c71e6e 2020-03-21 stsp ret="$?"
267 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
268 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
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 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
274 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
275 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
276 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
277 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
278 c8c71e6e 2020-03-21 stsp
279 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
280 c8c71e6e 2020-03-21 stsp
281 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
282 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
283 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
284 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
285 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
286 c8c71e6e 2020-03-21 stsp
287 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
288 c8c71e6e 2020-03-21 stsp ret="$?"
289 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
290 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
292 c8c71e6e 2020-03-21 stsp return 1
293 c8c71e6e 2020-03-21 stsp fi
294 c8c71e6e 2020-03-21 stsp
295 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
296 c8c71e6e 2020-03-21 stsp ret="$?"
297 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
298 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
299 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
300 c8c71e6e 2020-03-21 stsp return 1
301 c8c71e6e 2020-03-21 stsp fi
302 c8c71e6e 2020-03-21 stsp
303 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
304 c8c71e6e 2020-03-21 stsp
305 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
306 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
307 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
308 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
309 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
310 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
311 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
312 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
313 c8c71e6e 2020-03-21 stsp
314 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
315 c8c71e6e 2020-03-21 stsp ret="$?"
316 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
317 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
318 c8c71e6e 2020-03-21 stsp fi
319 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
320 c8c71e6e 2020-03-21 stsp }
321 c8c71e6e 2020-03-21 stsp
322 c8c71e6e 2020-03-21 stsp function test_fetch_empty_packfile {
323 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
324 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
325 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
326 c8c71e6e 2020-03-21 stsp
327 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
328 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
329 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
330 c8c71e6e 2020-03-21 stsp
331 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
332 c8c71e6e 2020-03-21 stsp ret="$?"
333 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
334 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
335 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
336 c8c71e6e 2020-03-21 stsp return 1
337 c8c71e6e 2020-03-21 stsp fi
338 c8c71e6e 2020-03-21 stsp
339 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
340 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
341 c8c71e6e 2020-03-21 stsp
342 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
343 c8c71e6e 2020-03-21 stsp
344 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
345 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
346 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
347 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
348 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
349 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
350 c8c71e6e 2020-03-21 stsp
351 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
352 c8c71e6e 2020-03-21 stsp ret="$?"
353 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
354 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
355 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
356 c8c71e6e 2020-03-21 stsp return 1
357 c8c71e6e 2020-03-21 stsp fi
358 c8c71e6e 2020-03-21 stsp
359 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
360 c8c71e6e 2020-03-21 stsp ret="$?"
361 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
362 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
363 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
364 c8c71e6e 2020-03-21 stsp return 1
365 c8c71e6e 2020-03-21 stsp fi
366 c8c71e6e 2020-03-21 stsp
367 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
368 c8c71e6e 2020-03-21 stsp
369 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
370 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
371 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
372 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
373 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
374 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
375 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
376 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
377 c8c71e6e 2020-03-21 stsp
378 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
379 c8c71e6e 2020-03-21 stsp ret="$?"
380 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
381 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
382 c8c71e6e 2020-03-21 stsp fi
383 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
384 c8c71e6e 2020-03-21 stsp }
385 c8c71e6e 2020-03-21 stsp
386 c8c71e6e 2020-03-21 stsp function test_fetch_delete_branch {
387 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
388 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
389 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
390 c8c71e6e 2020-03-21 stsp
391 c8c71e6e 2020-03-21 stsp
392 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
393 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
394 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
395 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
396 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
397 c8c71e6e 2020-03-21 stsp
398 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
399 c8c71e6e 2020-03-21 stsp ret="$?"
400 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
401 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
402 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
403 c8c71e6e 2020-03-21 stsp return 1
404 c8c71e6e 2020-03-21 stsp fi
405 c8c71e6e 2020-03-21 stsp
406 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
407 c8c71e6e 2020-03-21 stsp
408 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
409 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
410 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
411 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
412 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
413 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
414 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
415 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
416 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
417 c8c71e6e 2020-03-21 stsp
418 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
419 c8c71e6e 2020-03-21 stsp ret="$?"
420 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
421 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
422 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
423 c8c71e6e 2020-03-21 stsp return 1
424 c8c71e6e 2020-03-21 stsp fi
425 c8c71e6e 2020-03-21 stsp
426 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -d foo
427 c8c71e6e 2020-03-21 stsp
428 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
429 c8c71e6e 2020-03-21 stsp ret="$?"
430 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
431 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
432 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
433 c8c71e6e 2020-03-21 stsp return 1
434 c8c71e6e 2020-03-21 stsp fi
435 c8c71e6e 2020-03-21 stsp
436 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
437 c8c71e6e 2020-03-21 stsp
438 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
439 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
440 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
441 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
442 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
443 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
444 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
445 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
446 c8c71e6e 2020-03-21 stsp
447 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
448 c8c71e6e 2020-03-21 stsp ret="$?"
449 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
450 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
451 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
452 c8c71e6e 2020-03-21 stsp return 1
453 c8c71e6e 2020-03-21 stsp fi
454 c8c71e6e 2020-03-21 stsp
455 c8c71e6e 2020-03-21 stsp got fetch -d -q -r $testroot/repo-clone > $testroot/stdout
456 c8c71e6e 2020-03-21 stsp ret="$?"
457 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
458 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
459 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
460 c8c71e6e 2020-03-21 stsp return 1
461 c8c71e6e 2020-03-21 stsp fi
462 c8c71e6e 2020-03-21 stsp
463 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
464 c8c71e6e 2020-03-21 stsp
465 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
466 c8c71e6e 2020-03-21 stsp ret="$?"
467 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
468 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
469 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
470 c8c71e6e 2020-03-21 stsp return 1
471 c8c71e6e 2020-03-21 stsp fi
472 c8c71e6e 2020-03-21 stsp
473 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
474 c8c71e6e 2020-03-21 stsp
475 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
476 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
477 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
478 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
479 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
480 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
481 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
482 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
483 c8c71e6e 2020-03-21 stsp
484 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
485 c8c71e6e 2020-03-21 stsp ret="$?"
486 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
487 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
488 c8c71e6e 2020-03-21 stsp fi
489 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
490 c8c71e6e 2020-03-21 stsp
491 c8c71e6e 2020-03-21 stsp }
492 db6d8ad8 2020-03-21 stsp
493 db6d8ad8 2020-03-21 stsp function test_fetch_update_tag {
494 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
495 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
496 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
497 db6d8ad8 2020-03-21 stsp
498 db6d8ad8 2020-03-21 stsp
499 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
500 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
501 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
502 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
503 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
504 db6d8ad8 2020-03-21 stsp
505 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
506 db6d8ad8 2020-03-21 stsp ret="$?"
507 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
508 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
509 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
510 db6d8ad8 2020-03-21 stsp return 1
511 db6d8ad8 2020-03-21 stsp fi
512 db6d8ad8 2020-03-21 stsp
513 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
514 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
515 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
516 db6d8ad8 2020-03-21 stsp
517 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
518 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
519 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
520 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
521 db6d8ad8 2020-03-21 stsp
522 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
523 db6d8ad8 2020-03-21 stsp
524 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
525 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
526 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
527 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
528 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
529 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
530 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
531 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
532 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
533 c8c71e6e 2020-03-21 stsp
534 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
535 db6d8ad8 2020-03-21 stsp ret="$?"
536 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
537 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
538 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
539 db6d8ad8 2020-03-21 stsp return 1
540 db6d8ad8 2020-03-21 stsp fi
541 db6d8ad8 2020-03-21 stsp
542 db6d8ad8 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
543 db6d8ad8 2020-03-21 stsp ret="$?"
544 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
545 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
546 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
547 db6d8ad8 2020-03-21 stsp return 1
548 db6d8ad8 2020-03-21 stsp fi
549 db6d8ad8 2020-03-21 stsp
550 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
551 db6d8ad8 2020-03-21 stsp
552 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
553 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
554 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
555 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
556 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
557 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
558 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
559 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
560 db6d8ad8 2020-03-21 stsp
561 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
562 db6d8ad8 2020-03-21 stsp ret="$?"
563 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
564 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
565 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
566 db6d8ad8 2020-03-21 stsp return 1
567 db6d8ad8 2020-03-21 stsp fi
568 db6d8ad8 2020-03-21 stsp
569 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
570 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
571 db6d8ad8 2020-03-21 stsp ret="$?"
572 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
573 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
574 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
575 db6d8ad8 2020-03-21 stsp return 1
576 db6d8ad8 2020-03-21 stsp fi
577 db6d8ad8 2020-03-21 stsp
578 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
579 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
580 db6d8ad8 2020-03-21 stsp
581 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
582 db6d8ad8 2020-03-21 stsp ret="$?"
583 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
584 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
585 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
586 db6d8ad8 2020-03-21 stsp return 1
587 db6d8ad8 2020-03-21 stsp fi
588 db6d8ad8 2020-03-21 stsp
589 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
590 db6d8ad8 2020-03-21 stsp
591 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
592 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
593 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
594 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
595 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
596 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
597 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
598 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
599 db6d8ad8 2020-03-21 stsp
600 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
601 db6d8ad8 2020-03-21 stsp ret="$?"
602 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
603 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
604 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
605 db6d8ad8 2020-03-21 stsp return 1
606 db6d8ad8 2020-03-21 stsp fi
607 db6d8ad8 2020-03-21 stsp
608 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
609 db6d8ad8 2020-03-21 stsp ret="$?"
610 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
611 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
612 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
613 db6d8ad8 2020-03-21 stsp return 1
614 db6d8ad8 2020-03-21 stsp fi
615 db6d8ad8 2020-03-21 stsp
616 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
617 db6d8ad8 2020-03-21 stsp
618 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
619 db6d8ad8 2020-03-21 stsp ret="$?"
620 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
621 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
622 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
623 db6d8ad8 2020-03-21 stsp return 1
624 db6d8ad8 2020-03-21 stsp fi
625 db6d8ad8 2020-03-21 stsp
626 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
627 db6d8ad8 2020-03-21 stsp
628 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
629 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
630 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
631 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
632 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
633 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
634 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
635 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
636 db6d8ad8 2020-03-21 stsp
637 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
638 db6d8ad8 2020-03-21 stsp ret="$?"
639 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
640 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
641 db6d8ad8 2020-03-21 stsp fi
642 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
643 db6d8ad8 2020-03-21 stsp }
644 0e4002ca 2020-03-21 stsp
645 0e4002ca 2020-03-21 stsp function test_fetch_reference {
646 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
647 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
648 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
649 db6d8ad8 2020-03-21 stsp
650 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
651 0e4002ca 2020-03-21 stsp ret="$?"
652 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
653 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
654 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
655 0e4002ca 2020-03-21 stsp return 1
656 0e4002ca 2020-03-21 stsp fi
657 0e4002ca 2020-03-21 stsp
658 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
659 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
660 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
661 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
662 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
663 0e4002ca 2020-03-21 stsp
664 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
665 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
666 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
667 0e4002ca 2020-03-21 stsp
668 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
669 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
670 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
671 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
672 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
673 0e4002ca 2020-03-21 stsp
674 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
675 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
676 0e4002ca 2020-03-21 stsp ret="$?"
677 0e4002ca 2020-03-21 stsp if [ "$ret" == "0" ]; then
678 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
679 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
680 0e4002ca 2020-03-21 stsp return 1
681 0e4002ca 2020-03-21 stsp fi
682 0e4002ca 2020-03-21 stsp
683 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
684 0e4002ca 2020-03-21 stsp
685 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
686 0e4002ca 2020-03-21 stsp ret="$?"
687 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
688 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
689 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
690 0e4002ca 2020-03-21 stsp return 1
691 0e4002ca 2020-03-21 stsp fi
692 0e4002ca 2020-03-21 stsp
693 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
694 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
695 0e4002ca 2020-03-21 stsp
696 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
697 0e4002ca 2020-03-21 stsp ret="$?"
698 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
699 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
700 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
701 0e4002ca 2020-03-21 stsp return 1
702 0e4002ca 2020-03-21 stsp fi
703 0e4002ca 2020-03-21 stsp
704 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
705 0e4002ca 2020-03-21 stsp ret="$?"
706 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
707 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
708 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
709 0e4002ca 2020-03-21 stsp return 1
710 0e4002ca 2020-03-21 stsp fi
711 0e4002ca 2020-03-21 stsp
712 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
713 0e4002ca 2020-03-21 stsp
714 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
715 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
716 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
717 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
718 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
719 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
720 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
721 e8a967e0 2020-03-21 stsp
722 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
723 e8a967e0 2020-03-21 stsp ret="$?"
724 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
725 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
726 e8a967e0 2020-03-21 stsp fi
727 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
728 e8a967e0 2020-03-21 stsp
729 e8a967e0 2020-03-21 stsp }
730 e8a967e0 2020-03-21 stsp
731 e8a967e0 2020-03-21 stsp function test_fetch_replace_symref {
732 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
733 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
734 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
735 e8a967e0 2020-03-21 stsp
736 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
737 e8a967e0 2020-03-21 stsp ret="$?"
738 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
739 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
740 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
741 e8a967e0 2020-03-21 stsp return 1
742 e8a967e0 2020-03-21 stsp fi
743 e8a967e0 2020-03-21 stsp
744 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
745 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
746 e8a967e0 2020-03-21 stsp
747 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
748 e8a967e0 2020-03-21 stsp
749 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
750 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
751 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
752 e8a967e0 2020-03-21 stsp
753 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
754 e8a967e0 2020-03-21 stsp ret="$?"
755 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
756 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
758 e8a967e0 2020-03-21 stsp return 1
759 e8a967e0 2020-03-21 stsp fi
760 0e4002ca 2020-03-21 stsp
761 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
762 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
763 e8a967e0 2020-03-21 stsp ret="$?"
764 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
765 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
766 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
767 e8a967e0 2020-03-21 stsp return 1
768 e8a967e0 2020-03-21 stsp fi
769 e8a967e0 2020-03-21 stsp
770 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
771 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
772 e8a967e0 2020-03-21 stsp
773 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
774 0e4002ca 2020-03-21 stsp ret="$?"
775 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
776 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
777 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
778 e8a967e0 2020-03-21 stsp return 1
779 0e4002ca 2020-03-21 stsp fi
780 e8a967e0 2020-03-21 stsp
781 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
782 e8a967e0 2020-03-21 stsp
783 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
784 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
785 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
786 e8a967e0 2020-03-21 stsp
787 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
788 e8a967e0 2020-03-21 stsp ret="$?"
789 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
790 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
791 e8a967e0 2020-03-21 stsp fi
792 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
793 0e4002ca 2020-03-21 stsp
794 0e4002ca 2020-03-21 stsp }
795 0e4002ca 2020-03-21 stsp
796 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
797 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
798 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
799 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
800 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
801 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
802 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
803 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
804 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref