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 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
89 a9c2d4c2 2020-09-24 stsp return 1
90 c8c71e6e 2020-03-21 stsp fi
91 a9c2d4c2 2020-09-24 stsp
92 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
93 a9c2d4c2 2020-09-24 stsp remote "origin" {
94 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
95 a9c2d4c2 2020-09-24 stsp protocol ssh
96 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
97 a9c2d4c2 2020-09-24 stsp }
98 a9c2d4c2 2020-09-24 stsp EOF
99 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
100 a9c2d4c2 2020-09-24 stsp ret="$?"
101 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
102 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
103 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
104 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
105 a9c2d4c2 2020-09-24 stsp return 1
106 a9c2d4c2 2020-09-24 stsp fi
107 a9c2d4c2 2020-09-24 stsp
108 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
109 a9c2d4c2 2020-09-24 stsp [core]
110 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
111 a9c2d4c2 2020-09-24 stsp filemode = true
112 a9c2d4c2 2020-09-24 stsp bare = true
113 a9c2d4c2 2020-09-24 stsp
114 a9c2d4c2 2020-09-24 stsp [remote "origin"]
115 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
116 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
117 a9c2d4c2 2020-09-24 stsp EOF
118 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
119 a9c2d4c2 2020-09-24 stsp ret="$?"
120 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
121 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
122 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
123 a9c2d4c2 2020-09-24 stsp fi
124 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
125 c8c71e6e 2020-03-21 stsp }
126 c8c71e6e 2020-03-21 stsp
127 f6cae3ed 2020-09-13 naddy test_clone_list() {
128 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_list`
129 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
130 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
131 c8c71e6e 2020-03-21 stsp
132 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
133 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
134 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
135 c8c71e6e 2020-03-21 stsp
136 c8c71e6e 2020-03-21 stsp got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
137 c8c71e6e 2020-03-21 stsp ret="$?"
138 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
139 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
140 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
141 c8c71e6e 2020-03-21 stsp return 1
142 c8c71e6e 2020-03-21 stsp fi
143 c8c71e6e 2020-03-21 stsp
144 d7c4e80d 2020-04-19 stsp echo "Connecting to 127.0.0.1" > $testroot/stdout.expected
145 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
146 c8c71e6e 2020-03-21 stsp
147 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
148 c8c71e6e 2020-03-21 stsp ret="$?"
149 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
150 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
151 c8c71e6e 2020-03-21 stsp fi
152 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
153 c8c71e6e 2020-03-21 stsp }
154 c8c71e6e 2020-03-21 stsp
155 f6cae3ed 2020-09-13 naddy test_clone_branch() {
156 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_branch`
157 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
158 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
159 c8c71e6e 2020-03-21 stsp
160 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
161 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
162 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
163 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
164 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
165 c8c71e6e 2020-03-21 stsp
166 c8c71e6e 2020-03-21 stsp got clone -q -b foo $testurl/repo $testroot/repo-clone
167 c8c71e6e 2020-03-21 stsp ret="$?"
168 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
169 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
170 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
171 c8c71e6e 2020-03-21 stsp return 1
172 c8c71e6e 2020-03-21 stsp fi
173 c8c71e6e 2020-03-21 stsp
174 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
175 c8c71e6e 2020-03-21 stsp
176 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
177 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
178 c8c71e6e 2020-03-21 stsp # refs/heads/master is missing because it wasn't passed via -b
179 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
180 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
181 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
182 c8c71e6e 2020-03-21 stsp
183 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
184 c8c71e6e 2020-03-21 stsp ret="$?"
185 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
186 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
187 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
188 a9c2d4c2 2020-09-24 stsp return 1
189 c8c71e6e 2020-03-21 stsp fi
190 a9c2d4c2 2020-09-24 stsp
191 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
192 a9c2d4c2 2020-09-24 stsp remote "origin" {
193 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
194 a9c2d4c2 2020-09-24 stsp protocol ssh
195 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
196 a9c2d4c2 2020-09-24 stsp }
197 a9c2d4c2 2020-09-24 stsp EOF
198 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
199 a9c2d4c2 2020-09-24 stsp ret="$?"
200 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
201 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
202 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
203 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
204 a9c2d4c2 2020-09-24 stsp return 1
205 a9c2d4c2 2020-09-24 stsp fi
206 a9c2d4c2 2020-09-24 stsp
207 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
208 a9c2d4c2 2020-09-24 stsp [core]
209 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
210 a9c2d4c2 2020-09-24 stsp filemode = true
211 a9c2d4c2 2020-09-24 stsp bare = true
212 a9c2d4c2 2020-09-24 stsp
213 a9c2d4c2 2020-09-24 stsp [remote "origin"]
214 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
215 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
216 a9c2d4c2 2020-09-24 stsp EOF
217 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
218 a9c2d4c2 2020-09-24 stsp ret="$?"
219 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
220 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
221 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
222 a9c2d4c2 2020-09-24 stsp fi
223 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
224 c8c71e6e 2020-03-21 stsp }
225 c8c71e6e 2020-03-21 stsp
226 f6cae3ed 2020-09-13 naddy test_clone_all() {
227 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_all`
228 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
229 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
230 c8c71e6e 2020-03-21 stsp
231 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
232 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
233 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
234 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
235 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
236 c8c71e6e 2020-03-21 stsp
237 c8c71e6e 2020-03-21 stsp got clone -q -a $testurl/repo $testroot/repo-clone
238 c8c71e6e 2020-03-21 stsp ret="$?"
239 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
240 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
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_id" >> $testroot/stdout.expected
249 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
250 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
251 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
252 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
253 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
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 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
263 a9c2d4c2 2020-09-24 stsp return 1
264 c8c71e6e 2020-03-21 stsp fi
265 a9c2d4c2 2020-09-24 stsp
266 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
267 a9c2d4c2 2020-09-24 stsp remote "origin" {
268 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
269 a9c2d4c2 2020-09-24 stsp protocol ssh
270 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
271 a9c2d4c2 2020-09-24 stsp }
272 a9c2d4c2 2020-09-24 stsp EOF
273 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
274 a9c2d4c2 2020-09-24 stsp ret="$?"
275 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
276 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
277 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
278 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
279 a9c2d4c2 2020-09-24 stsp return 1
280 a9c2d4c2 2020-09-24 stsp fi
281 a9c2d4c2 2020-09-24 stsp
282 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
283 a9c2d4c2 2020-09-24 stsp [core]
284 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
285 a9c2d4c2 2020-09-24 stsp filemode = true
286 a9c2d4c2 2020-09-24 stsp bare = true
287 a9c2d4c2 2020-09-24 stsp
288 a9c2d4c2 2020-09-24 stsp [remote "origin"]
289 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
290 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/*:refs/remotes/origin/*
291 a9c2d4c2 2020-09-24 stsp EOF
292 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
293 a9c2d4c2 2020-09-24 stsp ret="$?"
294 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
295 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
296 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
297 a9c2d4c2 2020-09-24 stsp fi
298 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
299 c8c71e6e 2020-03-21 stsp }
300 c8c71e6e 2020-03-21 stsp
301 f6cae3ed 2020-09-13 naddy test_clone_mirror() {
302 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror`
303 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
304 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
305 c8c71e6e 2020-03-21 stsp
306 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
307 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
308 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
309 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
310 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
311 c8c71e6e 2020-03-21 stsp
312 c8c71e6e 2020-03-21 stsp got clone -q -m $testurl/repo $testroot/repo-clone
313 c8c71e6e 2020-03-21 stsp ret="$?"
314 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
315 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
316 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
317 c8c71e6e 2020-03-21 stsp return 1
318 c8c71e6e 2020-03-21 stsp fi
319 c8c71e6e 2020-03-21 stsp
320 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
321 c8c71e6e 2020-03-21 stsp
322 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
323 c8c71e6e 2020-03-21 stsp # refs/heads/foo is missing because we're not fetching all branches
324 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
325 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
326 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
327 c8c71e6e 2020-03-21 stsp
328 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
329 c8c71e6e 2020-03-21 stsp ret="$?"
330 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
331 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
333 a9c2d4c2 2020-09-24 stsp return 1
334 c8c71e6e 2020-03-21 stsp fi
335 a9c2d4c2 2020-09-24 stsp
336 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
337 a9c2d4c2 2020-09-24 stsp remote "origin" {
338 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
339 a9c2d4c2 2020-09-24 stsp protocol ssh
340 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
341 a9c2d4c2 2020-09-24 stsp mirror-references yes
342 a9c2d4c2 2020-09-24 stsp }
343 a9c2d4c2 2020-09-24 stsp EOF
344 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
345 a9c2d4c2 2020-09-24 stsp ret="$?"
346 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
347 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
348 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
349 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
350 a9c2d4c2 2020-09-24 stsp return 1
351 a9c2d4c2 2020-09-24 stsp fi
352 a9c2d4c2 2020-09-24 stsp
353 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
354 a9c2d4c2 2020-09-24 stsp [core]
355 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
356 a9c2d4c2 2020-09-24 stsp filemode = true
357 a9c2d4c2 2020-09-24 stsp bare = true
358 a9c2d4c2 2020-09-24 stsp
359 a9c2d4c2 2020-09-24 stsp [remote "origin"]
360 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
361 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
362 a9c2d4c2 2020-09-24 stsp mirror = true
363 a9c2d4c2 2020-09-24 stsp EOF
364 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
365 a9c2d4c2 2020-09-24 stsp ret="$?"
366 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
367 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
368 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
369 a9c2d4c2 2020-09-24 stsp fi
370 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
371 c8c71e6e 2020-03-21 stsp }
372 c8c71e6e 2020-03-21 stsp
373 f6cae3ed 2020-09-13 naddy test_clone_mirror_all() {
374 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror_all`
375 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
376 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
377 c8c71e6e 2020-03-21 stsp
378 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
379 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
380 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
381 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
382 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
383 c8c71e6e 2020-03-21 stsp
384 c8c71e6e 2020-03-21 stsp got clone -q -m -a $testurl/repo $testroot/repo-clone
385 c8c71e6e 2020-03-21 stsp ret="$?"
386 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
387 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
388 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
389 c8c71e6e 2020-03-21 stsp return 1
390 c8c71e6e 2020-03-21 stsp fi
391 c8c71e6e 2020-03-21 stsp
392 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
393 c8c71e6e 2020-03-21 stsp
394 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
395 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
396 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
397 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
398 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
399 c8c71e6e 2020-03-21 stsp
400 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
401 c8c71e6e 2020-03-21 stsp ret="$?"
402 c8c71e6e 2020-03-21 stsp if [ "$ret" != "0" ]; then
403 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
405 a9c2d4c2 2020-09-24 stsp return 1
406 c8c71e6e 2020-03-21 stsp fi
407 a9c2d4c2 2020-09-24 stsp
408 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
409 a9c2d4c2 2020-09-24 stsp remote "origin" {
410 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
411 a9c2d4c2 2020-09-24 stsp protocol ssh
412 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
413 a9c2d4c2 2020-09-24 stsp mirror-references yes
414 a9c2d4c2 2020-09-24 stsp }
415 a9c2d4c2 2020-09-24 stsp EOF
416 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
417 a9c2d4c2 2020-09-24 stsp ret="$?"
418 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
419 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
420 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
421 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
422 a9c2d4c2 2020-09-24 stsp return 1
423 a9c2d4c2 2020-09-24 stsp fi
424 a9c2d4c2 2020-09-24 stsp
425 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
426 a9c2d4c2 2020-09-24 stsp [core]
427 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
428 a9c2d4c2 2020-09-24 stsp filemode = true
429 a9c2d4c2 2020-09-24 stsp bare = true
430 a9c2d4c2 2020-09-24 stsp
431 a9c2d4c2 2020-09-24 stsp [remote "origin"]
432 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
433 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
434 a9c2d4c2 2020-09-24 stsp mirror = true
435 a9c2d4c2 2020-09-24 stsp EOF
436 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
437 a9c2d4c2 2020-09-24 stsp ret="$?"
438 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
439 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
440 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
441 a9c2d4c2 2020-09-24 stsp fi
442 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
443 c8c71e6e 2020-03-21 stsp }
444 0e4002ca 2020-03-21 stsp
445 f6cae3ed 2020-09-13 naddy test_clone_reference() {
446 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
447 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
448 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
449 c8c71e6e 2020-03-21 stsp
450 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
451 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
452 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
453 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
454 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
455 0e4002ca 2020-03-21 stsp
456 0e4002ca 2020-03-21 stsp got clone -q -R hoo $testurl/repo $testroot/repo-clone
457 0e4002ca 2020-03-21 stsp ret="$?"
458 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
459 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
460 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
461 0e4002ca 2020-03-21 stsp return 1
462 0e4002ca 2020-03-21 stsp fi
463 0e4002ca 2020-03-21 stsp
464 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
465 0e4002ca 2020-03-21 stsp
466 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
467 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
468 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
469 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
470 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
471 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
472 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
473 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
474 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
475 0e4002ca 2020-03-21 stsp
476 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
477 0e4002ca 2020-03-21 stsp ret="$?"
478 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
479 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
481 a9c2d4c2 2020-09-24 stsp return 1
482 0e4002ca 2020-03-21 stsp fi
483 a9c2d4c2 2020-09-24 stsp
484 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
485 a9c2d4c2 2020-09-24 stsp remote "origin" {
486 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
487 a9c2d4c2 2020-09-24 stsp protocol ssh
488 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
489 a9c2d4c2 2020-09-24 stsp }
490 a9c2d4c2 2020-09-24 stsp EOF
491 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
492 a9c2d4c2 2020-09-24 stsp ret="$?"
493 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
494 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
495 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
496 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
497 a9c2d4c2 2020-09-24 stsp return 1
498 a9c2d4c2 2020-09-24 stsp fi
499 a9c2d4c2 2020-09-24 stsp
500 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
501 a9c2d4c2 2020-09-24 stsp [core]
502 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
503 a9c2d4c2 2020-09-24 stsp filemode = true
504 a9c2d4c2 2020-09-24 stsp bare = true
505 a9c2d4c2 2020-09-24 stsp
506 a9c2d4c2 2020-09-24 stsp [remote "origin"]
507 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
508 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/master:refs/remotes/origin/master
509 a9c2d4c2 2020-09-24 stsp EOF
510 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
511 a9c2d4c2 2020-09-24 stsp ret="$?"
512 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
513 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
514 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
515 a9c2d4c2 2020-09-24 stsp fi
516 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
517 0e4002ca 2020-03-21 stsp }
518 0e4002ca 2020-03-21 stsp
519 f6cae3ed 2020-09-13 naddy test_clone_branch_and_reference() {
520 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
521 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
522 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
523 0e4002ca 2020-03-21 stsp
524 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
525 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
526 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
527 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
528 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
529 0e4002ca 2020-03-21 stsp
530 0e4002ca 2020-03-21 stsp got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
531 0e4002ca 2020-03-21 stsp ret="$?"
532 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
533 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
534 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
535 0e4002ca 2020-03-21 stsp return 1
536 0e4002ca 2020-03-21 stsp fi
537 0e4002ca 2020-03-21 stsp
538 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
539 0e4002ca 2020-03-21 stsp
540 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
541 0e4002ca 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
542 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
543 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
544 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
545 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
546 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
547 0e4002ca 2020-03-21 stsp
548 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
549 0e4002ca 2020-03-21 stsp ret="$?"
550 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
551 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
552 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
553 a9c2d4c2 2020-09-24 stsp return 1
554 0e4002ca 2020-03-21 stsp fi
555 a9c2d4c2 2020-09-24 stsp
556 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
557 a9c2d4c2 2020-09-24 stsp remote "origin" {
558 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
559 a9c2d4c2 2020-09-24 stsp protocol ssh
560 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
561 a9c2d4c2 2020-09-24 stsp }
562 a9c2d4c2 2020-09-24 stsp EOF
563 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
564 a9c2d4c2 2020-09-24 stsp ret="$?"
565 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
566 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
567 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
568 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
569 a9c2d4c2 2020-09-24 stsp return 1
570 a9c2d4c2 2020-09-24 stsp fi
571 a9c2d4c2 2020-09-24 stsp
572 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
573 a9c2d4c2 2020-09-24 stsp [core]
574 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
575 a9c2d4c2 2020-09-24 stsp filemode = true
576 a9c2d4c2 2020-09-24 stsp bare = true
577 a9c2d4c2 2020-09-24 stsp
578 a9c2d4c2 2020-09-24 stsp [remote "origin"]
579 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
580 a9c2d4c2 2020-09-24 stsp fetch = +refs/heads/foo:refs/remotes/origin/foo
581 a9c2d4c2 2020-09-24 stsp EOF
582 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
583 a9c2d4c2 2020-09-24 stsp ret="$?"
584 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
585 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
586 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
587 a9c2d4c2 2020-09-24 stsp fi
588 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
589 0e4002ca 2020-03-21 stsp }
590 0e4002ca 2020-03-21 stsp
591 f6cae3ed 2020-09-13 naddy test_clone_reference_mirror() {
592 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference_mirror`
593 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
594 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
595 0e4002ca 2020-03-21 stsp
596 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
597 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
598 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
599 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
600 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
601 0e4002ca 2020-03-21 stsp
602 0e4002ca 2020-03-21 stsp got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
603 0e4002ca 2020-03-21 stsp ret="$?"
604 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
605 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
606 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
607 0e4002ca 2020-03-21 stsp return 1
608 0e4002ca 2020-03-21 stsp fi
609 0e4002ca 2020-03-21 stsp
610 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
611 0e4002ca 2020-03-21 stsp
612 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
613 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
614 0e4002ca 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
615 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
616 0e4002ca 2020-03-21 stsp
617 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
618 0e4002ca 2020-03-21 stsp ret="$?"
619 0e4002ca 2020-03-21 stsp if [ "$ret" != "0" ]; then
620 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
622 a9c2d4c2 2020-09-24 stsp return 1
623 0e4002ca 2020-03-21 stsp fi
624 a9c2d4c2 2020-09-24 stsp
625 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
626 a9c2d4c2 2020-09-24 stsp remote "origin" {
627 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
628 a9c2d4c2 2020-09-24 stsp protocol ssh
629 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
630 a9c2d4c2 2020-09-24 stsp mirror-references yes
631 a9c2d4c2 2020-09-24 stsp }
632 a9c2d4c2 2020-09-24 stsp EOF
633 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
634 a9c2d4c2 2020-09-24 stsp ret="$?"
635 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
636 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
637 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
638 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
639 a9c2d4c2 2020-09-24 stsp return 1
640 a9c2d4c2 2020-09-24 stsp fi
641 a9c2d4c2 2020-09-24 stsp
642 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
643 a9c2d4c2 2020-09-24 stsp [core]
644 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
645 a9c2d4c2 2020-09-24 stsp filemode = true
646 a9c2d4c2 2020-09-24 stsp bare = true
647 a9c2d4c2 2020-09-24 stsp
648 a9c2d4c2 2020-09-24 stsp [remote "origin"]
649 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
650 a9c2d4c2 2020-09-24 stsp fetch = +refs/*:refs/*
651 a9c2d4c2 2020-09-24 stsp mirror = true
652 a9c2d4c2 2020-09-24 stsp EOF
653 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
654 a9c2d4c2 2020-09-24 stsp ret="$?"
655 a9c2d4c2 2020-09-24 stsp if [ "$ret" != "0" ]; then
656 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
657 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
658 a9c2d4c2 2020-09-24 stsp fi
659 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
660 0e4002ca 2020-03-21 stsp }
661 0e4002ca 2020-03-21 stsp
662 7fb414ae 2020-08-08 stsp test_parseargs "$@"
663 c8c71e6e 2020-03-21 stsp run_test test_clone_basic
664 c8c71e6e 2020-03-21 stsp run_test test_clone_list
665 c8c71e6e 2020-03-21 stsp run_test test_clone_branch
666 c8c71e6e 2020-03-21 stsp run_test test_clone_all
667 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror
668 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror_all
669 0e4002ca 2020-03-21 stsp run_test test_clone_reference
670 0e4002ca 2020-03-21 stsp run_test test_clone_branch_and_reference
671 0e4002ca 2020-03-21 stsp run_test test_clone_reference_mirror