Blame


1 f8a36e22 2021-08-26 stsp #!/bin/sh
2 f8a36e22 2021-08-26 stsp #
3 f8a36e22 2021-08-26 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 f8a36e22 2021-08-26 stsp #
5 f8a36e22 2021-08-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp # copyright notice and this permission notice appear in all copies.
8 f8a36e22 2021-08-26 stsp #
9 f8a36e22 2021-08-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f8a36e22 2021-08-26 stsp
17 f8a36e22 2021-08-26 stsp . ./common.sh
18 f8a36e22 2021-08-26 stsp
19 f8a36e22 2021-08-26 stsp test_send_basic() {
20 f8a36e22 2021-08-26 stsp local testroot=`test_init send_basic`
21 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
22 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
23 f8a36e22 2021-08-26 stsp
24 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
25 fc414659 2022-04-16 thomas ret=$?
26 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
27 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
28 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
29 f8a36e22 2021-08-26 stsp return 1
30 f8a36e22 2021-08-26 stsp fi
31 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
32 f8a36e22 2021-08-26 stsp remote "origin" {
33 f8a36e22 2021-08-26 stsp protocol ssh
34 f8a36e22 2021-08-26 stsp server 127.0.0.1
35 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
36 f8a36e22 2021-08-26 stsp }
37 f8a36e22 2021-08-26 stsp EOF
38 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
41 f8a36e22 2021-08-26 stsp
42 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
43 08511b5e 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
44 08511b5e 2021-09-24 thomas (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
45 08511b5e 2021-09-24 thomas echo "new file alpha" > $testroot/repo/new
46 08511b5e 2021-09-24 thomas (cd $testroot/repo && git add new)
47 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
48 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
49 f8a36e22 2021-08-26 stsp
50 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
51 fc414659 2022-04-16 thomas ret=$?
52 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
53 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
54 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
55 f8a36e22 2021-08-26 stsp return 1
56 f8a36e22 2021-08-26 stsp fi
57 f8a36e22 2021-08-26 stsp
58 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
59 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
60 fc414659 2022-04-16 thomas ret=$?
61 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
62 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
63 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
64 f8a36e22 2021-08-26 stsp return 1
65 f8a36e22 2021-08-26 stsp fi
66 f8a36e22 2021-08-26 stsp
67 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
68 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
69 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
70 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
71 f8a36e22 2021-08-26 stsp return 1
72 f8a36e22 2021-08-26 stsp fi
73 f8a36e22 2021-08-26 stsp
74 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
75 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
76 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
77 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
78 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
79 f8a36e22 2021-08-26 stsp
80 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
81 fc414659 2022-04-16 thomas ret=$?
82 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
83 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
84 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
85 f8a36e22 2021-08-26 stsp return 1
86 f8a36e22 2021-08-26 stsp fi
87 f8a36e22 2021-08-26 stsp
88 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
89 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
90 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
91 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
92 f8a36e22 2021-08-26 stsp return 1
93 f8a36e22 2021-08-26 stsp fi
94 f8a36e22 2021-08-26 stsp
95 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
96 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
97 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
98 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
100 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
101 08511b5e 2021-09-24 thomas
102 08511b5e 2021-09-24 thomas cmp -s $testroot/stdout $testroot/stdout.expected
103 fc414659 2022-04-16 thomas ret=$?
104 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
105 08511b5e 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
106 08511b5e 2021-09-24 thomas test_done "$testroot" "$ret"
107 08511b5e 2021-09-24 thomas return 1
108 08511b5e 2021-09-24 thomas fi
109 f8a36e22 2021-08-26 stsp
110 08511b5e 2021-09-24 thomas got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
111 08511b5e 2021-09-24 thomas > $testroot/stdout
112 08511b5e 2021-09-24 thomas got tree -r $testroot/repo -c $commit_id2 -i -R \
113 08511b5e 2021-09-24 thomas > $testroot/stdout.expected
114 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
115 fc414659 2022-04-16 thomas ret=$?
116 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
117 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
118 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
119 f8a36e22 2021-08-26 stsp return 1
120 f8a36e22 2021-08-26 stsp fi
121 f8a36e22 2021-08-26 stsp
122 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
123 fc414659 2022-04-16 thomas ret=$?
124 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
125 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
126 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
127 f8a36e22 2021-08-26 stsp return 1
128 f8a36e22 2021-08-26 stsp fi
129 f8a36e22 2021-08-26 stsp
130 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
131 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
132 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
133 fc414659 2022-04-16 thomas ret=$?
134 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
135 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
136 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
137 f0fd0aaf 2021-09-14 stsp return 1
138 f8a36e22 2021-08-26 stsp fi
139 f0fd0aaf 2021-09-14 stsp
140 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
141 fc414659 2022-04-16 thomas ret=$?
142 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
143 f8a36e22 2021-08-26 stsp }
144 f8a36e22 2021-08-26 stsp
145 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
146 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
147 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
148 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
149 f8a36e22 2021-08-26 stsp
150 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
151 fc414659 2022-04-16 thomas ret=$?
152 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
153 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
154 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
155 f8a36e22 2021-08-26 stsp return 1
156 f8a36e22 2021-08-26 stsp fi
157 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
158 f8a36e22 2021-08-26 stsp remote "origin" {
159 f8a36e22 2021-08-26 stsp protocol ssh
160 f8a36e22 2021-08-26 stsp server 127.0.0.1
161 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
162 f8a36e22 2021-08-26 stsp }
163 f8a36e22 2021-08-26 stsp EOF
164 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
165 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
166 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
167 f8a36e22 2021-08-26 stsp
168 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
169 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
170 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
171 f8a36e22 2021-08-26 stsp
172 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
173 fc414659 2022-04-16 thomas ret=$?
174 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
175 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
176 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
177 f8a36e22 2021-08-26 stsp return 1
178 f8a36e22 2021-08-26 stsp fi
179 f8a36e22 2021-08-26 stsp
180 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
181 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
182 fc414659 2022-04-16 thomas ret=$?
183 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
184 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
185 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
186 f8a36e22 2021-08-26 stsp return 1
187 f8a36e22 2021-08-26 stsp fi
188 f8a36e22 2021-08-26 stsp
189 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
190 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
191 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
192 fc414659 2022-04-16 thomas ret=$?
193 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
194 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
196 f0fd0aaf 2021-09-14 stsp return 1
197 f8a36e22 2021-08-26 stsp fi
198 f0fd0aaf 2021-09-14 stsp
199 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
200 fc414659 2022-04-16 thomas ret=$?
201 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
202 f8a36e22 2021-08-26 stsp }
203 f8a36e22 2021-08-26 stsp
204 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
205 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
206 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
207 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
208 f8a36e22 2021-08-26 stsp
209 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
210 fc414659 2022-04-16 thomas ret=$?
211 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
212 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
213 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
214 f8a36e22 2021-08-26 stsp return 1
215 f8a36e22 2021-08-26 stsp fi
216 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
217 f8a36e22 2021-08-26 stsp remote "foobar" {
218 f8a36e22 2021-08-26 stsp protocol ssh
219 f8a36e22 2021-08-26 stsp server 127.0.0.1
220 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
221 f8a36e22 2021-08-26 stsp }
222 f8a36e22 2021-08-26 stsp EOF
223 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
224 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
225 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
226 f8a36e22 2021-08-26 stsp
227 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
228 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
229 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
230 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
231 f8a36e22 2021-08-26 stsp
232 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
233 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
234 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
235 fc414659 2022-04-16 thomas ret=$?
236 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
237 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
238 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
239 f8a36e22 2021-08-26 stsp return 1
240 f8a36e22 2021-08-26 stsp fi
241 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
242 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
243 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
244 fc414659 2022-04-16 thomas ret=$?
245 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
246 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
247 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
248 f8a36e22 2021-08-26 stsp return 1
249 f8a36e22 2021-08-26 stsp fi
250 f8a36e22 2021-08-26 stsp
251 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
252 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
253 fc414659 2022-04-16 thomas ret=$?
254 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
255 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
256 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
257 f8a36e22 2021-08-26 stsp return 1
258 f8a36e22 2021-08-26 stsp fi
259 f8a36e22 2021-08-26 stsp
260 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
261 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
262 fc414659 2022-04-16 thomas ret=$?
263 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
264 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
266 f8a36e22 2021-08-26 stsp return 1
267 f8a36e22 2021-08-26 stsp fi
268 f8a36e22 2021-08-26 stsp
269 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
270 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
271 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
272 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
273 f8a36e22 2021-08-26 stsp return 1
274 f8a36e22 2021-08-26 stsp fi
275 f8a36e22 2021-08-26 stsp
276 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
277 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
278 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
279 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
280 f8a36e22 2021-08-26 stsp
281 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
282 fc414659 2022-04-16 thomas ret=$?
283 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
284 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
286 f8a36e22 2021-08-26 stsp return 1
287 f8a36e22 2021-08-26 stsp fi
288 f8a36e22 2021-08-26 stsp
289 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
290 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
291 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
292 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
293 f8a36e22 2021-08-26 stsp return 1
294 f8a36e22 2021-08-26 stsp fi
295 f8a36e22 2021-08-26 stsp
296 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
297 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
298 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
299 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
300 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
301 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
302 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
303 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
304 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
305 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
306 f8a36e22 2021-08-26 stsp
307 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
308 fc414659 2022-04-16 thomas ret=$?
309 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
310 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
311 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
312 f0fd0aaf 2021-09-14 stsp return 1
313 f8a36e22 2021-08-26 stsp fi
314 f0fd0aaf 2021-09-14 stsp
315 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
316 fc414659 2022-04-16 thomas ret=$?
317 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
318 f8a36e22 2021-08-26 stsp }
319 f8a36e22 2021-08-26 stsp
320 f8a36e22 2021-08-26 stsp test_send_delete() {
321 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
322 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
323 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
324 f8a36e22 2021-08-26 stsp
325 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
326 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
327 f8a36e22 2021-08-26 stsp
328 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
329 fc414659 2022-04-16 thomas ret=$?
330 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
331 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
332 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
333 f8a36e22 2021-08-26 stsp return 1
334 f8a36e22 2021-08-26 stsp fi
335 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
336 f8a36e22 2021-08-26 stsp remote "origin" {
337 f8a36e22 2021-08-26 stsp protocol ssh
338 f8a36e22 2021-08-26 stsp server 127.0.0.1
339 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
340 f8a36e22 2021-08-26 stsp }
341 f8a36e22 2021-08-26 stsp EOF
342 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
343 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
344 f8a36e22 2021-08-26 stsp
345 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
346 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
347 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
348 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
349 f8a36e22 2021-08-26 stsp return 1
350 f8a36e22 2021-08-26 stsp fi
351 f8a36e22 2021-08-26 stsp
352 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
353 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
354 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
355 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
356 f8a36e22 2021-08-26 stsp
357 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
358 f8a36e22 2021-08-26 stsp # time is not allowed.
359 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
360 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
361 fc414659 2022-04-16 thomas ret=$?
362 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
363 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
364 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
365 f8a36e22 2021-08-26 stsp return 1
366 f8a36e22 2021-08-26 stsp fi
367 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
368 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
369 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
370 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
371 fc414659 2022-04-16 thomas ret=$?
372 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
373 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
374 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
375 f8a36e22 2021-08-26 stsp return 1
376 f8a36e22 2021-08-26 stsp fi
377 f8a36e22 2021-08-26 stsp
378 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
379 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
380 fc414659 2022-04-16 thomas ret=$?
381 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
382 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
383 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
384 f8a36e22 2021-08-26 stsp return 1
385 f8a36e22 2021-08-26 stsp fi
386 f8a36e22 2021-08-26 stsp
387 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
388 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
389 fc414659 2022-04-16 thomas ret=$?
390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
391 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
392 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
393 1bd76734 2021-08-26 stsp return 1
394 1bd76734 2021-08-26 stsp fi
395 1bd76734 2021-08-26 stsp
396 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
397 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
398 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
399 1bd76734 2021-08-26 stsp
400 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
401 fc414659 2022-04-16 thomas ret=$?
402 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
403 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
405 f8a36e22 2021-08-26 stsp return 1
406 f8a36e22 2021-08-26 stsp fi
407 f8a36e22 2021-08-26 stsp
408 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
409 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
410 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
411 fc414659 2022-04-16 thomas ret=$?
412 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
413 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
414 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
415 f8a36e22 2021-08-26 stsp return 1
416 f8a36e22 2021-08-26 stsp fi
417 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
418 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
419 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
420 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
421 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
422 fc414659 2022-04-16 thomas ret=$?
423 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
424 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
425 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
426 f8a36e22 2021-08-26 stsp return 1
427 f8a36e22 2021-08-26 stsp fi
428 f8a36e22 2021-08-26 stsp
429 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
430 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
431 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
432 fc414659 2022-04-16 thomas ret=$?
433 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
434 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
435 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
436 f8a36e22 2021-08-26 stsp return 1
437 f8a36e22 2021-08-26 stsp fi
438 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
439 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
440 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
441 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
442 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
443 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
444 fc414659 2022-04-16 thomas ret=$?
445 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
446 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
447 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
448 f8a36e22 2021-08-26 stsp return 1
449 f8a36e22 2021-08-26 stsp fi
450 f8a36e22 2021-08-26 stsp
451 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
452 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
453 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
454 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
455 f8a36e22 2021-08-26 stsp return 1
456 f8a36e22 2021-08-26 stsp fi
457 f8a36e22 2021-08-26 stsp
458 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
459 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
460 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
461 f8a36e22 2021-08-26 stsp
462 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
463 fc414659 2022-04-16 thomas ret=$?
464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
465 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
467 f8a36e22 2021-08-26 stsp return 1
468 f8a36e22 2021-08-26 stsp fi
469 f8a36e22 2021-08-26 stsp
470 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
471 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
472 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
473 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
474 f8a36e22 2021-08-26 stsp return 1
475 f8a36e22 2021-08-26 stsp fi
476 f8a36e22 2021-08-26 stsp
477 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
478 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
479 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
480 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
481 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
482 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
483 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
484 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
485 f8a36e22 2021-08-26 stsp
486 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
487 fc414659 2022-04-16 thomas ret=$?
488 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
489 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
490 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
491 f0fd0aaf 2021-09-14 stsp return 1
492 f8a36e22 2021-08-26 stsp fi
493 f0fd0aaf 2021-09-14 stsp
494 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
495 fc414659 2022-04-16 thomas ret=$?
496 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
497 f8a36e22 2021-08-26 stsp }
498 f8a36e22 2021-08-26 stsp
499 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
500 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
501 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
502 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
503 f8a36e22 2021-08-26 stsp
504 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
505 f8a36e22 2021-08-26 stsp
506 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
507 fc414659 2022-04-16 thomas ret=$?
508 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
509 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
510 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
511 f8a36e22 2021-08-26 stsp return 1
512 f8a36e22 2021-08-26 stsp fi
513 f8a36e22 2021-08-26 stsp
514 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
515 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
516 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
517 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
518 f8a36e22 2021-08-26 stsp
519 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
520 fc414659 2022-04-16 thomas ret=$?
521 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
522 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
523 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
524 f8a36e22 2021-08-26 stsp return 1
525 f8a36e22 2021-08-26 stsp fi
526 f8a36e22 2021-08-26 stsp
527 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
529 fc414659 2022-04-16 thomas ret=$?
530 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
531 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
532 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
533 f8a36e22 2021-08-26 stsp return 1
534 f8a36e22 2021-08-26 stsp fi
535 f8a36e22 2021-08-26 stsp
536 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
537 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
538 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
539 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
540 f8a36e22 2021-08-26 stsp return 1
541 f8a36e22 2021-08-26 stsp fi
542 f8a36e22 2021-08-26 stsp
543 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
544 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
545 f8a36e22 2021-08-26 stsp
546 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
547 fc414659 2022-04-16 thomas ret=$?
548 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
549 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
550 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
551 f8a36e22 2021-08-26 stsp return 1
552 f8a36e22 2021-08-26 stsp fi
553 f8a36e22 2021-08-26 stsp
554 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
555 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
556 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
557 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
558 f8a36e22 2021-08-26 stsp return 1
559 f8a36e22 2021-08-26 stsp fi
560 f8a36e22 2021-08-26 stsp
561 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
562 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
563 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
564 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
565 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
566 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
567 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
568 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
569 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
570 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
571 f8a36e22 2021-08-26 stsp
572 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
573 fc414659 2022-04-16 thomas ret=$?
574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
575 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
577 f0fd0aaf 2021-09-14 stsp return 1
578 f8a36e22 2021-08-26 stsp fi
579 f0fd0aaf 2021-09-14 stsp
580 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
581 fc414659 2022-04-16 thomas ret=$?
582 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
583 f8a36e22 2021-08-26 stsp }
584 f8a36e22 2021-08-26 stsp
585 f8a36e22 2021-08-26 stsp test_send_tags() {
586 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
587 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
588 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
589 f8a36e22 2021-08-26 stsp
590 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
591 fc414659 2022-04-16 thomas ret=$?
592 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
593 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
594 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
595 f8a36e22 2021-08-26 stsp return 1
596 f8a36e22 2021-08-26 stsp fi
597 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
598 f8a36e22 2021-08-26 stsp remote "origin" {
599 f8a36e22 2021-08-26 stsp protocol ssh
600 f8a36e22 2021-08-26 stsp server 127.0.0.1
601 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
602 f8a36e22 2021-08-26 stsp }
603 f8a36e22 2021-08-26 stsp EOF
604 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
605 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
606 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
607 f8a36e22 2021-08-26 stsp
608 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
609 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
610 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
611 f8a36e22 2021-08-26 stsp
612 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
613 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
614 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
615 f8a36e22 2021-08-26 stsp
616 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
617 fc414659 2022-04-16 thomas ret=$?
618 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
619 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
620 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
621 f8a36e22 2021-08-26 stsp return 1
622 f8a36e22 2021-08-26 stsp fi
623 f8a36e22 2021-08-26 stsp
624 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
625 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
626 fc414659 2022-04-16 thomas ret=$?
627 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
628 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
630 f8a36e22 2021-08-26 stsp return 1
631 f8a36e22 2021-08-26 stsp fi
632 f8a36e22 2021-08-26 stsp
633 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
634 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
635 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
636 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
637 f8a36e22 2021-08-26 stsp return 1
638 f8a36e22 2021-08-26 stsp fi
639 f8a36e22 2021-08-26 stsp
640 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
641 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
642 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
643 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
644 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
645 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
646 f8a36e22 2021-08-26 stsp
647 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
648 fc414659 2022-04-16 thomas ret=$?
649 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
650 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
651 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
652 f8a36e22 2021-08-26 stsp return 1
653 f8a36e22 2021-08-26 stsp fi
654 f8a36e22 2021-08-26 stsp
655 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
656 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
657 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
658 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
659 f8a36e22 2021-08-26 stsp return 1
660 f8a36e22 2021-08-26 stsp fi
661 f8a36e22 2021-08-26 stsp
662 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
663 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
664 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
665 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
666 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
667 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
668 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
669 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
670 f8a36e22 2021-08-26 stsp
671 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
672 fc414659 2022-04-16 thomas ret=$?
673 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
674 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
675 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
676 f8a36e22 2021-08-26 stsp return 1
677 f8a36e22 2021-08-26 stsp fi
678 f8a36e22 2021-08-26 stsp
679 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
680 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
681 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
682 4064588e 2021-10-17 thomas cmp -s $testroot/stdout $testroot/stdout.expected
683 fc414659 2022-04-16 thomas ret=$?
684 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
685 4064588e 2021-10-17 thomas diff -u $testroot/stdout.expected $testroot/stdout
686 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
687 4064588e 2021-10-17 thomas return 1
688 4064588e 2021-10-17 thomas fi
689 4064588e 2021-10-17 thomas
690 4064588e 2021-10-17 thomas # Send the same tags again. This should be a no-op.
691 4064588e 2021-10-17 thomas got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
692 fc414659 2022-04-16 thomas ret=$?
693 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
694 4064588e 2021-10-17 thomas echo "got send command failed unexpectedly" >&2
695 4064588e 2021-10-17 thomas test_done "$testroot" "$ret"
696 4064588e 2021-10-17 thomas return 1
697 4064588e 2021-10-17 thomas fi
698 4064588e 2021-10-17 thomas
699 4064588e 2021-10-17 thomas echo -n > $testroot/stdout.expected
700 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
701 fc414659 2022-04-16 thomas ret=$?
702 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
703 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
704 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
705 f8a36e22 2021-08-26 stsp return 1
706 f8a36e22 2021-08-26 stsp fi
707 f8a36e22 2021-08-26 stsp
708 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
709 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
710 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
711 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
712 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
713 f8a36e22 2021-08-26 stsp
714 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
715 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
716 fc414659 2022-04-16 thomas ret=$?
717 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
718 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
719 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
720 f8a36e22 2021-08-26 stsp return 1
721 f8a36e22 2021-08-26 stsp fi
722 f8a36e22 2021-08-26 stsp
723 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
724 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
725 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
726 fc414659 2022-04-16 thomas ret=$?
727 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
728 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
729 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
730 f8a36e22 2021-08-26 stsp return 1
731 f8a36e22 2021-08-26 stsp fi
732 f8a36e22 2021-08-26 stsp
733 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
734 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
735 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
736 fc414659 2022-04-16 thomas ret=$?
737 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
738 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
739 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
740 f8a36e22 2021-08-26 stsp return 1
741 f8a36e22 2021-08-26 stsp fi
742 f8a36e22 2021-08-26 stsp
743 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
744 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
745 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
746 fc414659 2022-04-16 thomas ret=$?
747 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
748 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
749 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
750 f8a36e22 2021-08-26 stsp return 1
751 f8a36e22 2021-08-26 stsp fi
752 f8a36e22 2021-08-26 stsp
753 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
754 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
755 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
756 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
757 fc414659 2022-04-16 thomas ret=$?
758 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
759 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
760 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
761 f8a36e22 2021-08-26 stsp return 1
762 f8a36e22 2021-08-26 stsp fi
763 f8a36e22 2021-08-26 stsp
764 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
765 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
766 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
767 fc414659 2022-04-16 thomas ret=$?
768 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
769 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
770 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
771 f8a36e22 2021-08-26 stsp return 1
772 f8a36e22 2021-08-26 stsp fi
773 f8a36e22 2021-08-26 stsp
774 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
775 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
776 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
777 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
778 fc414659 2022-04-16 thomas ret=$?
779 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
780 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
781 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
782 c2105d00 2021-09-14 stsp return 1
783 f8a36e22 2021-08-26 stsp fi
784 c2105d00 2021-09-14 stsp
785 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
786 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
787 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
788 c2105d00 2021-09-14 stsp
789 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
790 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
791 c2105d00 2021-09-14 stsp 2> $testroot/stderr
792 fc414659 2022-04-16 thomas ret=$?
793 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
794 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
795 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
796 c2105d00 2021-09-14 stsp return 1
797 c2105d00 2021-09-14 stsp fi
798 c2105d00 2021-09-14 stsp
799 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
800 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
801 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
802 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
803 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
804 c2105d00 2021-09-14 stsp
805 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
806 c2105d00 2021-09-14 stsp 2> $testroot/stderr
807 fc414659 2022-04-16 thomas ret=$?
808 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
809 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
810 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
811 c2105d00 2021-09-14 stsp return 1
812 c2105d00 2021-09-14 stsp fi
813 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
814 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
815 c2105d00 2021-09-14 stsp $testroot/stdout; then
816 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
817 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
818 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
819 c2105d00 2021-09-14 stsp return 1
820 c2105d00 2021-09-14 stsp fi
821 f0fd0aaf 2021-09-14 stsp
822 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
823 fc414659 2022-04-16 thomas ret=$?
824 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
825 f8a36e22 2021-08-26 stsp }
826 f8a36e22 2021-08-26 stsp
827 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
828 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
829 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
830 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
831 26960ff7 2021-09-14 stsp
832 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
833 fc414659 2022-04-16 thomas ret=$?
834 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
835 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
836 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
837 26960ff7 2021-09-14 stsp return 1
838 26960ff7 2021-09-14 stsp fi
839 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
840 26960ff7 2021-09-14 stsp remote "origin" {
841 26960ff7 2021-09-14 stsp protocol ssh
842 26960ff7 2021-09-14 stsp server 127.0.0.1
843 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
844 26960ff7 2021-09-14 stsp }
845 26960ff7 2021-09-14 stsp EOF
846 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
847 26960ff7 2021-09-14 stsp
848 13eb256c 2022-05-31 thomas # modify beta on branch foo
849 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
850 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
851 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
852 13eb256c 2022-05-31 thomas > /dev/null)
853 13eb256c 2022-05-31 thomas echo buu >> $testroot/wt/beta
854 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
855 26960ff7 2021-09-14 stsp > /dev/null)
856 13eb256c 2022-05-31 thomas echo baa >> $testroot/wt/beta
857 13eb256c 2022-05-31 thomas (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
858 13eb256c 2022-05-31 thomas > /dev/null)
859 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
860 26960ff7 2021-09-14 stsp
861 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
862 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
863 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
864 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
865 26960ff7 2021-09-14 stsp
866 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
867 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
868 26960ff7 2021-09-14 stsp
869 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
870 26960ff7 2021-09-14 stsp # and the tag
871 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
872 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
873 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
874 26960ff7 2021-09-14 stsp
875 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
876 fc414659 2022-04-16 thomas ret=$?
877 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
878 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
879 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
880 26960ff7 2021-09-14 stsp return 1
881 26960ff7 2021-09-14 stsp fi
882 26960ff7 2021-09-14 stsp
883 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
884 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
885 fc414659 2022-04-16 thomas ret=$?
886 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
887 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
888 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
889 26960ff7 2021-09-14 stsp return 1
890 26960ff7 2021-09-14 stsp fi
891 26960ff7 2021-09-14 stsp
892 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
893 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
894 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
895 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
896 26960ff7 2021-09-14 stsp return 1
897 26960ff7 2021-09-14 stsp fi
898 26960ff7 2021-09-14 stsp
899 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
900 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
901 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
902 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
903 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
904 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
905 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
906 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
907 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
908 26960ff7 2021-09-14 stsp
909 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
910 fc414659 2022-04-16 thomas ret=$?
911 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
912 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
913 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
914 26960ff7 2021-09-14 stsp return 1
915 26960ff7 2021-09-14 stsp fi
916 26960ff7 2021-09-14 stsp
917 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
918 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
919 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
920 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
921 26960ff7 2021-09-14 stsp return 1
922 26960ff7 2021-09-14 stsp fi
923 26960ff7 2021-09-14 stsp
924 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
925 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
926 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
927 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
928 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
929 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
930 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
931 26960ff7 2021-09-14 stsp
932 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
933 fc414659 2022-04-16 thomas ret=$?
934 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
935 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
936 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
937 26960ff7 2021-09-14 stsp return 1
938 26960ff7 2021-09-14 stsp fi
939 26960ff7 2021-09-14 stsp
940 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
941 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
942 26960ff7 2021-09-14 stsp
943 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
944 fc414659 2022-04-16 thomas ret=$?
945 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
946 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
947 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
948 f0fd0aaf 2021-09-14 stsp return 1
949 26960ff7 2021-09-14 stsp fi
950 f0fd0aaf 2021-09-14 stsp
951 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
952 fc414659 2022-04-16 thomas ret=$?
953 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
954 26960ff7 2021-09-14 stsp }
955 26960ff7 2021-09-14 stsp
956 f8a36e22 2021-08-26 stsp test_send_new_branch() {
957 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
958 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
959 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
960 f8a36e22 2021-08-26 stsp
961 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
962 f8a36e22 2021-08-26 stsp
963 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
964 fc414659 2022-04-16 thomas ret=$?
965 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
966 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
967 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
968 f8a36e22 2021-08-26 stsp return 1
969 f8a36e22 2021-08-26 stsp fi
970 f8a36e22 2021-08-26 stsp
971 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
972 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
973 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
974 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
975 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
976 f8a36e22 2021-08-26 stsp
977 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
978 fc414659 2022-04-16 thomas ret=$?
979 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
980 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
981 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
982 f8a36e22 2021-08-26 stsp return 1
983 f8a36e22 2021-08-26 stsp fi
984 f8a36e22 2021-08-26 stsp
985 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
986 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
987 fc414659 2022-04-16 thomas ret=$?
988 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
989 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
990 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
991 f8a36e22 2021-08-26 stsp return 1
992 f8a36e22 2021-08-26 stsp fi
993 f8a36e22 2021-08-26 stsp
994 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
995 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
996 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
997 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
998 f8a36e22 2021-08-26 stsp return 1
999 f8a36e22 2021-08-26 stsp fi
1000 f8a36e22 2021-08-26 stsp
1001 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1002 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1003 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1004 f8a36e22 2021-08-26 stsp
1005 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1006 fc414659 2022-04-16 thomas ret=$?
1007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1008 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1009 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1010 f8a36e22 2021-08-26 stsp return 1
1011 f8a36e22 2021-08-26 stsp fi
1012 f8a36e22 2021-08-26 stsp
1013 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1014 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1015 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1016 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1017 f8a36e22 2021-08-26 stsp return 1
1018 f8a36e22 2021-08-26 stsp fi
1019 f8a36e22 2021-08-26 stsp
1020 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1021 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1022 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1023 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1024 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1025 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1026 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1027 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1028 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1029 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1030 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1031 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1032 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1033 f8a36e22 2021-08-26 stsp
1034 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1035 fc414659 2022-04-16 thomas ret=$?
1036 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1037 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1038 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1039 f0fd0aaf 2021-09-14 stsp return 1
1040 f8a36e22 2021-08-26 stsp fi
1041 f0fd0aaf 2021-09-14 stsp
1042 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1043 fc414659 2022-04-16 thomas ret=$?
1044 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1045 f8a36e22 2021-08-26 stsp }
1046 f8a36e22 2021-08-26 stsp
1047 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1048 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1049 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1050 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1051 f8a36e22 2021-08-26 stsp
1052 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1053 f8a36e22 2021-08-26 stsp
1054 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1055 fc414659 2022-04-16 thomas ret=$?
1056 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1057 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1058 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1059 f8a36e22 2021-08-26 stsp return 1
1060 f8a36e22 2021-08-26 stsp fi
1061 f8a36e22 2021-08-26 stsp
1062 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1063 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1064 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1065 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1066 f8a36e22 2021-08-26 stsp
1067 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1068 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1069 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1070 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1071 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1072 f8a36e22 2021-08-26 stsp
1073 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1074 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1075 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1076 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1077 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1078 f8a36e22 2021-08-26 stsp
1079 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1080 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1081 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1082 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1083 f8a36e22 2021-08-26 stsp return 1
1084 f8a36e22 2021-08-26 stsp fi
1085 f8a36e22 2021-08-26 stsp
1086 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1087 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1088 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1089 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1090 f8a36e22 2021-08-26 stsp
1091 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1092 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1093 fc414659 2022-04-16 thomas ret=$?
1094 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1095 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1096 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1097 f8a36e22 2021-08-26 stsp return 1
1098 f8a36e22 2021-08-26 stsp fi
1099 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1100 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1101 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1102 fc414659 2022-04-16 thomas ret=$?
1103 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1104 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1105 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1106 f8a36e22 2021-08-26 stsp return 1
1107 f8a36e22 2021-08-26 stsp fi
1108 f8a36e22 2021-08-26 stsp
1109 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1110 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1111 fc414659 2022-04-16 thomas ret=$?
1112 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1113 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1114 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1115 f8a36e22 2021-08-26 stsp return 1
1116 f8a36e22 2021-08-26 stsp fi
1117 f8a36e22 2021-08-26 stsp
1118 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1119 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1120 fc414659 2022-04-16 thomas ret=$?
1121 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1122 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1123 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1124 f8a36e22 2021-08-26 stsp return 1
1125 f8a36e22 2021-08-26 stsp fi
1126 f8a36e22 2021-08-26 stsp
1127 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1128 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1129 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1130 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1131 f8a36e22 2021-08-26 stsp return 1
1132 f8a36e22 2021-08-26 stsp fi
1133 f8a36e22 2021-08-26 stsp
1134 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1135 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1136 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1137 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1138 f8a36e22 2021-08-26 stsp
1139 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1140 fc414659 2022-04-16 thomas ret=$?
1141 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1142 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1143 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1144 f8a36e22 2021-08-26 stsp return 1
1145 f8a36e22 2021-08-26 stsp fi
1146 f8a36e22 2021-08-26 stsp
1147 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1148 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1149 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1150 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1151 f8a36e22 2021-08-26 stsp return 1
1152 f8a36e22 2021-08-26 stsp fi
1153 f8a36e22 2021-08-26 stsp
1154 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1155 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1156 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1157 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1158 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1159 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1160 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1161 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1162 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1163 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1164 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1165 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1166 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1167 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1168 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1169 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1170 f8a36e22 2021-08-26 stsp
1171 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1172 fc414659 2022-04-16 thomas ret=$?
1173 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1174 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1175 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1176 f0fd0aaf 2021-09-14 stsp return 1
1177 f8a36e22 2021-08-26 stsp fi
1178 f0fd0aaf 2021-09-14 stsp
1179 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1180 fc414659 2022-04-16 thomas ret=$?
1181 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1182 f8a36e22 2021-08-26 stsp }
1183 f8a36e22 2021-08-26 stsp
1184 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1185 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1186 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1187 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1188 f8a36e22 2021-08-26 stsp
1189 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1190 f8a36e22 2021-08-26 stsp
1191 fc414659 2022-04-16 thomas ret=$?
1192 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1193 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1194 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1195 f8a36e22 2021-08-26 stsp return 1
1196 f8a36e22 2021-08-26 stsp fi
1197 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1198 f8a36e22 2021-08-26 stsp remote "origin" {
1199 f8a36e22 2021-08-26 stsp protocol ssh
1200 f8a36e22 2021-08-26 stsp server 127.0.0.1
1201 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1202 f8a36e22 2021-08-26 stsp }
1203 f8a36e22 2021-08-26 stsp EOF
1204 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1205 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1206 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1207 f8a36e22 2021-08-26 stsp
1208 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1209 fc414659 2022-04-16 thomas ret=$?
1210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1211 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1212 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1213 f8a36e22 2021-08-26 stsp return 1
1214 f8a36e22 2021-08-26 stsp fi
1215 f8a36e22 2021-08-26 stsp
1216 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1217 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1218 fc414659 2022-04-16 thomas ret=$?
1219 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1220 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1221 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1222 f8a36e22 2021-08-26 stsp return 1
1223 f8a36e22 2021-08-26 stsp fi
1224 f8a36e22 2021-08-26 stsp
1225 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1226 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1227 f8a36e22 2021-08-26 stsp
1228 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1229 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1230 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1231 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1232 f8a36e22 2021-08-26 stsp return 1
1233 f8a36e22 2021-08-26 stsp fi
1234 f8a36e22 2021-08-26 stsp
1235 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1236 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1237 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1238 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1239 f8a36e22 2021-08-26 stsp
1240 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1241 fc414659 2022-04-16 thomas ret=$?
1242 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1243 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1244 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1245 f8a36e22 2021-08-26 stsp return 1
1246 f8a36e22 2021-08-26 stsp fi
1247 f8a36e22 2021-08-26 stsp
1248 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1249 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1250 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1251 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1252 f8a36e22 2021-08-26 stsp return 1
1253 f8a36e22 2021-08-26 stsp fi
1254 f8a36e22 2021-08-26 stsp
1255 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1256 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1257 f8a36e22 2021-08-26 stsp
1258 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1259 fc414659 2022-04-16 thomas ret=$?
1260 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1261 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1262 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1263 f8a36e22 2021-08-26 stsp return 1
1264 f8a36e22 2021-08-26 stsp fi
1265 f8a36e22 2021-08-26 stsp
1266 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1267 fc414659 2022-04-16 thomas ret=$?
1268 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1269 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1270 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1271 f8a36e22 2021-08-26 stsp return 1
1272 f8a36e22 2021-08-26 stsp fi
1273 f8a36e22 2021-08-26 stsp
1274 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1275 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1276 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1277 fc414659 2022-04-16 thomas ret=$?
1278 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1279 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1280 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1281 f0fd0aaf 2021-09-14 stsp return 1
1282 f8a36e22 2021-08-26 stsp fi
1283 f0fd0aaf 2021-09-14 stsp
1284 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1285 fc414659 2022-04-16 thomas ret=$?
1286 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1287 6480c871 2021-08-30 stsp }
1288 6480c871 2021-08-30 stsp
1289 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1290 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1291 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1292 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1293 6480c871 2021-08-30 stsp
1294 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1295 fc414659 2022-04-16 thomas ret=$?
1296 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1297 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1298 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1299 6480c871 2021-08-30 stsp return 1
1300 6480c871 2021-08-30 stsp fi
1301 6480c871 2021-08-30 stsp
1302 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1303 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1304 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1305 6480c871 2021-08-30 stsp
1306 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1307 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1308 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1309 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1310 6480c871 2021-08-30 stsp
1311 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1312 6480c871 2021-08-30 stsp remote "origin" {
1313 6480c871 2021-08-30 stsp protocol ssh
1314 6480c871 2021-08-30 stsp server 127.0.0.1
1315 6480c871 2021-08-30 stsp send {
1316 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1317 6480c871 2021-08-30 stsp }
1318 6480c871 2021-08-30 stsp fetch {
1319 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1320 6480c871 2021-08-30 stsp }
1321 f8a36e22 2021-08-26 stsp }
1322 6480c871 2021-08-30 stsp EOF
1323 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1324 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1325 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1326 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1327 6480c871 2021-08-30 stsp return 1
1328 6480c871 2021-08-30 stsp fi
1329 f8a36e22 2021-08-26 stsp
1330 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1331 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1332 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1333 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1334 fc414659 2022-04-16 thomas ret=$?
1335 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1336 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1337 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1338 6480c871 2021-08-30 stsp return 1
1339 6480c871 2021-08-30 stsp fi
1340 f8a36e22 2021-08-26 stsp
1341 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1342 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1343 fc414659 2022-04-16 thomas ret=$?
1344 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1345 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1346 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1347 6480c871 2021-08-30 stsp return 1
1348 6480c871 2021-08-30 stsp fi
1349 6480c871 2021-08-30 stsp
1350 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1351 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1352 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1353 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1354 6480c871 2021-08-30 stsp return 1
1355 6480c871 2021-08-30 stsp fi
1356 6480c871 2021-08-30 stsp
1357 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1358 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1359 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1360 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1361 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1362 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1363 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1364 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1365 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1366 fc414659 2022-04-16 thomas ret=$?
1367 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1368 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1369 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1370 6480c871 2021-08-30 stsp return 1
1371 6480c871 2021-08-30 stsp fi
1372 6480c871 2021-08-30 stsp
1373 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1374 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1375 fc414659 2022-04-16 thomas ret=$?
1376 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1377 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1378 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1379 6480c871 2021-08-30 stsp return 1
1380 6480c871 2021-08-30 stsp fi
1381 6480c871 2021-08-30 stsp
1382 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1383 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1384 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1385 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1386 6480c871 2021-08-30 stsp return 1
1387 6480c871 2021-08-30 stsp fi
1388 6480c871 2021-08-30 stsp
1389 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1390 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1391 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1392 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1393 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1394 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1395 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1396 6480c871 2021-08-30 stsp
1397 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1398 fc414659 2022-04-16 thomas ret=$?
1399 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1400 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1401 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1402 f0fd0aaf 2021-09-14 stsp return 1
1403 6480c871 2021-08-30 stsp fi
1404 6480c871 2021-08-30 stsp
1405 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1406 fc414659 2022-04-16 thomas ret=$?
1407 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1408 eac1df47 2021-09-01 stsp }
1409 eac1df47 2021-09-01 stsp
1410 eac1df47 2021-09-01 stsp test_send_config() {
1411 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1412 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1413 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1414 eac1df47 2021-09-01 stsp
1415 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1416 fc414659 2022-04-16 thomas ret=$?
1417 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1418 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1419 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1420 eac1df47 2021-09-01 stsp return 1
1421 eac1df47 2021-09-01 stsp fi
1422 eac1df47 2021-09-01 stsp
1423 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1424 eac1df47 2021-09-01 stsp remote "origin" {
1425 eac1df47 2021-09-01 stsp protocol ssh
1426 eac1df47 2021-09-01 stsp server 127.0.0.1
1427 eac1df47 2021-09-01 stsp branch foo
1428 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1429 6480c871 2021-08-30 stsp }
1430 eac1df47 2021-09-01 stsp EOF
1431 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1432 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1433 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1434 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1435 eac1df47 2021-09-01 stsp return 1
1436 eac1df47 2021-09-01 stsp fi
1437 6480c871 2021-08-30 stsp
1438 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1439 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1440 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1441 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1442 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1443 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1444 eac1df47 2021-09-01 stsp
1445 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1446 fc414659 2022-04-16 thomas ret=$?
1447 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1448 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1449 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1450 eac1df47 2021-09-01 stsp return 1
1451 eac1df47 2021-09-01 stsp fi
1452 eac1df47 2021-09-01 stsp
1453 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1454 eac1df47 2021-09-01 stsp
1455 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1456 fc414659 2022-04-16 thomas ret=$?
1457 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1458 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1459 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1460 eac1df47 2021-09-01 stsp return 1
1461 eac1df47 2021-09-01 stsp fi
1462 eac1df47 2021-09-01 stsp
1463 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1465 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1466 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1467 eac1df47 2021-09-01 stsp return 1
1468 eac1df47 2021-09-01 stsp fi
1469 eac1df47 2021-09-01 stsp
1470 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1471 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1472 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1473 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1474 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1475 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1476 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1477 eac1df47 2021-09-01 stsp
1478 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1479 fc414659 2022-04-16 thomas ret=$?
1480 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1481 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1482 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1483 f0fd0aaf 2021-09-14 stsp return 1
1484 eac1df47 2021-09-01 stsp fi
1485 f0fd0aaf 2021-09-14 stsp
1486 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1487 fc414659 2022-04-16 thomas ret=$?
1488 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1489 eac1df47 2021-09-01 stsp }
1490 eac1df47 2021-09-01 stsp
1491 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1492 f8a36e22 2021-08-26 stsp run_test test_send_basic
1493 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1494 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1495 f8a36e22 2021-08-26 stsp run_test test_send_delete
1496 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1497 f8a36e22 2021-08-26 stsp run_test test_send_tags
1498 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1499 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1500 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1501 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1502 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1503 eac1df47 2021-09-01 stsp run_test test_send_config