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 49c543a6 2022-03-31 naddy ret=$?
26 49c543a6 2022-03-31 naddy if [ $ret -ne 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 84246752 2022-06-03 op ret=$?
34 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
35 c8c71e6e 2020-03-21 stsp echo "got log command failed unexpectedly" >&2
36 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
37 c8c71e6e 2020-03-21 stsp return 1
38 c8c71e6e 2020-03-21 stsp fi
39 8c9ae19c 2023-03-10 op got log -l0 -p -r $testroot/repo-clone | \
40 8c9ae19c 2023-03-10 op sed 's@master, origin/master@master@g' \
41 8c9ae19c 2023-03-10 op > $testroot/log-repo-clone
42 8c9ae19c 2023-03-10 op
43 c8c71e6e 2020-03-21 stsp cmp -s $testroot/log-repo $testroot/log-repo-clone
44 49c543a6 2022-03-31 naddy ret=$?
45 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
46 c8c71e6e 2020-03-21 stsp echo "log -p output of cloned repository differs" >&2
47 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
48 c8c71e6e 2020-03-21 stsp return 1
49 c8c71e6e 2020-03-21 stsp fi
50 c8c71e6e 2020-03-21 stsp
51 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo > $testroot/stdout
52 84246752 2022-06-03 op ret=$?
53 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
64 49c543a6 2022-03-31 naddy if [ $ret -ne 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 84246752 2022-06-03 op ret=$?
72 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
73 c8c71e6e 2020-03-21 stsp echo "got ref command failed unexpectedly" >&2
74 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
75 c8c71e6e 2020-03-21 stsp return 1
76 c8c71e6e 2020-03-21 stsp fi
77 c8c71e6e 2020-03-21 stsp
78 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
79 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
80 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
81 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
82 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
83 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
84 c8c71e6e 2020-03-21 stsp
85 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
86 49c543a6 2022-03-31 naddy ret=$?
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
89 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
90 a9c2d4c2 2020-09-24 stsp return 1
91 c8c71e6e 2020-03-21 stsp fi
92 a9c2d4c2 2020-09-24 stsp
93 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
94 a9c2d4c2 2020-09-24 stsp remote "origin" {
95 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
96 a9c2d4c2 2020-09-24 stsp protocol ssh
97 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
98 15d3c221 2021-01-05 stsp branch { "master" }
99 a9c2d4c2 2020-09-24 stsp }
100 a9c2d4c2 2020-09-24 stsp EOF
101 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
102 49c543a6 2022-03-31 naddy ret=$?
103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
104 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
105 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
106 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
107 a9c2d4c2 2020-09-24 stsp return 1
108 a9c2d4c2 2020-09-24 stsp fi
109 a9c2d4c2 2020-09-24 stsp
110 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
111 a9c2d4c2 2020-09-24 stsp [core]
112 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
113 a9c2d4c2 2020-09-24 stsp filemode = true
114 a9c2d4c2 2020-09-24 stsp bare = true
115 a9c2d4c2 2020-09-24 stsp
116 a9c2d4c2 2020-09-24 stsp [remote "origin"]
117 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
118 56d0a753 2021-01-20 stsp fetch = refs/heads/master:refs/remotes/origin/master
119 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
120 a9c2d4c2 2020-09-24 stsp EOF
121 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
122 49c543a6 2022-03-31 naddy ret=$?
123 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
124 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
125 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
126 a9c2d4c2 2020-09-24 stsp fi
127 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
128 c8c71e6e 2020-03-21 stsp }
129 c8c71e6e 2020-03-21 stsp
130 6cc8a118 2023-03-10 op test_clone_quoting() {
131 6cc8a118 2023-03-10 op local testroot=`test_init clone_basic`
132 6cc8a118 2023-03-10 op
133 6cc8a118 2023-03-10 op got log -l0 -p -r "$testroot/repo" > $testroot/log-repo
134 6cc8a118 2023-03-10 op
135 6cc8a118 2023-03-10 op (cd "$testroot" && cp -R repo "rock'n roll.git")
136 6cc8a118 2023-03-10 op
137 6cc8a118 2023-03-10 op got clone -q "ssh://127.0.0.1/$testroot/rock'n roll.git" \
138 6cc8a118 2023-03-10 op "$testroot/rock-clone"
139 6cc8a118 2023-03-10 op ret=$?
140 6cc8a118 2023-03-10 op if [ $ret -ne 0 ]; then
141 6cc8a118 2023-03-10 op echo "got clone failed unexpectedly" >&2
142 6cc8a118 2023-03-10 op test_done "$testroot" "$ret"
143 6cc8a118 2023-03-10 op return 1
144 6cc8a118 2023-03-10 op fi
145 6cc8a118 2023-03-10 op
146 6cc8a118 2023-03-10 op got log -l0 -p -r "$testroot/rock-clone" | \
147 6cc8a118 2023-03-10 op sed 's@master, origin/master@master@g' \
148 6cc8a118 2023-03-10 op >$testroot/log-repo-clone
149 6cc8a118 2023-03-10 op
150 6cc8a118 2023-03-10 op cmp -s "$testroot/log-repo" "$testroot/log-repo-clone"
151 6cc8a118 2023-03-10 op ret=$?
152 6cc8a118 2023-03-10 op if [ $ret -ne 0 ]; then
153 6cc8a118 2023-03-10 op echo "log -p output of cloned repository differs" >&2
154 6cc8a118 2023-03-10 op diff -u "$testroot/log-repo" "$testroot/log-repo-clone"
155 6cc8a118 2023-03-10 op test_done "$testroot" "$ret"
156 6cc8a118 2023-03-10 op fi
157 6cc8a118 2023-03-10 op test_done "$testroot" "$ret"
158 6cc8a118 2023-03-10 op }
159 6cc8a118 2023-03-10 op
160 f6cae3ed 2020-09-13 naddy test_clone_list() {
161 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_list`
162 0deb9607 2022-11-18 op local testurl=ssh://127.0.0.1$testroot
163 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
164 c8c71e6e 2020-03-21 stsp
165 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
166 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
167 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
168 c8c71e6e 2020-03-21 stsp
169 c8c71e6e 2020-03-21 stsp got clone -l $testurl/repo > $testroot/stdout 2>$testroot/stderr
170 49c543a6 2022-03-31 naddy ret=$?
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
173 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
174 c8c71e6e 2020-03-21 stsp return 1
175 c8c71e6e 2020-03-21 stsp fi
176 c8c71e6e 2020-03-21 stsp
177 0deb9607 2022-11-18 op echo "Connecting to $testurl/repo" > $testroot/stdout.expected
178 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo >> $testroot/stdout.expected
179 c8c71e6e 2020-03-21 stsp
180 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
181 49c543a6 2022-03-31 naddy ret=$?
182 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
183 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
184 c8c71e6e 2020-03-21 stsp fi
185 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
186 c8c71e6e 2020-03-21 stsp }
187 c8c71e6e 2020-03-21 stsp
188 f6cae3ed 2020-09-13 naddy test_clone_branch() {
189 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_branch`
190 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
191 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
192 c8c71e6e 2020-03-21 stsp
193 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
194 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
195 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
196 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
197 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
198 c8c71e6e 2020-03-21 stsp
199 c8c71e6e 2020-03-21 stsp got clone -q -b foo $testurl/repo $testroot/repo-clone
200 49c543a6 2022-03-31 naddy ret=$?
201 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
202 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
203 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
204 c8c71e6e 2020-03-21 stsp return 1
205 c8c71e6e 2020-03-21 stsp fi
206 c8c71e6e 2020-03-21 stsp
207 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
208 c8c71e6e 2020-03-21 stsp
209 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
210 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
211 c8c71e6e 2020-03-21 stsp # refs/heads/master is missing because it wasn't passed via -b
212 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
213 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
214 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
215 c8c71e6e 2020-03-21 stsp
216 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
217 49c543a6 2022-03-31 naddy ret=$?
218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
219 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
221 a9c2d4c2 2020-09-24 stsp return 1
222 c8c71e6e 2020-03-21 stsp fi
223 a9c2d4c2 2020-09-24 stsp
224 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
225 a9c2d4c2 2020-09-24 stsp remote "origin" {
226 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
227 a9c2d4c2 2020-09-24 stsp protocol ssh
228 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
229 15d3c221 2021-01-05 stsp branch { "foo" }
230 a9c2d4c2 2020-09-24 stsp }
231 a9c2d4c2 2020-09-24 stsp EOF
232 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
233 49c543a6 2022-03-31 naddy ret=$?
234 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
235 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
236 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
237 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
238 a9c2d4c2 2020-09-24 stsp return 1
239 a9c2d4c2 2020-09-24 stsp fi
240 a9c2d4c2 2020-09-24 stsp
241 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
242 a9c2d4c2 2020-09-24 stsp [core]
243 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
244 a9c2d4c2 2020-09-24 stsp filemode = true
245 a9c2d4c2 2020-09-24 stsp bare = true
246 a9c2d4c2 2020-09-24 stsp
247 a9c2d4c2 2020-09-24 stsp [remote "origin"]
248 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
249 56d0a753 2021-01-20 stsp fetch = refs/heads/foo:refs/remotes/origin/foo
250 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
251 a9c2d4c2 2020-09-24 stsp EOF
252 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
253 49c543a6 2022-03-31 naddy ret=$?
254 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
255 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
256 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
257 a9c2d4c2 2020-09-24 stsp fi
258 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
259 c8c71e6e 2020-03-21 stsp }
260 c8c71e6e 2020-03-21 stsp
261 f6cae3ed 2020-09-13 naddy test_clone_all() {
262 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_all`
263 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
264 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
265 c8c71e6e 2020-03-21 stsp
266 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
267 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
268 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
269 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
270 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
271 c8c71e6e 2020-03-21 stsp
272 c8c71e6e 2020-03-21 stsp got clone -q -a $testurl/repo $testroot/repo-clone
273 49c543a6 2022-03-31 naddy ret=$?
274 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
275 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
276 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
277 c8c71e6e 2020-03-21 stsp return 1
278 c8c71e6e 2020-03-21 stsp fi
279 c8c71e6e 2020-03-21 stsp
280 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
281 c8c71e6e 2020-03-21 stsp
282 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
283 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
284 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
285 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
286 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
287 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
288 c8c71e6e 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
289 c8c71e6e 2020-03-21 stsp >> $testroot/stdout.expected
290 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
291 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
292 c8c71e6e 2020-03-21 stsp
293 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
294 49c543a6 2022-03-31 naddy ret=$?
295 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
296 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
297 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
298 a9c2d4c2 2020-09-24 stsp return 1
299 c8c71e6e 2020-03-21 stsp fi
300 a9c2d4c2 2020-09-24 stsp
301 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
302 a9c2d4c2 2020-09-24 stsp remote "origin" {
303 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
304 a9c2d4c2 2020-09-24 stsp protocol ssh
305 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
306 f1bf60d1 2022-07-03 stsp fetch_all_branches yes
307 a9c2d4c2 2020-09-24 stsp }
308 a9c2d4c2 2020-09-24 stsp EOF
309 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
310 49c543a6 2022-03-31 naddy ret=$?
311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
312 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
313 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
314 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
315 a9c2d4c2 2020-09-24 stsp return 1
316 a9c2d4c2 2020-09-24 stsp fi
317 a9c2d4c2 2020-09-24 stsp
318 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
319 a9c2d4c2 2020-09-24 stsp [core]
320 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
321 a9c2d4c2 2020-09-24 stsp filemode = true
322 a9c2d4c2 2020-09-24 stsp bare = true
323 a9c2d4c2 2020-09-24 stsp
324 a9c2d4c2 2020-09-24 stsp [remote "origin"]
325 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
326 56d0a753 2021-01-20 stsp fetch = refs/heads/*:refs/remotes/origin/*
327 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
328 a9c2d4c2 2020-09-24 stsp EOF
329 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
330 49c543a6 2022-03-31 naddy ret=$?
331 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
332 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
333 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
334 a9c2d4c2 2020-09-24 stsp fi
335 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
336 c8c71e6e 2020-03-21 stsp }
337 c8c71e6e 2020-03-21 stsp
338 f6cae3ed 2020-09-13 naddy test_clone_mirror() {
339 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror`
340 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
341 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
342 c8c71e6e 2020-03-21 stsp
343 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
344 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
345 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
346 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
347 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
348 c8c71e6e 2020-03-21 stsp
349 c8c71e6e 2020-03-21 stsp got clone -q -m $testurl/repo $testroot/repo-clone
350 49c543a6 2022-03-31 naddy ret=$?
351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
352 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
353 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
354 c8c71e6e 2020-03-21 stsp return 1
355 c8c71e6e 2020-03-21 stsp fi
356 c8c71e6e 2020-03-21 stsp
357 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
358 c8c71e6e 2020-03-21 stsp
359 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
360 c8c71e6e 2020-03-21 stsp # refs/heads/foo is missing because we're not fetching all branches
361 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
362 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
363 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
364 c8c71e6e 2020-03-21 stsp
365 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
366 49c543a6 2022-03-31 naddy ret=$?
367 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
368 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
369 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
370 a9c2d4c2 2020-09-24 stsp return 1
371 c8c71e6e 2020-03-21 stsp fi
372 a9c2d4c2 2020-09-24 stsp
373 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
374 a9c2d4c2 2020-09-24 stsp remote "origin" {
375 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
376 a9c2d4c2 2020-09-24 stsp protocol ssh
377 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
378 15d3c221 2021-01-05 stsp branch { "master" }
379 26e6f38e 2022-07-03 stsp mirror_references yes
380 a9c2d4c2 2020-09-24 stsp }
381 a9c2d4c2 2020-09-24 stsp EOF
382 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
383 49c543a6 2022-03-31 naddy ret=$?
384 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
385 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
386 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
387 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
388 a9c2d4c2 2020-09-24 stsp return 1
389 a9c2d4c2 2020-09-24 stsp fi
390 a9c2d4c2 2020-09-24 stsp
391 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
392 a9c2d4c2 2020-09-24 stsp [core]
393 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
394 a9c2d4c2 2020-09-24 stsp filemode = true
395 a9c2d4c2 2020-09-24 stsp bare = true
396 a9c2d4c2 2020-09-24 stsp
397 a9c2d4c2 2020-09-24 stsp [remote "origin"]
398 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
399 56d0a753 2021-01-20 stsp fetch = refs/heads/master:refs/heads/master
400 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
401 a9c2d4c2 2020-09-24 stsp EOF
402 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
403 49c543a6 2022-03-31 naddy ret=$?
404 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
405 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
406 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
407 a9c2d4c2 2020-09-24 stsp fi
408 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
409 c8c71e6e 2020-03-21 stsp }
410 c8c71e6e 2020-03-21 stsp
411 f6cae3ed 2020-09-13 naddy test_clone_mirror_all() {
412 c8c71e6e 2020-03-21 stsp local testroot=`test_init clone_mirror_all`
413 c8c71e6e 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
414 c8c71e6e 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
415 c8c71e6e 2020-03-21 stsp
416 c8c71e6e 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
417 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
418 c8c71e6e 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
419 c8c71e6e 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
420 c8c71e6e 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
421 c8c71e6e 2020-03-21 stsp
422 c8c71e6e 2020-03-21 stsp got clone -q -m -a $testurl/repo $testroot/repo-clone
423 49c543a6 2022-03-31 naddy ret=$?
424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
425 c8c71e6e 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
426 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
427 c8c71e6e 2020-03-21 stsp return 1
428 c8c71e6e 2020-03-21 stsp fi
429 c8c71e6e 2020-03-21 stsp
430 c8c71e6e 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
431 c8c71e6e 2020-03-21 stsp
432 c8c71e6e 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
433 c8c71e6e 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
434 c8c71e6e 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
435 c8c71e6e 2020-03-21 stsp # refs/hoo/boo/zoo is missing because it is outside of refs/heads
436 c8c71e6e 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
437 c8c71e6e 2020-03-21 stsp
438 c8c71e6e 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
439 49c543a6 2022-03-31 naddy ret=$?
440 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
441 c8c71e6e 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
442 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
443 a9c2d4c2 2020-09-24 stsp return 1
444 c8c71e6e 2020-03-21 stsp fi
445 a9c2d4c2 2020-09-24 stsp
446 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
447 a9c2d4c2 2020-09-24 stsp remote "origin" {
448 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
449 a9c2d4c2 2020-09-24 stsp protocol ssh
450 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
451 26e6f38e 2022-07-03 stsp mirror_references yes
452 f1bf60d1 2022-07-03 stsp fetch_all_branches yes
453 a9c2d4c2 2020-09-24 stsp }
454 a9c2d4c2 2020-09-24 stsp EOF
455 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
456 49c543a6 2022-03-31 naddy ret=$?
457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
458 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
459 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
460 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
461 a9c2d4c2 2020-09-24 stsp return 1
462 a9c2d4c2 2020-09-24 stsp fi
463 a9c2d4c2 2020-09-24 stsp
464 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
465 a9c2d4c2 2020-09-24 stsp [core]
466 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
467 a9c2d4c2 2020-09-24 stsp filemode = true
468 a9c2d4c2 2020-09-24 stsp bare = true
469 a9c2d4c2 2020-09-24 stsp
470 a9c2d4c2 2020-09-24 stsp [remote "origin"]
471 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
472 56d0a753 2021-01-20 stsp fetch = refs/heads/*:refs/heads/*
473 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
474 a9c2d4c2 2020-09-24 stsp EOF
475 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
476 49c543a6 2022-03-31 naddy ret=$?
477 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
478 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
479 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
480 a9c2d4c2 2020-09-24 stsp fi
481 c8c71e6e 2020-03-21 stsp test_done "$testroot" "$ret"
482 c8c71e6e 2020-03-21 stsp }
483 0e4002ca 2020-03-21 stsp
484 f6cae3ed 2020-09-13 naddy test_clone_reference() {
485 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
486 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
487 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
488 c8c71e6e 2020-03-21 stsp
489 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
490 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
491 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
492 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
493 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
494 0e4002ca 2020-03-21 stsp
495 0e4002ca 2020-03-21 stsp got clone -q -R hoo $testurl/repo $testroot/repo-clone
496 49c543a6 2022-03-31 naddy ret=$?
497 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
498 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
499 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
500 0e4002ca 2020-03-21 stsp return 1
501 0e4002ca 2020-03-21 stsp fi
502 0e4002ca 2020-03-21 stsp
503 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
504 0e4002ca 2020-03-21 stsp
505 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
506 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
507 f298ae0f 2020-03-25 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
508 f298ae0f 2020-03-25 stsp >> $testroot/stdout.expected
509 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
510 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
511 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/master: $commit_id" \
512 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
513 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
514 0e4002ca 2020-03-21 stsp
515 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
516 49c543a6 2022-03-31 naddy ret=$?
517 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
518 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
519 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
520 a9c2d4c2 2020-09-24 stsp return 1
521 0e4002ca 2020-03-21 stsp fi
522 a9c2d4c2 2020-09-24 stsp
523 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
524 a9c2d4c2 2020-09-24 stsp remote "origin" {
525 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
526 a9c2d4c2 2020-09-24 stsp protocol ssh
527 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
528 15d3c221 2021-01-05 stsp branch { "master" }
529 99495ddb 2021-01-10 stsp reference { "hoo" }
530 a9c2d4c2 2020-09-24 stsp }
531 a9c2d4c2 2020-09-24 stsp EOF
532 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
533 49c543a6 2022-03-31 naddy ret=$?
534 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
535 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
536 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
537 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
538 a9c2d4c2 2020-09-24 stsp return 1
539 a9c2d4c2 2020-09-24 stsp fi
540 a9c2d4c2 2020-09-24 stsp
541 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
542 a9c2d4c2 2020-09-24 stsp [core]
543 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
544 a9c2d4c2 2020-09-24 stsp filemode = true
545 a9c2d4c2 2020-09-24 stsp bare = true
546 a9c2d4c2 2020-09-24 stsp
547 a9c2d4c2 2020-09-24 stsp [remote "origin"]
548 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
549 56d0a753 2021-01-20 stsp fetch = refs/heads/master:refs/remotes/origin/master
550 56d0a753 2021-01-20 stsp fetch = refs/hoo:refs/remotes/origin/hoo
551 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
552 a9c2d4c2 2020-09-24 stsp EOF
553 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
554 49c543a6 2022-03-31 naddy ret=$?
555 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
556 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
557 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
558 a9c2d4c2 2020-09-24 stsp fi
559 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
560 0e4002ca 2020-03-21 stsp }
561 0e4002ca 2020-03-21 stsp
562 f6cae3ed 2020-09-13 naddy test_clone_branch_and_reference() {
563 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference`
564 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
565 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
566 0e4002ca 2020-03-21 stsp
567 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
568 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
569 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
570 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
571 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
572 0e4002ca 2020-03-21 stsp
573 0e4002ca 2020-03-21 stsp got clone -q -R hoo/boo/zoo -b foo $testurl/repo $testroot/repo-clone
574 49c543a6 2022-03-31 naddy ret=$?
575 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
576 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
577 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
578 0e4002ca 2020-03-21 stsp return 1
579 0e4002ca 2020-03-21 stsp fi
580 0e4002ca 2020-03-21 stsp
581 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
582 0e4002ca 2020-03-21 stsp
583 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
584 0e4002ca 2020-03-21 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
585 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/foo: $commit_id" \
586 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
587 0e4002ca 2020-03-21 stsp echo "refs/remotes/origin/hoo/boo/zoo: $commit_id" \
588 0e4002ca 2020-03-21 stsp >> $testroot/stdout.expected
589 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
590 0e4002ca 2020-03-21 stsp
591 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
592 49c543a6 2022-03-31 naddy ret=$?
593 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
594 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
595 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
596 a9c2d4c2 2020-09-24 stsp return 1
597 0e4002ca 2020-03-21 stsp fi
598 a9c2d4c2 2020-09-24 stsp
599 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
600 a9c2d4c2 2020-09-24 stsp remote "origin" {
601 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
602 a9c2d4c2 2020-09-24 stsp protocol ssh
603 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
604 15d3c221 2021-01-05 stsp branch { "foo" }
605 99495ddb 2021-01-10 stsp reference { "hoo/boo/zoo" }
606 a9c2d4c2 2020-09-24 stsp }
607 a9c2d4c2 2020-09-24 stsp EOF
608 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
609 49c543a6 2022-03-31 naddy ret=$?
610 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
611 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
612 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
613 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
614 a9c2d4c2 2020-09-24 stsp return 1
615 a9c2d4c2 2020-09-24 stsp fi
616 a9c2d4c2 2020-09-24 stsp
617 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
618 a9c2d4c2 2020-09-24 stsp [core]
619 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
620 a9c2d4c2 2020-09-24 stsp filemode = true
621 a9c2d4c2 2020-09-24 stsp bare = true
622 a9c2d4c2 2020-09-24 stsp
623 a9c2d4c2 2020-09-24 stsp [remote "origin"]
624 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
625 56d0a753 2021-01-20 stsp fetch = refs/heads/foo:refs/remotes/origin/foo
626 56d0a753 2021-01-20 stsp fetch = refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
627 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
628 a9c2d4c2 2020-09-24 stsp EOF
629 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
630 49c543a6 2022-03-31 naddy ret=$?
631 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
632 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
633 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
634 a9c2d4c2 2020-09-24 stsp fi
635 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
636 0e4002ca 2020-03-21 stsp }
637 0e4002ca 2020-03-21 stsp
638 f6cae3ed 2020-09-13 naddy test_clone_reference_mirror() {
639 0e4002ca 2020-03-21 stsp local testroot=`test_init clone_reference_mirror`
640 0e4002ca 2020-03-21 stsp local testurl=ssh://127.0.0.1/$testroot
641 0e4002ca 2020-03-21 stsp local commit_id=`git_show_head $testroot/repo`
642 0e4002ca 2020-03-21 stsp
643 0e4002ca 2020-03-21 stsp got branch -r $testroot/repo -c $commit_id foo
644 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c $commit_id refs/hoo/boo/zoo
645 0e4002ca 2020-03-21 stsp got tag -r $testroot/repo -c $commit_id -m tag "1.0" >/dev/null
646 0e4002ca 2020-03-21 stsp local tag_id=`got ref -r $testroot/repo -l \
647 0e4002ca 2020-03-21 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
648 0e4002ca 2020-03-21 stsp
649 0e4002ca 2020-03-21 stsp got clone -q -R hoo -m $testurl/repo $testroot/repo-clone
650 49c543a6 2022-03-31 naddy ret=$?
651 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
652 0e4002ca 2020-03-21 stsp echo "got clone command failed unexpectedly" >&2
653 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
654 0e4002ca 2020-03-21 stsp return 1
655 0e4002ca 2020-03-21 stsp fi
656 0e4002ca 2020-03-21 stsp
657 0e4002ca 2020-03-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
658 0e4002ca 2020-03-21 stsp
659 0e4002ca 2020-03-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
660 0e4002ca 2020-03-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
661 0e4002ca 2020-03-21 stsp echo "refs/hoo/boo/zoo: $commit_id" >> $testroot/stdout.expected
662 0e4002ca 2020-03-21 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
663 0e4002ca 2020-03-21 stsp
664 0e4002ca 2020-03-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
665 49c543a6 2022-03-31 naddy ret=$?
666 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
667 0e4002ca 2020-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
668 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
669 a9c2d4c2 2020-09-24 stsp return 1
670 0e4002ca 2020-03-21 stsp fi
671 a9c2d4c2 2020-09-24 stsp
672 a9c2d4c2 2020-09-24 stsp cat > $testroot/got.conf.expected <<EOF
673 a9c2d4c2 2020-09-24 stsp remote "origin" {
674 a9c2d4c2 2020-09-24 stsp server 127.0.0.1
675 a9c2d4c2 2020-09-24 stsp protocol ssh
676 a9c2d4c2 2020-09-24 stsp repository "$testroot/repo"
677 15d3c221 2021-01-05 stsp branch { "master" }
678 99495ddb 2021-01-10 stsp reference { "hoo" }
679 26e6f38e 2022-07-03 stsp mirror_references yes
680 a9c2d4c2 2020-09-24 stsp }
681 a9c2d4c2 2020-09-24 stsp EOF
682 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
683 49c543a6 2022-03-31 naddy ret=$?
684 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
685 a9c2d4c2 2020-09-24 stsp diff -u $testroot/got.conf.expected \
686 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/got.conf
687 a9c2d4c2 2020-09-24 stsp test_done "$testroot" "$ret"
688 a9c2d4c2 2020-09-24 stsp return 1
689 a9c2d4c2 2020-09-24 stsp fi
690 a9c2d4c2 2020-09-24 stsp
691 a9c2d4c2 2020-09-24 stsp cat > $testroot/config.expected <<EOF
692 a9c2d4c2 2020-09-24 stsp [core]
693 a9c2d4c2 2020-09-24 stsp repositoryformatversion = 0
694 a9c2d4c2 2020-09-24 stsp filemode = true
695 a9c2d4c2 2020-09-24 stsp bare = true
696 a9c2d4c2 2020-09-24 stsp
697 a9c2d4c2 2020-09-24 stsp [remote "origin"]
698 a9c2d4c2 2020-09-24 stsp url = ssh://127.0.0.1$testroot/repo
699 56d0a753 2021-01-20 stsp fetch = refs/heads/master:refs/heads/master
700 56d0a753 2021-01-20 stsp fetch = refs/hoo:refs/hoo
701 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
702 132af4a5 2021-01-05 stsp EOF
703 132af4a5 2021-01-05 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
704 49c543a6 2022-03-31 naddy ret=$?
705 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
706 132af4a5 2021-01-05 stsp diff -u $testroot/config.expected \
707 132af4a5 2021-01-05 stsp $testroot/repo-clone/config
708 132af4a5 2021-01-05 stsp fi
709 132af4a5 2021-01-05 stsp test_done "$testroot" "$ret"
710 132af4a5 2021-01-05 stsp }
711 132af4a5 2021-01-05 stsp
712 132af4a5 2021-01-05 stsp test_clone_multiple_branches() {
713 132af4a5 2021-01-05 stsp local testroot=`test_init clone_multiple_branches`
714 132af4a5 2021-01-05 stsp local testurl=ssh://127.0.0.1/$testroot
715 132af4a5 2021-01-05 stsp local commit_id=`git_show_head $testroot/repo`
716 132af4a5 2021-01-05 stsp
717 132af4a5 2021-01-05 stsp got branch -r $testroot/repo -c $commit_id foo
718 132af4a5 2021-01-05 stsp got branch -r $testroot/repo -c $commit_id bar
719 132af4a5 2021-01-05 stsp
720 132af4a5 2021-01-05 stsp got clone -q -b foo -b bar $testurl/repo $testroot/repo-clone
721 49c543a6 2022-03-31 naddy ret=$?
722 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
723 132af4a5 2021-01-05 stsp echo "got clone command failed unexpectedly" >&2
724 132af4a5 2021-01-05 stsp test_done "$testroot" "$ret"
725 132af4a5 2021-01-05 stsp return 1
726 132af4a5 2021-01-05 stsp fi
727 132af4a5 2021-01-05 stsp
728 132af4a5 2021-01-05 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
729 132af4a5 2021-01-05 stsp
730 132af4a5 2021-01-05 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
731 132af4a5 2021-01-05 stsp echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
732 132af4a5 2021-01-05 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
733 132af4a5 2021-01-05 stsp echo "refs/remotes/origin/bar: $commit_id" \
734 132af4a5 2021-01-05 stsp >> $testroot/stdout.expected
735 132af4a5 2021-01-05 stsp echo "refs/remotes/origin/foo: $commit_id" \
736 132af4a5 2021-01-05 stsp >> $testroot/stdout.expected
737 132af4a5 2021-01-05 stsp
738 132af4a5 2021-01-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
739 49c543a6 2022-03-31 naddy ret=$?
740 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
741 132af4a5 2021-01-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
742 132af4a5 2021-01-05 stsp test_done "$testroot" "$ret"
743 132af4a5 2021-01-05 stsp return 1
744 132af4a5 2021-01-05 stsp fi
745 132af4a5 2021-01-05 stsp
746 132af4a5 2021-01-05 stsp cat > $testroot/got.conf.expected <<EOF
747 132af4a5 2021-01-05 stsp remote "origin" {
748 132af4a5 2021-01-05 stsp server 127.0.0.1
749 132af4a5 2021-01-05 stsp protocol ssh
750 132af4a5 2021-01-05 stsp repository "$testroot/repo"
751 132af4a5 2021-01-05 stsp branch { "foo" "bar" }
752 132af4a5 2021-01-05 stsp }
753 a9c2d4c2 2020-09-24 stsp EOF
754 132af4a5 2021-01-05 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
755 49c543a6 2022-03-31 naddy ret=$?
756 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
757 132af4a5 2021-01-05 stsp diff -u $testroot/got.conf.expected \
758 132af4a5 2021-01-05 stsp $testroot/repo-clone/got.conf
759 132af4a5 2021-01-05 stsp test_done "$testroot" "$ret"
760 132af4a5 2021-01-05 stsp return 1
761 132af4a5 2021-01-05 stsp fi
762 132af4a5 2021-01-05 stsp
763 132af4a5 2021-01-05 stsp cat > $testroot/config.expected <<EOF
764 132af4a5 2021-01-05 stsp [core]
765 132af4a5 2021-01-05 stsp repositoryformatversion = 0
766 132af4a5 2021-01-05 stsp filemode = true
767 132af4a5 2021-01-05 stsp bare = true
768 132af4a5 2021-01-05 stsp
769 132af4a5 2021-01-05 stsp [remote "origin"]
770 132af4a5 2021-01-05 stsp url = ssh://127.0.0.1$testroot/repo
771 56d0a753 2021-01-20 stsp fetch = refs/heads/foo:refs/remotes/origin/foo
772 56d0a753 2021-01-20 stsp fetch = refs/heads/bar:refs/remotes/origin/bar
773 c9f1ac46 2022-11-08 stsp fetch = refs/tags/*:refs/tags/*
774 c9f1ac46 2022-11-08 stsp EOF
775 c9f1ac46 2022-11-08 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
776 c9f1ac46 2022-11-08 stsp ret=$?
777 c9f1ac46 2022-11-08 stsp if [ $ret -ne 0 ]; then
778 c9f1ac46 2022-11-08 stsp diff -u $testroot/config.expected \
779 c9f1ac46 2022-11-08 stsp $testroot/repo-clone/config
780 c9f1ac46 2022-11-08 stsp fi
781 c9f1ac46 2022-11-08 stsp test_done "$testroot" "$ret"
782 c9f1ac46 2022-11-08 stsp }
783 c9f1ac46 2022-11-08 stsp
784 c9f1ac46 2022-11-08 stsp test_clone_dangling_headref() {
785 c9f1ac46 2022-11-08 stsp local testroot=`test_init clone_dangling_headref`
786 c9f1ac46 2022-11-08 stsp local testurl=ssh://127.0.0.1/$testroot
787 c9f1ac46 2022-11-08 stsp local commit_id=`git_show_head $testroot/repo`
788 c9f1ac46 2022-11-08 stsp
789 c9f1ac46 2022-11-08 stsp got branch -r $testroot/repo -d master > /dev/null
790 c9f1ac46 2022-11-08 stsp got branch -r $testroot/repo -c $commit_id foo
791 c9f1ac46 2022-11-08 stsp
792 c9f1ac46 2022-11-08 stsp got ref -l -r $testroot/repo > $testroot/stdout
793 c9f1ac46 2022-11-08 stsp
794 c9f1ac46 2022-11-08 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
795 c9f1ac46 2022-11-08 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
796 c9f1ac46 2022-11-08 stsp # refs/heads/master is missing because it was deleted above
797 c9f1ac46 2022-11-08 stsp
798 c9f1ac46 2022-11-08 stsp cmp -s $testroot/stdout $testroot/stdout.expected
799 c9f1ac46 2022-11-08 stsp ret=$?
800 c9f1ac46 2022-11-08 stsp if [ $ret -ne 0 ]; then
801 c9f1ac46 2022-11-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
802 c9f1ac46 2022-11-08 stsp test_done "$testroot" "$ret"
803 c9f1ac46 2022-11-08 stsp return 1
804 c9f1ac46 2022-11-08 stsp fi
805 c9f1ac46 2022-11-08 stsp
806 c9f1ac46 2022-11-08 stsp got clone -q -b foo $testurl/repo $testroot/repo-clone
807 c9f1ac46 2022-11-08 stsp ret=$?
808 c9f1ac46 2022-11-08 stsp if [ $ret -ne 0 ]; then
809 c9f1ac46 2022-11-08 stsp echo "got clone command failed unexpectedly" >&2
810 c9f1ac46 2022-11-08 stsp test_done "$testroot" "$ret"
811 c9f1ac46 2022-11-08 stsp return 1
812 c9f1ac46 2022-11-08 stsp fi
813 c9f1ac46 2022-11-08 stsp
814 c9f1ac46 2022-11-08 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
815 c9f1ac46 2022-11-08 stsp
816 c9f1ac46 2022-11-08 stsp echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
817 c9f1ac46 2022-11-08 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
818 c9f1ac46 2022-11-08 stsp echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
819 c9f1ac46 2022-11-08 stsp
820 c9f1ac46 2022-11-08 stsp cmp -s $testroot/stdout $testroot/stdout.expected
821 c9f1ac46 2022-11-08 stsp ret=$?
822 c9f1ac46 2022-11-08 stsp if [ $ret -ne 0 ]; then
823 c9f1ac46 2022-11-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
824 c9f1ac46 2022-11-08 stsp test_done "$testroot" "$ret"
825 c9f1ac46 2022-11-08 stsp return 1
826 c9f1ac46 2022-11-08 stsp fi
827 c9f1ac46 2022-11-08 stsp
828 c9f1ac46 2022-11-08 stsp cat > $testroot/got.conf.expected <<EOF
829 c9f1ac46 2022-11-08 stsp remote "origin" {
830 c9f1ac46 2022-11-08 stsp server 127.0.0.1
831 c9f1ac46 2022-11-08 stsp protocol ssh
832 c9f1ac46 2022-11-08 stsp repository "$testroot/repo"
833 c9f1ac46 2022-11-08 stsp branch { "foo" }
834 c9f1ac46 2022-11-08 stsp }
835 c9f1ac46 2022-11-08 stsp EOF
836 c9f1ac46 2022-11-08 stsp cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
837 c9f1ac46 2022-11-08 stsp ret=$?
838 c9f1ac46 2022-11-08 stsp if [ $ret -ne 0 ]; then
839 c9f1ac46 2022-11-08 stsp diff -u $testroot/got.conf.expected \
840 c9f1ac46 2022-11-08 stsp $testroot/repo-clone/got.conf
841 c9f1ac46 2022-11-08 stsp test_done "$testroot" "$ret"
842 c9f1ac46 2022-11-08 stsp return 1
843 c9f1ac46 2022-11-08 stsp fi
844 c9f1ac46 2022-11-08 stsp
845 c9f1ac46 2022-11-08 stsp cat > $testroot/config.expected <<EOF
846 c9f1ac46 2022-11-08 stsp [core]
847 c9f1ac46 2022-11-08 stsp repositoryformatversion = 0
848 c9f1ac46 2022-11-08 stsp filemode = true
849 c9f1ac46 2022-11-08 stsp bare = true
850 c9f1ac46 2022-11-08 stsp
851 c9f1ac46 2022-11-08 stsp [remote "origin"]
852 c9f1ac46 2022-11-08 stsp url = ssh://127.0.0.1$testroot/repo
853 c9f1ac46 2022-11-08 stsp fetch = refs/heads/foo:refs/remotes/origin/foo
854 56d0a753 2021-01-20 stsp fetch = refs/tags/*:refs/tags/*
855 132af4a5 2021-01-05 stsp EOF
856 a9c2d4c2 2020-09-24 stsp cmp -s $testroot/repo-clone/config $testroot/config.expected
857 49c543a6 2022-03-31 naddy ret=$?
858 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
859 a9c2d4c2 2020-09-24 stsp diff -u $testroot/config.expected \
860 a9c2d4c2 2020-09-24 stsp $testroot/repo-clone/config
861 a9c2d4c2 2020-09-24 stsp fi
862 0e4002ca 2020-03-21 stsp test_done "$testroot" "$ret"
863 0e4002ca 2020-03-21 stsp }
864 0e4002ca 2020-03-21 stsp
865 7fb414ae 2020-08-08 stsp test_parseargs "$@"
866 c8c71e6e 2020-03-21 stsp run_test test_clone_basic
867 6cc8a118 2023-03-10 op run_test test_clone_quoting
868 c8c71e6e 2020-03-21 stsp run_test test_clone_list
869 c8c71e6e 2020-03-21 stsp run_test test_clone_branch
870 c8c71e6e 2020-03-21 stsp run_test test_clone_all
871 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror
872 c8c71e6e 2020-03-21 stsp run_test test_clone_mirror_all
873 0e4002ca 2020-03-21 stsp run_test test_clone_reference
874 0e4002ca 2020-03-21 stsp run_test test_clone_branch_and_reference
875 0e4002ca 2020-03-21 stsp run_test test_clone_reference_mirror
876 132af4a5 2021-01-05 stsp run_test test_clone_multiple_branches
877 c9f1ac46 2022-11-08 stsp run_test test_clone_dangling_headref