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