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 f8a36e22 2021-08-26 stsp ret="$?"
26 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
52 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
61 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
82 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 08511b5e 2021-09-24 thomas ret="$?"
104 08511b5e 2021-09-24 thomas if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
116 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
124 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
134 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 f8a36e22 2021-08-26 stsp ret="$?"
152 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
174 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
183 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
193 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 f8a36e22 2021-08-26 stsp ret="$?"
211 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
236 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
245 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
254 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
263 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
283 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
309 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 f8a36e22 2021-08-26 stsp ret="$?"
330 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
362 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
372 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
381 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
390 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 1bd76734 2021-08-26 stsp ret="$?"
402 1bd76734 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
412 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
423 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
433 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
445 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
464 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
488 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 f8a36e22 2021-08-26 stsp ret="$?"
508 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
521 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
530 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
548 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
574 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 f8a36e22 2021-08-26 stsp ret="$?"
592 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
618 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
627 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
649 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
673 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
683 f8a36e22 2021-08-26 stsp ret="$?"
684 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
685 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
687 f8a36e22 2021-08-26 stsp return 1
688 f8a36e22 2021-08-26 stsp fi
689 f8a36e22 2021-08-26 stsp
690 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
691 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
692 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
693 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
694 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
695 f8a36e22 2021-08-26 stsp
696 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
697 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
698 f8a36e22 2021-08-26 stsp ret="$?"
699 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
700 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
701 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
702 f8a36e22 2021-08-26 stsp return 1
703 f8a36e22 2021-08-26 stsp fi
704 f8a36e22 2021-08-26 stsp
705 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
706 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
707 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
708 f8a36e22 2021-08-26 stsp ret="$?"
709 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
710 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
711 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
712 f8a36e22 2021-08-26 stsp return 1
713 f8a36e22 2021-08-26 stsp fi
714 f8a36e22 2021-08-26 stsp
715 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
716 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
717 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
718 f8a36e22 2021-08-26 stsp ret="$?"
719 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
720 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
721 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
722 f8a36e22 2021-08-26 stsp return 1
723 f8a36e22 2021-08-26 stsp fi
724 f8a36e22 2021-08-26 stsp
725 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
726 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
727 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
728 f8a36e22 2021-08-26 stsp ret="$?"
729 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
730 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
731 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
732 f8a36e22 2021-08-26 stsp return 1
733 f8a36e22 2021-08-26 stsp fi
734 f8a36e22 2021-08-26 stsp
735 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
736 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
737 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
738 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
739 f8a36e22 2021-08-26 stsp ret="$?"
740 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
741 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
742 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
743 f8a36e22 2021-08-26 stsp return 1
744 f8a36e22 2021-08-26 stsp fi
745 f8a36e22 2021-08-26 stsp
746 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
747 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
748 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
749 f8a36e22 2021-08-26 stsp ret="$?"
750 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
751 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
752 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
753 f8a36e22 2021-08-26 stsp return 1
754 f8a36e22 2021-08-26 stsp fi
755 f8a36e22 2021-08-26 stsp
756 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
757 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
758 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
759 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
760 f8a36e22 2021-08-26 stsp ret="$?"
761 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
762 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
763 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
764 c2105d00 2021-09-14 stsp return 1
765 f8a36e22 2021-08-26 stsp fi
766 c2105d00 2021-09-14 stsp
767 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
768 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
769 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
770 c2105d00 2021-09-14 stsp
771 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
772 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
773 c2105d00 2021-09-14 stsp 2> $testroot/stderr
774 c2105d00 2021-09-14 stsp ret="$?"
775 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
776 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
777 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
778 c2105d00 2021-09-14 stsp return 1
779 c2105d00 2021-09-14 stsp fi
780 c2105d00 2021-09-14 stsp
781 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
782 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
783 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
784 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
785 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
786 c2105d00 2021-09-14 stsp
787 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
788 c2105d00 2021-09-14 stsp 2> $testroot/stderr
789 c2105d00 2021-09-14 stsp ret="$?"
790 c2105d00 2021-09-14 stsp if [ "$ret" != "0" ]; then
791 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
792 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
793 c2105d00 2021-09-14 stsp return 1
794 c2105d00 2021-09-14 stsp fi
795 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
796 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
797 c2105d00 2021-09-14 stsp $testroot/stdout; then
798 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
799 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
800 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
801 c2105d00 2021-09-14 stsp return 1
802 c2105d00 2021-09-14 stsp fi
803 f0fd0aaf 2021-09-14 stsp
804 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
805 f0fd0aaf 2021-09-14 stsp ret="$?"
806 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
807 f8a36e22 2021-08-26 stsp }
808 f8a36e22 2021-08-26 stsp
809 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
810 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
811 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
812 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
813 26960ff7 2021-09-14 stsp
814 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
815 26960ff7 2021-09-14 stsp ret="$?"
816 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
817 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
818 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
819 26960ff7 2021-09-14 stsp return 1
820 26960ff7 2021-09-14 stsp fi
821 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
822 26960ff7 2021-09-14 stsp remote "origin" {
823 26960ff7 2021-09-14 stsp protocol ssh
824 26960ff7 2021-09-14 stsp server 127.0.0.1
825 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
826 26960ff7 2021-09-14 stsp }
827 26960ff7 2021-09-14 stsp EOF
828 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
829 26960ff7 2021-09-14 stsp
830 26960ff7 2021-09-14 stsp # modify alpha on branch foo
831 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
832 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
833 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
834 26960ff7 2021-09-14 stsp > /dev/null)
835 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
836 26960ff7 2021-09-14 stsp
837 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
838 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
839 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
840 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
841 26960ff7 2021-09-14 stsp
842 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
843 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
844 26960ff7 2021-09-14 stsp
845 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
846 26960ff7 2021-09-14 stsp # and the tag
847 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
848 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
849 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
850 26960ff7 2021-09-14 stsp
851 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
852 26960ff7 2021-09-14 stsp ret="$?"
853 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
854 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
855 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
856 26960ff7 2021-09-14 stsp return 1
857 26960ff7 2021-09-14 stsp fi
858 26960ff7 2021-09-14 stsp
859 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
860 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
861 26960ff7 2021-09-14 stsp ret="$?"
862 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
863 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
864 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
865 26960ff7 2021-09-14 stsp return 1
866 26960ff7 2021-09-14 stsp fi
867 26960ff7 2021-09-14 stsp
868 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
869 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
870 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
871 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
872 26960ff7 2021-09-14 stsp return 1
873 26960ff7 2021-09-14 stsp fi
874 26960ff7 2021-09-14 stsp
875 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
876 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
877 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
878 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
879 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
880 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
881 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
882 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
883 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
884 26960ff7 2021-09-14 stsp
885 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
886 26960ff7 2021-09-14 stsp ret="$?"
887 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
888 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
889 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
890 26960ff7 2021-09-14 stsp return 1
891 26960ff7 2021-09-14 stsp fi
892 26960ff7 2021-09-14 stsp
893 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
894 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
895 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
896 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
897 26960ff7 2021-09-14 stsp return 1
898 26960ff7 2021-09-14 stsp fi
899 26960ff7 2021-09-14 stsp
900 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
901 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
902 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
903 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
904 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
905 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
906 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
907 26960ff7 2021-09-14 stsp
908 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
909 26960ff7 2021-09-14 stsp ret="$?"
910 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
911 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
912 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
913 26960ff7 2021-09-14 stsp return 1
914 26960ff7 2021-09-14 stsp fi
915 26960ff7 2021-09-14 stsp
916 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
917 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
918 26960ff7 2021-09-14 stsp
919 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
920 26960ff7 2021-09-14 stsp ret="$?"
921 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
922 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
923 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
924 f0fd0aaf 2021-09-14 stsp return 1
925 26960ff7 2021-09-14 stsp fi
926 f0fd0aaf 2021-09-14 stsp
927 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
928 f0fd0aaf 2021-09-14 stsp ret="$?"
929 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
930 26960ff7 2021-09-14 stsp }
931 26960ff7 2021-09-14 stsp
932 f8a36e22 2021-08-26 stsp test_send_new_branch() {
933 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
934 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
935 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
936 f8a36e22 2021-08-26 stsp
937 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
938 f8a36e22 2021-08-26 stsp
939 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
940 f8a36e22 2021-08-26 stsp ret="$?"
941 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
942 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
943 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
944 f8a36e22 2021-08-26 stsp return 1
945 f8a36e22 2021-08-26 stsp fi
946 f8a36e22 2021-08-26 stsp
947 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
948 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
949 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
950 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
951 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
952 f8a36e22 2021-08-26 stsp
953 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
954 f8a36e22 2021-08-26 stsp ret="$?"
955 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
956 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
957 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
958 f8a36e22 2021-08-26 stsp return 1
959 f8a36e22 2021-08-26 stsp fi
960 f8a36e22 2021-08-26 stsp
961 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
962 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
963 f8a36e22 2021-08-26 stsp ret="$?"
964 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
965 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
966 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
967 f8a36e22 2021-08-26 stsp return 1
968 f8a36e22 2021-08-26 stsp fi
969 f8a36e22 2021-08-26 stsp
970 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
971 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
972 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
973 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
974 f8a36e22 2021-08-26 stsp return 1
975 f8a36e22 2021-08-26 stsp fi
976 f8a36e22 2021-08-26 stsp
977 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
978 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
979 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
980 f8a36e22 2021-08-26 stsp
981 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
982 f8a36e22 2021-08-26 stsp ret="$?"
983 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
984 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
986 f8a36e22 2021-08-26 stsp return 1
987 f8a36e22 2021-08-26 stsp fi
988 f8a36e22 2021-08-26 stsp
989 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
990 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
991 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
992 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
993 f8a36e22 2021-08-26 stsp return 1
994 f8a36e22 2021-08-26 stsp fi
995 f8a36e22 2021-08-26 stsp
996 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
997 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
998 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
999 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1000 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1001 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1002 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1003 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1004 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1005 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1006 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1007 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1008 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1009 f8a36e22 2021-08-26 stsp
1010 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1011 f8a36e22 2021-08-26 stsp ret="$?"
1012 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1013 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1014 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1015 f0fd0aaf 2021-09-14 stsp return 1
1016 f8a36e22 2021-08-26 stsp fi
1017 f0fd0aaf 2021-09-14 stsp
1018 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1019 f0fd0aaf 2021-09-14 stsp ret="$?"
1020 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1021 f8a36e22 2021-08-26 stsp }
1022 f8a36e22 2021-08-26 stsp
1023 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1024 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1025 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1026 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1027 f8a36e22 2021-08-26 stsp
1028 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1029 f8a36e22 2021-08-26 stsp
1030 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1031 f8a36e22 2021-08-26 stsp ret="$?"
1032 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1033 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1034 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1035 f8a36e22 2021-08-26 stsp return 1
1036 f8a36e22 2021-08-26 stsp fi
1037 f8a36e22 2021-08-26 stsp
1038 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1039 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1040 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1041 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1042 f8a36e22 2021-08-26 stsp
1043 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1044 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1045 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1046 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1047 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1048 f8a36e22 2021-08-26 stsp
1049 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1050 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1051 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1052 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1053 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1054 f8a36e22 2021-08-26 stsp
1055 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1056 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1057 f8a36e22 2021-08-26 stsp echo "got ref 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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1063 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1064 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1065 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1066 f8a36e22 2021-08-26 stsp
1067 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1068 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1069 f8a36e22 2021-08-26 stsp ret="$?"
1070 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
1071 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1072 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1073 f8a36e22 2021-08-26 stsp return 1
1074 f8a36e22 2021-08-26 stsp fi
1075 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1076 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1077 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1078 f8a36e22 2021-08-26 stsp ret="$?"
1079 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1080 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1081 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1082 f8a36e22 2021-08-26 stsp return 1
1083 f8a36e22 2021-08-26 stsp fi
1084 f8a36e22 2021-08-26 stsp
1085 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1086 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1087 f8a36e22 2021-08-26 stsp ret="$?"
1088 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1090 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1091 f8a36e22 2021-08-26 stsp return 1
1092 f8a36e22 2021-08-26 stsp fi
1093 f8a36e22 2021-08-26 stsp
1094 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1095 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1096 f8a36e22 2021-08-26 stsp ret="$?"
1097 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1098 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1099 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1100 f8a36e22 2021-08-26 stsp return 1
1101 f8a36e22 2021-08-26 stsp fi
1102 f8a36e22 2021-08-26 stsp
1103 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1104 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1105 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1106 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1107 f8a36e22 2021-08-26 stsp return 1
1108 f8a36e22 2021-08-26 stsp fi
1109 f8a36e22 2021-08-26 stsp
1110 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1111 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1112 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1113 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1114 f8a36e22 2021-08-26 stsp
1115 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1116 f8a36e22 2021-08-26 stsp ret="$?"
1117 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1118 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1119 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1120 f8a36e22 2021-08-26 stsp return 1
1121 f8a36e22 2021-08-26 stsp fi
1122 f8a36e22 2021-08-26 stsp
1123 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1124 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1125 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1126 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1127 f8a36e22 2021-08-26 stsp return 1
1128 f8a36e22 2021-08-26 stsp fi
1129 f8a36e22 2021-08-26 stsp
1130 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1131 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1132 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1133 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1134 f8a36e22 2021-08-26 stsp >> $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 echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1139 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1140 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1141 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1142 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1143 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1144 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1145 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1146 f8a36e22 2021-08-26 stsp
1147 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1148 f8a36e22 2021-08-26 stsp ret="$?"
1149 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1150 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1152 f0fd0aaf 2021-09-14 stsp return 1
1153 f8a36e22 2021-08-26 stsp fi
1154 f0fd0aaf 2021-09-14 stsp
1155 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1156 f0fd0aaf 2021-09-14 stsp ret="$?"
1157 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1158 f8a36e22 2021-08-26 stsp }
1159 f8a36e22 2021-08-26 stsp
1160 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1161 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1162 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1163 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1164 f8a36e22 2021-08-26 stsp
1165 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1166 f8a36e22 2021-08-26 stsp
1167 f8a36e22 2021-08-26 stsp ret="$?"
1168 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1169 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1170 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1171 f8a36e22 2021-08-26 stsp return 1
1172 f8a36e22 2021-08-26 stsp fi
1173 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1174 f8a36e22 2021-08-26 stsp remote "origin" {
1175 f8a36e22 2021-08-26 stsp protocol ssh
1176 f8a36e22 2021-08-26 stsp server 127.0.0.1
1177 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1178 f8a36e22 2021-08-26 stsp }
1179 f8a36e22 2021-08-26 stsp EOF
1180 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1181 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1182 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1183 f8a36e22 2021-08-26 stsp
1184 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1185 f8a36e22 2021-08-26 stsp ret="$?"
1186 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1187 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1188 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1189 f8a36e22 2021-08-26 stsp return 1
1190 f8a36e22 2021-08-26 stsp fi
1191 f8a36e22 2021-08-26 stsp
1192 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1193 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1194 f8a36e22 2021-08-26 stsp ret="$?"
1195 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1196 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1197 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1198 f8a36e22 2021-08-26 stsp return 1
1199 f8a36e22 2021-08-26 stsp fi
1200 f8a36e22 2021-08-26 stsp
1201 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1202 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1203 f8a36e22 2021-08-26 stsp
1204 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1205 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1206 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1207 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1208 f8a36e22 2021-08-26 stsp return 1
1209 f8a36e22 2021-08-26 stsp fi
1210 f8a36e22 2021-08-26 stsp
1211 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1212 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1213 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1214 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1215 f8a36e22 2021-08-26 stsp
1216 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1217 f8a36e22 2021-08-26 stsp ret="$?"
1218 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1219 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1220 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1221 f8a36e22 2021-08-26 stsp return 1
1222 f8a36e22 2021-08-26 stsp fi
1223 f8a36e22 2021-08-26 stsp
1224 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1225 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1226 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1227 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1228 f8a36e22 2021-08-26 stsp return 1
1229 f8a36e22 2021-08-26 stsp fi
1230 f8a36e22 2021-08-26 stsp
1231 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1232 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1233 f8a36e22 2021-08-26 stsp
1234 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1235 f8a36e22 2021-08-26 stsp ret="$?"
1236 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1237 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1239 f8a36e22 2021-08-26 stsp return 1
1240 f8a36e22 2021-08-26 stsp fi
1241 f8a36e22 2021-08-26 stsp
1242 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1243 f8a36e22 2021-08-26 stsp ret="$?"
1244 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1245 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1246 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1247 f8a36e22 2021-08-26 stsp return 1
1248 f8a36e22 2021-08-26 stsp fi
1249 f8a36e22 2021-08-26 stsp
1250 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1251 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1252 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1253 f8a36e22 2021-08-26 stsp ret="$?"
1254 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1255 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1256 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1257 f0fd0aaf 2021-09-14 stsp return 1
1258 f8a36e22 2021-08-26 stsp fi
1259 f0fd0aaf 2021-09-14 stsp
1260 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1261 f0fd0aaf 2021-09-14 stsp ret="$?"
1262 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1263 6480c871 2021-08-30 stsp }
1264 6480c871 2021-08-30 stsp
1265 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1266 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1267 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1268 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1269 6480c871 2021-08-30 stsp
1270 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1271 6480c871 2021-08-30 stsp ret="$?"
1272 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1273 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1274 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1275 6480c871 2021-08-30 stsp return 1
1276 6480c871 2021-08-30 stsp fi
1277 6480c871 2021-08-30 stsp
1278 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1279 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1280 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1281 6480c871 2021-08-30 stsp
1282 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1283 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1284 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1285 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1286 6480c871 2021-08-30 stsp
1287 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1288 6480c871 2021-08-30 stsp remote "origin" {
1289 6480c871 2021-08-30 stsp protocol ssh
1290 6480c871 2021-08-30 stsp server 127.0.0.1
1291 6480c871 2021-08-30 stsp send {
1292 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1293 6480c871 2021-08-30 stsp }
1294 6480c871 2021-08-30 stsp fetch {
1295 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1296 6480c871 2021-08-30 stsp }
1297 f8a36e22 2021-08-26 stsp }
1298 6480c871 2021-08-30 stsp EOF
1299 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1300 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1301 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1302 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1303 6480c871 2021-08-30 stsp return 1
1304 6480c871 2021-08-30 stsp fi
1305 f8a36e22 2021-08-26 stsp
1306 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1307 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1308 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1309 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1310 6480c871 2021-08-30 stsp ret="$?"
1311 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1312 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1313 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1314 6480c871 2021-08-30 stsp return 1
1315 6480c871 2021-08-30 stsp fi
1316 f8a36e22 2021-08-26 stsp
1317 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1318 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1319 6480c871 2021-08-30 stsp ret="$?"
1320 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1321 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1322 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1323 6480c871 2021-08-30 stsp return 1
1324 6480c871 2021-08-30 stsp fi
1325 6480c871 2021-08-30 stsp
1326 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1327 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1328 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1329 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1330 6480c871 2021-08-30 stsp return 1
1331 6480c871 2021-08-30 stsp fi
1332 6480c871 2021-08-30 stsp
1333 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1334 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1335 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1336 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1337 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1338 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1339 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1340 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1341 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1342 6480c871 2021-08-30 stsp ret="$?"
1343 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1344 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1345 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1346 6480c871 2021-08-30 stsp return 1
1347 6480c871 2021-08-30 stsp fi
1348 6480c871 2021-08-30 stsp
1349 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1350 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1351 6480c871 2021-08-30 stsp ret="$?"
1352 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1353 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1354 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1355 6480c871 2021-08-30 stsp return 1
1356 6480c871 2021-08-30 stsp fi
1357 6480c871 2021-08-30 stsp
1358 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1359 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1360 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1361 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1362 6480c871 2021-08-30 stsp return 1
1363 6480c871 2021-08-30 stsp fi
1364 6480c871 2021-08-30 stsp
1365 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1366 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1367 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1368 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1369 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1370 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1371 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1372 6480c871 2021-08-30 stsp
1373 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1374 6480c871 2021-08-30 stsp ret="$?"
1375 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1376 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1377 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1378 f0fd0aaf 2021-09-14 stsp return 1
1379 6480c871 2021-08-30 stsp fi
1380 6480c871 2021-08-30 stsp
1381 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1382 f0fd0aaf 2021-09-14 stsp ret="$?"
1383 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1384 eac1df47 2021-09-01 stsp }
1385 eac1df47 2021-09-01 stsp
1386 eac1df47 2021-09-01 stsp test_send_config() {
1387 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1388 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1389 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1390 eac1df47 2021-09-01 stsp
1391 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1392 eac1df47 2021-09-01 stsp ret="$?"
1393 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1394 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1395 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1396 eac1df47 2021-09-01 stsp return 1
1397 eac1df47 2021-09-01 stsp fi
1398 eac1df47 2021-09-01 stsp
1399 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1400 eac1df47 2021-09-01 stsp remote "origin" {
1401 eac1df47 2021-09-01 stsp protocol ssh
1402 eac1df47 2021-09-01 stsp server 127.0.0.1
1403 eac1df47 2021-09-01 stsp branch foo
1404 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1405 6480c871 2021-08-30 stsp }
1406 eac1df47 2021-09-01 stsp EOF
1407 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1408 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1409 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1410 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1411 eac1df47 2021-09-01 stsp return 1
1412 eac1df47 2021-09-01 stsp fi
1413 6480c871 2021-08-30 stsp
1414 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1415 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1416 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1417 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1418 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1419 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1420 eac1df47 2021-09-01 stsp
1421 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1422 eac1df47 2021-09-01 stsp ret="$?"
1423 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1424 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1425 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1426 eac1df47 2021-09-01 stsp return 1
1427 eac1df47 2021-09-01 stsp fi
1428 eac1df47 2021-09-01 stsp
1429 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1430 eac1df47 2021-09-01 stsp
1431 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1432 eac1df47 2021-09-01 stsp ret="$?"
1433 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1434 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1435 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1436 eac1df47 2021-09-01 stsp return 1
1437 eac1df47 2021-09-01 stsp fi
1438 eac1df47 2021-09-01 stsp
1439 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1440 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1441 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1442 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1443 eac1df47 2021-09-01 stsp return 1
1444 eac1df47 2021-09-01 stsp fi
1445 eac1df47 2021-09-01 stsp
1446 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1447 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1448 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1449 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1450 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1451 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1452 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1453 eac1df47 2021-09-01 stsp
1454 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1455 eac1df47 2021-09-01 stsp ret="$?"
1456 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1457 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1458 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1459 f0fd0aaf 2021-09-14 stsp return 1
1460 eac1df47 2021-09-01 stsp fi
1461 f0fd0aaf 2021-09-14 stsp
1462 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1463 f0fd0aaf 2021-09-14 stsp ret="$?"
1464 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1465 eac1df47 2021-09-01 stsp }
1466 eac1df47 2021-09-01 stsp
1467 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1468 f8a36e22 2021-08-26 stsp run_test test_send_basic
1469 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1470 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1471 f8a36e22 2021-08-26 stsp run_test test_send_delete
1472 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1473 f8a36e22 2021-08-26 stsp run_test test_send_tags
1474 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1475 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1476 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1477 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1478 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1479 eac1df47 2021-09-01 stsp run_test test_send_config