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_clone_basic() {
20 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_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 got log -l0 -p -r $testroot/repo > $testroot/log-repo
33 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
34 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
35 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
36 c8c71e6e 2020-03-21 stsp return 1
37 c8c71e6e 2020-03-21 stsp fi
38 c8c71e6e 2020-03-21 stsp got log -l0 -p -r $testroot/repo > $testroot/log-repo-clone
39 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
40 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
41 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
42 c8c71e6e 2020-03-21 stsp return 1
43 c8c71e6e 2020-03-21 stsp fi
44 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
45 c8c71e6e 2020-03-21 stsp ret="$?"
46 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
47 c8c71e6e 2020-03-21 stsp echo "log -p output of cloned repository differs" >&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 got ref -l -r $testroot/repo > $testroot/stdout
53 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
54 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
55 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
56 c8c71e6e 2020-03-21 stsp return 1
57 c8c71e6e 2020-03-21 stsp fi
58 c8c71e6e 2020-03-21 stsp
59 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
60 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
61 c8c71e6e 2020-03-21 stsp
62 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
63 c8c71e6e 2020-03-21 stsp ret="$?"
64 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
65 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
66 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
67 c8c71e6e 2020-03-21 stsp return 1
68 c8c71e6e 2020-03-21 stsp fi
69 c8c71e6e 2020-03-21 stsp
70 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
71 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
72 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
73 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
74 c8c71e6e 2020-03-21 stsp return 1
75 c8c71e6e 2020-03-21 stsp fi
76 c8c71e6e 2020-03-21 stsp
77 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
78 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
79 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
80 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
81 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
82 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
83 c8c71e6e 2020-03-21 stsp
84 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
85 c8c71e6e 2020-03-21 stsp ret="$?"
86 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
87 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
88 c8c71e6e 2020-03-21 stsp fi
89 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
90 c8c71e6e 2020-03-21 stsp }
91 c8c71e6e 2020-03-21 stsp
92 f6cae3ed 2020-09-13 naddy test_clone_list() {
93 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_list`
94 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
95 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
96 c8c71e6e 2020-03-21 stsp
97 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
98 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
99 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
100 c8c71e6e 2020-03-21 stsp
101 c8c71e6e 2020-03-21 stsp got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
102 c8c71e6e 2020-03-21 stsp ret="$?"
103 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
104 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
105 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
106 c8c71e6e 2020-03-21 stsp return 1
107 c8c71e6e 2020-03-21 stsp fi
108 c8c71e6e 2020-03-21 stsp
109 d7c4e80d 2020-04-19 stsp echo "Connecting to 127.0.0.1" > $testroot/stdout.expected
110 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $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 f6cae3ed 2020-09-13 naddy test_clone_branch() {
121 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_branch`
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 local tag_id=`got ref -r $testroot/repo -l \
129 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
130 c8c71e6e 2020-03-21 stsp
131 c8c71e6e 2020-03-21 stsp got clone -q -b foo $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 got ref -l -r $testroot/repo-clone > $testroot/stdout
140 c8c71e6e 2020-03-21 stsp
141 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
142 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
143 c8c71e6e 2020-03-21 stsp # refs/heads/master is missing because it wasn't passed via -b
144 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
145 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
146 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
147 c8c71e6e 2020-03-21 stsp
148 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
149 c8c71e6e 2020-03-21 stsp ret="$?"
150 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
151 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
152 c8c71e6e 2020-03-21 stsp fi
153 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
154 c8c71e6e 2020-03-21 stsp }
155 c8c71e6e 2020-03-21 stsp
156 f6cae3ed 2020-09-13 naddy test_clone_all() {
157 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_all`
158 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
159 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
160 c8c71e6e 2020-03-21 stsp
161 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
162 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
163 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
164 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
165 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
166 c8c71e6e 2020-03-21 stsp
167 c8c71e6e 2020-03-21 stsp got clone -q -a $testurl/repo $testroot/repo-clone
168 c8c71e6e 2020-03-21 stsp ret="$?"
169 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
170 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
171 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
172 c8c71e6e 2020-03-21 stsp return 1
173 c8c71e6e 2020-03-21 stsp fi
174 c8c71e6e 2020-03-21 stsp
175 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
176 c8c71e6e 2020-03-21 stsp
177 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
178 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
179 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
180 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
181 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
182 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
183 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
184 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
185 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
186 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
187 c8c71e6e 2020-03-21 stsp
188 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
189 c8c71e6e 2020-03-21 stsp ret="$?"
190 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
191 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
192 c8c71e6e 2020-03-21 stsp fi
193 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
194 c8c71e6e 2020-03-21 stsp }
195 c8c71e6e 2020-03-21 stsp
196 f6cae3ed 2020-09-13 naddy test_clone_mirror() {
197 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror`
198 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
199 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
200 c8c71e6e 2020-03-21 stsp
201 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
202 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
203 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
204 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
205 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
206 c8c71e6e 2020-03-21 stsp
207 c8c71e6e 2020-03-21 stsp got clone -q -m $testurl/repo $testroot/repo-clone
208 c8c71e6e 2020-03-21 stsp ret="$?"
209 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
210 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
211 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
212 c8c71e6e 2020-03-21 stsp return 1
213 c8c71e6e 2020-03-21 stsp fi
214 c8c71e6e 2020-03-21 stsp
215 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
216 c8c71e6e 2020-03-21 stsp
217 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
218 c8c71e6e 2020-03-21 stsp # refs/heads/foo is missing because we're not fetching all branches
219 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
220 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
221 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
222 c8c71e6e 2020-03-21 stsp
223 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
224 c8c71e6e 2020-03-21 stsp ret="$?"
225 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
226 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
227 c8c71e6e 2020-03-21 stsp fi
228 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
229 c8c71e6e 2020-03-21 stsp }
230 c8c71e6e 2020-03-21 stsp
231 f6cae3ed 2020-09-13 naddy test_clone_mirror_all() {
232 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror_all`
233 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
234 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
235 c8c71e6e 2020-03-21 stsp
236 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
237 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
238 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
239 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
240 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
241 c8c71e6e 2020-03-21 stsp
242 c8c71e6e 2020-03-21 stsp got clone -q -m -a $testurl/repo $testroot/repo-clone
243 c8c71e6e 2020-03-21 stsp ret="$?"
244 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
245 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
246 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
247 c8c71e6e 2020-03-21 stsp return 1
248 c8c71e6e 2020-03-21 stsp fi
249 c8c71e6e 2020-03-21 stsp
250 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
251 c8c71e6e 2020-03-21 stsp
252 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
254 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $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 0e4002ca 2020-03-21 stsp
266 f6cae3ed 2020-09-13 naddy test_clone_reference() {
267 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
268 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
269 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
270 c8c71e6e 2020-03-21 stsp
271 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
272 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
273 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
274 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
275 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
276 0e4002ca 2020-03-21 stsp
277 0e4002ca 2020-03-21 stsp got clone -q -R hoo $testurl/repo $testroot/repo-clone
278 0e4002ca 2020-03-21 stsp ret="$?"
279 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
280 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
281 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
282 0e4002ca 2020-03-21 stsp return 1
283 0e4002ca 2020-03-21 stsp fi
284 0e4002ca 2020-03-21 stsp
285 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
286 0e4002ca 2020-03-21 stsp
287 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
288 0e4002ca 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 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
292 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
293 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
294 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
295 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
296 0e4002ca 2020-03-21 stsp
297 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
298 0e4002ca 2020-03-21 stsp ret="$?"
299 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
300 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
301 0e4002ca 2020-03-21 stsp fi
302 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
303 0e4002ca 2020-03-21 stsp }
304 0e4002ca 2020-03-21 stsp
305 f6cae3ed 2020-09-13 naddy test_clone_branch_and_reference() {
306 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
307 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
308 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
309 0e4002ca 2020-03-21 stsp
310 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
311 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
312 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
313 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
314 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
315 0e4002ca 2020-03-21 stsp
316 0e4002ca 2020-03-21 stsp got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
317 0e4002ca 2020-03-21 stsp ret="$?"
318 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
319 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
320 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
321 0e4002ca 2020-03-21 stsp return 1
322 0e4002ca 2020-03-21 stsp fi
323 0e4002ca 2020-03-21 stsp
324 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
325 0e4002ca 2020-03-21 stsp
326 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
327 0e4002ca 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
328 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
329 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
330 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
331 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
332 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
333 0e4002ca 2020-03-21 stsp
334 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
335 0e4002ca 2020-03-21 stsp ret="$?"
336 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
337 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
338 0e4002ca 2020-03-21 stsp fi
339 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
340 0e4002ca 2020-03-21 stsp }
341 0e4002ca 2020-03-21 stsp
342 f6cae3ed 2020-09-13 naddy test_clone_reference_mirror() {
343 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference_mirror`
344 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
345 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
346 0e4002ca 2020-03-21 stsp
347 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
348 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
349 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
350 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
351 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
352 0e4002ca 2020-03-21 stsp
353 0e4002ca 2020-03-21 stsp got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
354 0e4002ca 2020-03-21 stsp ret="$?"
355 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
356 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
357 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
358 0e4002ca 2020-03-21 stsp return 1
359 0e4002ca 2020-03-21 stsp fi
360 0e4002ca 2020-03-21 stsp
361 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
362 0e4002ca 2020-03-21 stsp
363 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
364 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
365 0e4002ca 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
366 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
367 0e4002ca 2020-03-21 stsp
368 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
369 0e4002ca 2020-03-21 stsp ret="$?"
370 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
371 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
372 0e4002ca 2020-03-21 stsp fi
373 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
374 0e4002ca 2020-03-21 stsp }
375 0e4002ca 2020-03-21 stsp
376 7fb414ae 2020-08-08 stsp test_parseargs "$@"
377 c8c71e6e 2020-03-21 stsp run_test test_clone_basic
378 c8c71e6e 2020-03-21 stsp run_test test_clone_list
379 c8c71e6e 2020-03-21 stsp run_test test_clone_branch
380 c8c71e6e 2020-03-21 stsp run_test test_clone_all
381 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror
382 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror_all
383 0e4002ca 2020-03-21 stsp run_test test_clone_reference
384 0e4002ca 2020-03-21 stsp run_test test_clone_branch_and_reference
385 0e4002ca 2020-03-21 stsp run_test test_clone_reference_mirror