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 c8c71e6e 2020-03-21 stsp (cd $testroot/repo-clone && got fetch -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 d7c4e80d 2020-04-19 stsp echo "Connecting to \"origin\" 127.0.0.1" > $testroot/stdout.expected
149 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
150 c8c71e6e 2020-03-21 stsp
151 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
152 c8c71e6e 2020-03-21 stsp ret="$?"
153 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
154 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
155 c8c71e6e 2020-03-21 stsp fi
156 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
157 c8c71e6e 2020-03-21 stsp }
158 c8c71e6e 2020-03-21 stsp
159 f6cae3ed 2020-09-13 naddy test_fetch_branch() {
160 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_branch`
161 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
162 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
163 c8c71e6e 2020-03-21 stsp
164 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
165 c8c71e6e 2020-03-21 stsp ret="$?"
166 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
167 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
168 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
169 c8c71e6e 2020-03-21 stsp return 1
170 c8c71e6e 2020-03-21 stsp fi
171 c8c71e6e 2020-03-21 stsp
172 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
173 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
174 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
175 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
176 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
177 c8c71e6e 2020-03-21 stsp
178 c8c71e6e 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
179 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
180 c8c71e6e 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
181 c8c71e6e 2020-03-21 stsp
182 c8c71e6e 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
183 c8c71e6e 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
184 c8c71e6e 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
185 c8c71e6e 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
186 c8c71e6e 2020-03-21 stsp
187 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
188 c8c71e6e 2020-03-21 stsp ret="$?"
189 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
190 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
191 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
192 c8c71e6e 2020-03-21 stsp return 1
193 c8c71e6e 2020-03-21 stsp fi
194 c8c71e6e 2020-03-21 stsp
195 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
196 c8c71e6e 2020-03-21 stsp
197 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
198 c8c71e6e 2020-03-21 stsp ret="$?"
199 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
200 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
201 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
202 c8c71e6e 2020-03-21 stsp return 1
203 c8c71e6e 2020-03-21 stsp fi
204 c8c71e6e 2020-03-21 stsp
205 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
206 c8c71e6e 2020-03-21 stsp
207 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
208 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
209 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
210 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
211 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
212 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
213 c8c71e6e 2020-03-21 stsp # refs/remotes/origin/master is umodified because it wasn't fetched
214 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
215 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
216 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
217 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
218 c8c71e6e 2020-03-21 stsp
219 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
220 c8c71e6e 2020-03-21 stsp ret="$?"
221 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
222 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
223 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
224 c8c71e6e 2020-03-21 stsp return 1
225 c8c71e6e 2020-03-21 stsp fi
226 c8c71e6e 2020-03-21 stsp
227 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
228 c8c71e6e 2020-03-21 stsp ret="$?"
229 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
230 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
231 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
232 c8c71e6e 2020-03-21 stsp return 1
233 c8c71e6e 2020-03-21 stsp fi
234 c8c71e6e 2020-03-21 stsp
235 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
236 c8c71e6e 2020-03-21 stsp
237 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
238 c8c71e6e 2020-03-21 stsp ret="$?"
239 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
240 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
241 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
242 c8c71e6e 2020-03-21 stsp return 1
243 c8c71e6e 2020-03-21 stsp fi
244 c8c71e6e 2020-03-21 stsp
245 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
246 c8c71e6e 2020-03-21 stsp
247 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
248 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
249 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
250 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
251 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
254 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
255 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
256 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
257 c8c71e6e 2020-03-21 stsp
258 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
259 c8c71e6e 2020-03-21 stsp ret="$?"
260 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
261 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 c8c71e6e 2020-03-21 stsp fi
263 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
264 c8c71e6e 2020-03-21 stsp }
265 c8c71e6e 2020-03-21 stsp
266 f6cae3ed 2020-09-13 naddy test_fetch_all() {
267 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_all`
268 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
269 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
270 c8c71e6e 2020-03-21 stsp
271 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
272 c8c71e6e 2020-03-21 stsp ret="$?"
273 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
274 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
275 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
276 c8c71e6e 2020-03-21 stsp return 1
277 c8c71e6e 2020-03-21 stsp fi
278 c8c71e6e 2020-03-21 stsp
279 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
280 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
281 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
282 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
283 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
284 c8c71e6e 2020-03-21 stsp
285 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
286 c8c71e6e 2020-03-21 stsp
287 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
288 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
289 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
290 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
291 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
292 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
293 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
294 c8c71e6e 2020-03-21 stsp
295 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
296 c8c71e6e 2020-03-21 stsp ret="$?"
297 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
298 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 fetch -q -a -r $testroot/repo-clone
304 c8c71e6e 2020-03-21 stsp ret="$?"
305 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
306 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
307 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
308 c8c71e6e 2020-03-21 stsp return 1
309 c8c71e6e 2020-03-21 stsp fi
310 c8c71e6e 2020-03-21 stsp
311 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
312 c8c71e6e 2020-03-21 stsp
313 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
314 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
315 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
316 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
317 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
318 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
319 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
320 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
321 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
322 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
323 c8c71e6e 2020-03-21 stsp
324 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
325 c8c71e6e 2020-03-21 stsp ret="$?"
326 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
327 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 c8c71e6e 2020-03-21 stsp fi
329 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
330 c8c71e6e 2020-03-21 stsp }
331 c8c71e6e 2020-03-21 stsp
332 f6cae3ed 2020-09-13 naddy test_fetch_empty_packfile() {
333 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_empty_packfile`
334 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
335 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
336 c8c71e6e 2020-03-21 stsp
337 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
338 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
339 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
340 c8c71e6e 2020-03-21 stsp
341 c8c71e6e 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
342 c8c71e6e 2020-03-21 stsp ret="$?"
343 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
344 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
345 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
346 c8c71e6e 2020-03-21 stsp return 1
347 c8c71e6e 2020-03-21 stsp fi
348 c8c71e6e 2020-03-21 stsp
349 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
350 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
351 c8c71e6e 2020-03-21 stsp
352 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
353 c8c71e6e 2020-03-21 stsp
354 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
355 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
356 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
357 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
358 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
359 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
360 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
361 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
362 c8c71e6e 2020-03-21 stsp
363 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
364 c8c71e6e 2020-03-21 stsp ret="$?"
365 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
366 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
367 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
368 c8c71e6e 2020-03-21 stsp return 1
369 c8c71e6e 2020-03-21 stsp fi
370 c8c71e6e 2020-03-21 stsp
371 c8c71e6e 2020-03-21 stsp got fetch -q -a -r $testroot/repo-clone
372 c8c71e6e 2020-03-21 stsp ret="$?"
373 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
374 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
375 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
376 c8c71e6e 2020-03-21 stsp return 1
377 c8c71e6e 2020-03-21 stsp fi
378 c8c71e6e 2020-03-21 stsp
379 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
380 c8c71e6e 2020-03-21 stsp
381 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
382 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
383 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
384 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
385 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
386 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
387 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
388 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
389 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
390 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
391 c8c71e6e 2020-03-21 stsp
392 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
393 c8c71e6e 2020-03-21 stsp ret="$?"
394 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
395 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
396 c8c71e6e 2020-03-21 stsp fi
397 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
398 c8c71e6e 2020-03-21 stsp }
399 c8c71e6e 2020-03-21 stsp
400 f6cae3ed 2020-09-13 naddy test_fetch_delete_branch() {
401 c8c71e6e 2020-03-21 stsp local testroot=`test_init fetch_delete_branch`
402 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
403 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
404 c8c71e6e 2020-03-21 stsp
405 c8c71e6e 2020-03-21 stsp
406 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
407 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
408 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
409 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
410 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
411 c8c71e6e 2020-03-21 stsp
412 c8c71e6e 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
413 c8c71e6e 2020-03-21 stsp ret="$?"
414 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
415 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
416 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
417 c8c71e6e 2020-03-21 stsp return 1
418 c8c71e6e 2020-03-21 stsp fi
419 c8c71e6e 2020-03-21 stsp
420 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
421 c8c71e6e 2020-03-21 stsp
422 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
423 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
424 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
425 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
426 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
427 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
428 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
429 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
430 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
431 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
432 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
433 c8c71e6e 2020-03-21 stsp
434 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
435 c8c71e6e 2020-03-21 stsp ret="$?"
436 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
437 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
438 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
439 c8c71e6e 2020-03-21 stsp return 1
440 c8c71e6e 2020-03-21 stsp fi
441 c8c71e6e 2020-03-21 stsp
442 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -d foo
443 c8c71e6e 2020-03-21 stsp
444 c8c71e6e 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
445 c8c71e6e 2020-03-21 stsp ret="$?"
446 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
447 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
448 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
449 c8c71e6e 2020-03-21 stsp return 1
450 c8c71e6e 2020-03-21 stsp fi
451 c8c71e6e 2020-03-21 stsp
452 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
453 c8c71e6e 2020-03-21 stsp
454 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
455 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
456 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
457 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
458 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
459 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
460 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
461 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
462 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
463 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $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 fetch -d -q -r $testroot/repo-clone > $testroot/stdout
474 c8c71e6e 2020-03-21 stsp ret="$?"
475 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
476 c8c71e6e 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
477 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
478 c8c71e6e 2020-03-21 stsp return 1
479 c8c71e6e 2020-03-21 stsp fi
480 c8c71e6e 2020-03-21 stsp
481 c8c71e6e 2020-03-21 stsp echo -n > $testroot/stdout.expected
482 c8c71e6e 2020-03-21 stsp
483 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
484 c8c71e6e 2020-03-21 stsp ret="$?"
485 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
486 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
487 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
488 c8c71e6e 2020-03-21 stsp return 1
489 c8c71e6e 2020-03-21 stsp fi
490 c8c71e6e 2020-03-21 stsp
491 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
492 c8c71e6e 2020-03-21 stsp
493 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
494 c8c71e6e 2020-03-21 stsp # refs/heads/foo is now deleted
495 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
496 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
497 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
498 3789fd73 2020-03-26 stsp # refs/remotes/origin/foo is now deleted
499 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
500 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
501 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
502 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
503 c8c71e6e 2020-03-21 stsp
504 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
505 c8c71e6e 2020-03-21 stsp ret="$?"
506 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
507 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
508 c8c71e6e 2020-03-21 stsp fi
509 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
510 c8c71e6e 2020-03-21 stsp
511 c8c71e6e 2020-03-21 stsp }
512 db6d8ad8 2020-03-21 stsp
513 f6cae3ed 2020-09-13 naddy test_fetch_update_tag() {
514 db6d8ad8 2020-03-21 stsp local testroot=`test_init fetch_update_tag`
515 db6d8ad8 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
516 db6d8ad8 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
517 db6d8ad8 2020-03-21 stsp
518 db6d8ad8 2020-03-21 stsp
519 db6d8ad8 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
520 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
521 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
522 db6d8ad8 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
523 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
524 db6d8ad8 2020-03-21 stsp
525 db6d8ad8 2020-03-21 stsp got clone -a -q $testurl/repo $testroot/repo-clone
526 db6d8ad8 2020-03-21 stsp ret="$?"
527 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
528 db6d8ad8 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
529 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
530 db6d8ad8 2020-03-21 stsp return 1
531 db6d8ad8 2020-03-21 stsp fi
532 db6d8ad8 2020-03-21 stsp
533 db6d8ad8 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
534 db6d8ad8 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
535 db6d8ad8 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
536 db6d8ad8 2020-03-21 stsp
537 db6d8ad8 2020-03-21 stsp got ref -r $testroot/repo -d "refs/tags/1.0" >/dev/null
538 db6d8ad8 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id2 -m tag "1.0" >/dev/null
539 db6d8ad8 2020-03-21 stsp local tag_id2=`got ref -r $testroot/repo -l \
540 db6d8ad8 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
541 db6d8ad8 2020-03-21 stsp
542 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
543 db6d8ad8 2020-03-21 stsp
544 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
545 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
546 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
547 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
548 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
549 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
550 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
551 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
552 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
553 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
554 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
555 c8c71e6e 2020-03-21 stsp
556 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
557 db6d8ad8 2020-03-21 stsp ret="$?"
558 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
559 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
561 db6d8ad8 2020-03-21 stsp return 1
562 db6d8ad8 2020-03-21 stsp fi
563 db6d8ad8 2020-03-21 stsp
564 db6d8ad8 2020-03-21 stsp got fetch -q -r $testroot/repo-clone
565 db6d8ad8 2020-03-21 stsp ret="$?"
566 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
567 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
568 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
569 db6d8ad8 2020-03-21 stsp return 1
570 db6d8ad8 2020-03-21 stsp fi
571 db6d8ad8 2020-03-21 stsp
572 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
573 db6d8ad8 2020-03-21 stsp
574 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
575 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
576 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
577 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
578 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
579 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
580 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
581 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
582 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
583 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
584 db6d8ad8 2020-03-21 stsp
585 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
586 db6d8ad8 2020-03-21 stsp ret="$?"
587 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
588 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
589 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
590 db6d8ad8 2020-03-21 stsp return 1
591 db6d8ad8 2020-03-21 stsp fi
592 db6d8ad8 2020-03-21 stsp
593 db6d8ad8 2020-03-21 stsp got fetch -r $testroot/repo-clone 2> $testroot/stderr | \
594 db6d8ad8 2020-03-21 stsp tail -n 1 > $testroot/stdout
595 db6d8ad8 2020-03-21 stsp ret="$?"
596 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
597 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
598 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
599 db6d8ad8 2020-03-21 stsp return 1
600 db6d8ad8 2020-03-21 stsp fi
601 db6d8ad8 2020-03-21 stsp
602 db6d8ad8 2020-03-21 stsp echo "Rejecting update of existing tag refs/tags/1.0: $tag_id2" \
603 db6d8ad8 2020-03-21 stsp > $testroot/stdout.expected
604 db6d8ad8 2020-03-21 stsp
605 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
606 db6d8ad8 2020-03-21 stsp ret="$?"
607 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
608 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
609 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
610 db6d8ad8 2020-03-21 stsp return 1
611 db6d8ad8 2020-03-21 stsp fi
612 db6d8ad8 2020-03-21 stsp
613 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
614 db6d8ad8 2020-03-21 stsp
615 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
616 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
617 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
618 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
619 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
620 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
621 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
622 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
623 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
624 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
625 db6d8ad8 2020-03-21 stsp
626 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
627 db6d8ad8 2020-03-21 stsp ret="$?"
628 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
629 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
631 db6d8ad8 2020-03-21 stsp return 1
632 db6d8ad8 2020-03-21 stsp fi
633 db6d8ad8 2020-03-21 stsp
634 db6d8ad8 2020-03-21 stsp got fetch -q -t -r $testroot/repo-clone > $testroot/stdout
635 db6d8ad8 2020-03-21 stsp ret="$?"
636 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
637 db6d8ad8 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
638 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
639 db6d8ad8 2020-03-21 stsp return 1
640 db6d8ad8 2020-03-21 stsp fi
641 db6d8ad8 2020-03-21 stsp
642 db6d8ad8 2020-03-21 stsp echo -n > $testroot/stdout.expected
643 db6d8ad8 2020-03-21 stsp
644 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
645 db6d8ad8 2020-03-21 stsp ret="$?"
646 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
647 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
649 db6d8ad8 2020-03-21 stsp return 1
650 db6d8ad8 2020-03-21 stsp fi
651 db6d8ad8 2020-03-21 stsp
652 db6d8ad8 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
653 db6d8ad8 2020-03-21 stsp
654 db6d8ad8 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
655 db6d8ad8 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
656 db6d8ad8 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
657 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
658 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
659 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
660 db6d8ad8 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
661 db6d8ad8 2020-03-21 stsp >> $testroot/stdout.expected
662 db6d8ad8 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
663 db6d8ad8 2020-03-21 stsp echo "refs/tags/1.0: $tag_id2" >> $testroot/stdout.expected
664 db6d8ad8 2020-03-21 stsp
665 db6d8ad8 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
666 db6d8ad8 2020-03-21 stsp ret="$?"
667 db6d8ad8 2020-03-21 stsp if [ "$ret" != "0" ]; then
668 db6d8ad8 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
669 db6d8ad8 2020-03-21 stsp fi
670 db6d8ad8 2020-03-21 stsp test_done "$testroot" "$ret"
671 db6d8ad8 2020-03-21 stsp }
672 0e4002ca 2020-03-21 stsp
673 f6cae3ed 2020-09-13 naddy test_fetch_reference() {
674 0e4002ca 2020-03-21 stsp local testroot=`test_init fetch_reference`
675 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
676 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
677 db6d8ad8 2020-03-21 stsp
678 0e4002ca 2020-03-21 stsp got clone -q $testurl/repo $testroot/repo-clone
679 0e4002ca 2020-03-21 stsp ret="$?"
680 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
681 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
682 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
683 0e4002ca 2020-03-21 stsp return 1
684 0e4002ca 2020-03-21 stsp fi
685 0e4002ca 2020-03-21 stsp
686 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
687 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
688 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
689 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
690 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
691 0e4002ca 2020-03-21 stsp
692 0e4002ca 2020-03-21 stsp echo "modified alpha on master" > $testroot/repo/alpha
693 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
694 0e4002ca 2020-03-21 stsp local commit_id2=`git_show_head $testroot/repo`
695 0e4002ca 2020-03-21 stsp
696 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q foo)
697 0e4002ca 2020-03-21 stsp echo "modified alpha on foo" > $testroot/repo/alpha
698 0e4002ca 2020-03-21 stsp git_commit $testroot/repo -m "modified alpha"
699 0e4002ca 2020-03-21 stsp local commit_id3=`git_show_head $testroot/repo`
700 0e4002ca 2020-03-21 stsp (cd $testroot/repo && git checkout -q master)
701 0e4002ca 2020-03-21 stsp
702 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/remotes/origin/main \
703 0e4002ca 2020-03-21 stsp > $testroot/stdout 2> $testroot/stderr
704 0e4002ca 2020-03-21 stsp ret="$?"
705 0e4002ca 2020-03-21 stsp if [ "$ret" == "0" ]; then
706 0e4002ca 2020-03-21 stsp echo "got fetch command succeeded unexpectedly" >&2
707 ecdc3b49 2020-03-21 stsp test_done "$testroot" "1"
708 0e4002ca 2020-03-21 stsp return 1
709 0e4002ca 2020-03-21 stsp fi
710 0e4002ca 2020-03-21 stsp
711 0e4002ca 2020-03-21 stsp echo -n > $testroot/stdout.expected
712 0e4002ca 2020-03-21 stsp
713 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
714 0e4002ca 2020-03-21 stsp ret="$?"
715 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
716 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
718 0e4002ca 2020-03-21 stsp return 1
719 0e4002ca 2020-03-21 stsp fi
720 0e4002ca 2020-03-21 stsp
721 0e4002ca 2020-03-21 stsp echo "got: refs/remotes/origin/main: reference cannot be fetched" \
722 0e4002ca 2020-03-21 stsp > $testroot/stderr.expected
723 0e4002ca 2020-03-21 stsp
724 0e4002ca 2020-03-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
725 0e4002ca 2020-03-21 stsp ret="$?"
726 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
727 0e4002ca 2020-03-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
728 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
729 0e4002ca 2020-03-21 stsp return 1
730 0e4002ca 2020-03-21 stsp fi
731 0e4002ca 2020-03-21 stsp
732 0e4002ca 2020-03-21 stsp got fetch -q -r $testroot/repo-clone -R refs/hoo
733 0e4002ca 2020-03-21 stsp ret="$?"
734 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
735 0e4002ca 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
736 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
737 0e4002ca 2020-03-21 stsp return 1
738 0e4002ca 2020-03-21 stsp fi
739 0e4002ca 2020-03-21 stsp
740 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
741 0e4002ca 2020-03-21 stsp
742 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
743 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
744 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
745 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
746 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
747 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
748 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
749 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
750 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
751 e8a967e0 2020-03-21 stsp
752 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
753 e8a967e0 2020-03-21 stsp ret="$?"
754 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
755 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
756 e8a967e0 2020-03-21 stsp fi
757 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
758 e8a967e0 2020-03-21 stsp
759 e8a967e0 2020-03-21 stsp }
760 e8a967e0 2020-03-21 stsp
761 f6cae3ed 2020-09-13 naddy test_fetch_replace_symref() {
762 e8a967e0 2020-03-21 stsp local testroot=`test_init fetch_replace_symref`
763 e8a967e0 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
764 e8a967e0 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
765 e8a967e0 2020-03-21 stsp
766 e8a967e0 2020-03-21 stsp got clone -m -q $testurl/repo $testroot/repo-clone
767 e8a967e0 2020-03-21 stsp ret="$?"
768 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
769 e8a967e0 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
770 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
771 e8a967e0 2020-03-21 stsp return 1
772 e8a967e0 2020-03-21 stsp fi
773 e8a967e0 2020-03-21 stsp
774 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
775 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo-clone -s refs/heads/master refs/hoo/boo/zoo
776 e8a967e0 2020-03-21 stsp
777 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
778 e8a967e0 2020-03-21 stsp
779 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
780 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
781 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: refs/heads/master" >> $testroot/stdout.expected
782 e8a967e0 2020-03-21 stsp
783 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
784 e8a967e0 2020-03-21 stsp ret="$?"
785 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
786 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
788 e8a967e0 2020-03-21 stsp return 1
789 e8a967e0 2020-03-21 stsp fi
790 0e4002ca 2020-03-21 stsp
791 e8a967e0 2020-03-21 stsp got fetch -r $testroot/repo-clone -R refs/hoo \
792 e8a967e0 2020-03-21 stsp 2> $testroot/stderr | grep ^Replacing > $testroot/stdout
793 e8a967e0 2020-03-21 stsp ret="$?"
794 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
795 e8a967e0 2020-03-21 stsp echo "got fetch command failed unexpectedly" >&2
796 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
797 e8a967e0 2020-03-21 stsp return 1
798 e8a967e0 2020-03-21 stsp fi
799 e8a967e0 2020-03-21 stsp
800 e8a967e0 2020-03-21 stsp echo "Replacing reference refs/hoo/boo/zoo: refs/heads/master" \
801 e8a967e0 2020-03-21 stsp > $testroot/stdout.expected
802 e8a967e0 2020-03-21 stsp
803 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
804 0e4002ca 2020-03-21 stsp ret="$?"
805 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
806 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
807 e8a967e0 2020-03-21 stsp test_done "$testroot" "$ret"
808 e8a967e0 2020-03-21 stsp return 1
809 0e4002ca 2020-03-21 stsp fi
810 e8a967e0 2020-03-21 stsp
811 e8a967e0 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
812 e8a967e0 2020-03-21 stsp
813 e8a967e0 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
814 e8a967e0 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
815 e8a967e0 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
816 f1bcca34 2020-03-25 stsp
817 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
818 f1bcca34 2020-03-25 stsp ret="$?"
819 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
820 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
821 f1bcca34 2020-03-25 stsp fi
822 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
823 f1bcca34 2020-03-25 stsp
824 f1bcca34 2020-03-25 stsp }
825 f1bcca34 2020-03-25 stsp
826 f6cae3ed 2020-09-13 naddy test_fetch_update_headref() {
827 f1bcca34 2020-03-25 stsp local testroot=`test_init fetch_update_headref`
828 f1bcca34 2020-03-25 stsp local testurl=ssh://127.0.0.1/$testroot
829 f1bcca34 2020-03-25 stsp local commit_id=`git_show_head $testroot/repo`
830 f1bcca34 2020-03-25 stsp
831 f1bcca34 2020-03-25 stsp got clone -q $testurl/repo $testroot/repo-clone
832 f1bcca34 2020-03-25 stsp ret="$?"
833 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
834 f1bcca34 2020-03-25 stsp echo "got clone command failed unexpectedly" >&2
835 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
836 f1bcca34 2020-03-25 stsp return 1
837 f1bcca34 2020-03-25 stsp fi
838 f1bcca34 2020-03-25 stsp
839 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
840 f1bcca34 2020-03-25 stsp
841 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
842 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
843 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
844 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
845 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
846 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
847 f1bcca34 2020-03-25 stsp
848 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
849 f1bcca34 2020-03-25 stsp ret="$?"
850 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
851 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
853 f1bcca34 2020-03-25 stsp return 1
854 f1bcca34 2020-03-25 stsp fi
855 e8a967e0 2020-03-21 stsp
856 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -c refs/heads/master refs/heads/foo
857 f1bcca34 2020-03-25 stsp got ref -r $testroot/repo -s refs/heads/foo HEAD
858 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo > $testroot/stdout
859 f1bcca34 2020-03-25 stsp
860 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
861 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
862 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
863 f1bcca34 2020-03-25 stsp
864 e8a967e0 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
865 e8a967e0 2020-03-21 stsp ret="$?"
866 e8a967e0 2020-03-21 stsp if [ "$ret" != "0" ]; then
867 e8a967e0 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
868 f1bcca34 2020-03-25 stsp test_done "$testroot" "$ret"
869 f1bcca34 2020-03-25 stsp return 1
870 e8a967e0 2020-03-21 stsp fi
871 f1bcca34 2020-03-25 stsp
872 f1bcca34 2020-03-25 stsp got fetch -q -r $testroot/repo-clone
873 f1bcca34 2020-03-25 stsp
874 f1bcca34 2020-03-25 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
875 f1bcca34 2020-03-25 stsp
876 f1bcca34 2020-03-25 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
877 f1bcca34 2020-03-25 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
878 f1bcca34 2020-03-25 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
879 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
880 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
881 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/foo: $commit_id" \
882 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
883 f1bcca34 2020-03-25 stsp echo "refs/remotes/origin/master: $commit_id" \
884 f1bcca34 2020-03-25 stsp >> $testroot/stdout.expected
885 f1bcca34 2020-03-25 stsp
886 f1bcca34 2020-03-25 stsp cmp -s $testroot/stdout $testroot/stdout.expected
887 f1bcca34 2020-03-25 stsp ret="$?"
888 f1bcca34 2020-03-25 stsp if [ "$ret" != "0" ]; then
889 f1bcca34 2020-03-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
890 f1bcca34 2020-03-25 stsp fi
891 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
892 bcf34b0e 2020-03-26 stsp }
893 bcf34b0e 2020-03-26 stsp
894 f6cae3ed 2020-09-13 naddy test_fetch_headref_deleted_locally() {
895 bcf34b0e 2020-03-26 stsp local testroot=`test_init fetch_headref_deleted_locally`
896 bcf34b0e 2020-03-26 stsp local testurl=ssh://127.0.0.1/$testroot
897 bcf34b0e 2020-03-26 stsp local commit_id=`git_show_head $testroot/repo`
898 bcf34b0e 2020-03-26 stsp
899 bcf34b0e 2020-03-26 stsp got clone -q $testurl/repo $testroot/repo-clone
900 bcf34b0e 2020-03-26 stsp ret="$?"
901 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
902 bcf34b0e 2020-03-26 stsp echo "got clone command failed unexpectedly" >&2
903 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
904 bcf34b0e 2020-03-26 stsp return 1
905 bcf34b0e 2020-03-26 stsp fi
906 bcf34b0e 2020-03-26 stsp
907 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
908 0e4002ca 2020-03-21 stsp
909 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
910 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
911 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
912 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
913 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
914 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
915 bcf34b0e 2020-03-26 stsp
916 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
917 bcf34b0e 2020-03-26 stsp ret="$?"
918 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
919 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
920 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
921 bcf34b0e 2020-03-26 stsp return 1
922 bcf34b0e 2020-03-26 stsp fi
923 bcf34b0e 2020-03-26 stsp
924 bcf34b0e 2020-03-26 stsp got ref -r $testroot/repo-clone -d refs/remotes/origin/HEAD
925 bcf34b0e 2020-03-26 stsp
926 bcf34b0e 2020-03-26 stsp got fetch -q -r $testroot/repo-clone
927 bcf34b0e 2020-03-26 stsp ret="$?"
928 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
929 bcf34b0e 2020-03-26 stsp echo "got fetch command failed unexpectedly" >&2
930 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
931 bcf34b0e 2020-03-26 stsp return 1
932 bcf34b0e 2020-03-26 stsp fi
933 bcf34b0e 2020-03-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
934 bcf34b0e 2020-03-26 stsp
935 bcf34b0e 2020-03-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
936 bcf34b0e 2020-03-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
937 bcf34b0e 2020-03-26 stsp # refs/remotes/origin/HEAD has been restored:
938 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
939 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
940 bcf34b0e 2020-03-26 stsp echo "refs/remotes/origin/master: $commit_id" \
941 bcf34b0e 2020-03-26 stsp >> $testroot/stdout.expected
942 50b0790e 2020-09-11 stsp
943 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
944 50b0790e 2020-09-11 stsp ret="$?"
945 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
946 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
947 50b0790e 2020-09-11 stsp fi
948 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
949 50b0790e 2020-09-11 stsp }
950 50b0790e 2020-09-11 stsp
951 f6cae3ed 2020-09-13 naddy test_fetch_gotconfig_remote_repo() {
952 50b0790e 2020-09-11 stsp local testroot=`test_init fetch_gotconfig_remote_repo`
953 50b0790e 2020-09-11 stsp local testurl=ssh://127.0.0.1/$testroot
954 50b0790e 2020-09-11 stsp local commit_id=`git_show_head $testroot/repo`
955 50b0790e 2020-09-11 stsp
956 50b0790e 2020-09-11 stsp got branch -r $testroot/repo -c $commit_id foo
957 50b0790e 2020-09-11 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
958 50b0790e 2020-09-11 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
959 50b0790e 2020-09-11 stsp
960 50b0790e 2020-09-11 stsp got clone -q $testurl/repo $testroot/repo-clone
961 50b0790e 2020-09-11 stsp ret="$?"
962 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
963 50b0790e 2020-09-11 stsp echo "got clone command failed unexpectedly" >&2
964 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
965 50b0790e 2020-09-11 stsp return 1
966 50b0790e 2020-09-11 stsp fi
967 50b0790e 2020-09-11 stsp
968 50b0790e 2020-09-11 stsp cat > $testroot/repo-clone/got.conf <<EOF
969 50b0790e 2020-09-11 stsp remote "foobar" {
970 50b0790e 2020-09-11 stsp protocol ssh
971 50b0790e 2020-09-11 stsp server 127.0.0.1
972 50b0790e 2020-09-11 stsp repository "$testroot/repo"
973 50b0790e 2020-09-11 stsp }
974 50b0790e 2020-09-11 stsp
975 50b0790e 2020-09-11 stsp remote "barbaz" {
976 50b0790e 2020-09-11 stsp protocol ssh
977 50b0790e 2020-09-11 stsp server 127.0.0.1
978 50b0790e 2020-09-11 stsp repository "$testroot/does-not-exist"
979 50b0790e 2020-09-11 stsp }
980 50b0790e 2020-09-11 stsp EOF
981 54eb00d5 2020-10-20 stsp echo "got: nonexistent: remote repository not found" \
982 54eb00d5 2020-10-20 stsp > $testroot/stderr.expected
983 54eb00d5 2020-10-20 stsp (cd $testroot/repo-clone && got fetch nonexistent \
984 54eb00d5 2020-10-20 stsp > $testroot/stdout 2> $testroot/stderr)
985 54eb00d5 2020-10-20 stsp ret="$?"
986 54eb00d5 2020-10-20 stsp if [ "$ret" == "0" ]; then
987 54eb00d5 2020-10-20 stsp echo "got fetch command succeeded unexpectedly" >&2
988 54eb00d5 2020-10-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
989 54eb00d5 2020-10-20 stsp test_done "$testroot" "1"
990 54eb00d5 2020-10-20 stsp return 1
991 54eb00d5 2020-10-20 stsp fi
992 54eb00d5 2020-10-20 stsp
993 50b0790e 2020-09-11 stsp (cd $testroot/repo-clone && got fetch -l foobar \
994 50b0790e 2020-09-11 stsp > $testroot/stdout)
995 50b0790e 2020-09-11 stsp ret="$?"
996 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
997 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
998 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
999 50b0790e 2020-09-11 stsp return 1
1000 50b0790e 2020-09-11 stsp fi
1001 bcf34b0e 2020-03-26 stsp
1002 50b0790e 2020-09-11 stsp echo "Connecting to \"foobar\" 127.0.0.1" > $testroot/stdout.expected
1003 50b0790e 2020-09-11 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
1004 50b0790e 2020-09-11 stsp
1005 bcf34b0e 2020-03-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1006 bcf34b0e 2020-03-26 stsp ret="$?"
1007 bcf34b0e 2020-03-26 stsp if [ "$ret" != "0" ]; then
1008 bcf34b0e 2020-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1009 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1010 50b0790e 2020-09-11 stsp return 1
1011 bcf34b0e 2020-03-26 stsp fi
1012 50b0790e 2020-09-11 stsp
1013 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1014 50b0790e 2020-09-11 stsp
1015 50b0790e 2020-09-11 stsp cat > $testroot/wt/.got/got.conf <<EOF
1016 50b0790e 2020-09-11 stsp remote "barbaz" {
1017 50b0790e 2020-09-11 stsp protocol ssh
1018 50b0790e 2020-09-11 stsp server 127.0.0.1
1019 50b0790e 2020-09-11 stsp repository "$testroot/repo"
1020 50b0790e 2020-09-11 stsp }
1021 50b0790e 2020-09-11 stsp EOF
1022 50b0790e 2020-09-11 stsp (cd $testroot/wt && got fetch -l barbaz > $testroot/stdout)
1023 50b0790e 2020-09-11 stsp ret="$?"
1024 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1025 50b0790e 2020-09-11 stsp echo "got fetch command failed unexpectedly" >&2
1026 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
1027 50b0790e 2020-09-11 stsp return 1
1028 50b0790e 2020-09-11 stsp fi
1029 50b0790e 2020-09-11 stsp
1030 50b0790e 2020-09-11 stsp echo "Connecting to \"barbaz\" 127.0.0.1" > $testroot/stdout.expected
1031 50b0790e 2020-09-11 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
1032 50b0790e 2020-09-11 stsp
1033 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1034 50b0790e 2020-09-11 stsp ret="$?"
1035 50b0790e 2020-09-11 stsp if [ "$ret" != "0" ]; then
1036 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
1037 50b0790e 2020-09-11 stsp fi
1038 bcf34b0e 2020-03-26 stsp test_done "$testroot" "$ret"
1039 50b0790e 2020-09-11 stsp
1040 0e4002ca 2020-03-21 stsp }
1041 0e4002ca 2020-03-21 stsp
1042 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1043 c8c71e6e 2020-03-21 stsp run_test test_fetch_basic
1044 c8c71e6e 2020-03-21 stsp run_test test_fetch_list
1045 c8c71e6e 2020-03-21 stsp run_test test_fetch_branch
1046 c8c71e6e 2020-03-21 stsp run_test test_fetch_all
1047 c8c71e6e 2020-03-21 stsp run_test test_fetch_empty_packfile
1048 c8c71e6e 2020-03-21 stsp run_test test_fetch_delete_branch
1049 db6d8ad8 2020-03-21 stsp run_test test_fetch_update_tag
1050 0e4002ca 2020-03-21 stsp run_test test_fetch_reference
1051 e8a967e0 2020-03-21 stsp run_test test_fetch_replace_symref
1052 f1bcca34 2020-03-25 stsp run_test test_fetch_update_headref
1053 bcf34b0e 2020-03-26 stsp run_test test_fetch_headref_deleted_locally
1054 50b0790e 2020-09-11 stsp run_test test_fetch_gotconfig_remote_repo