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 3af9de88 2021-09-22 stsp (cd $testroot/repo && git rm -q beta)
44 3af9de88 2021-09-22 stsp (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
45 3af9de88 2021-09-22 stsp echo "new file alpha" > $testroot/repo/new
46 3af9de88 2021-09-22 stsp (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 3af9de88 2021-09-22 stsp
102 3af9de88 2021-09-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
103 3af9de88 2021-09-22 stsp ret="$?"
104 3af9de88 2021-09-22 stsp if [ "$ret" != "0" ]; then
105 3af9de88 2021-09-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 3af9de88 2021-09-22 stsp test_done "$testroot" "$ret"
107 3af9de88 2021-09-22 stsp return 1
108 3af9de88 2021-09-22 stsp fi
109 f8a36e22 2021-08-26 stsp
110 3af9de88 2021-09-22 stsp got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
111 3af9de88 2021-09-22 stsp > $testroot/stdout
112 3af9de88 2021-09-22 stsp got tree -r $testroot/repo -c $commit_id2 -i -R \
113 3af9de88 2021-09-22 stsp > $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 92410079 2021-10-16 stsp cmp -s $testroot/stdout $testroot/stdout.expected
683 92410079 2021-10-16 stsp ret="$?"
684 92410079 2021-10-16 stsp if [ "$ret" != "0" ]; then
685 92410079 2021-10-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
687 92410079 2021-10-16 stsp return 1
688 92410079 2021-10-16 stsp fi
689 92410079 2021-10-16 stsp
690 92410079 2021-10-16 stsp # Send the same tags again. This should be a no-op.
691 92410079 2021-10-16 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
692 92410079 2021-10-16 stsp ret="$?"
693 92410079 2021-10-16 stsp if [ "$ret" != "0" ]; then
694 92410079 2021-10-16 stsp echo "got send command failed unexpectedly" >&2
695 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
696 92410079 2021-10-16 stsp return 1
697 92410079 2021-10-16 stsp fi
698 92410079 2021-10-16 stsp
699 92410079 2021-10-16 stsp echo -n > $testroot/stdout.expected
700 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
701 f8a36e22 2021-08-26 stsp ret="$?"
702 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
717 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
727 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
737 f9756a57 2021-08-26 stsp if [ "$ret" = "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 f8a36e22 2021-08-26 stsp ret="$?"
747 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
758 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
768 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 f8a36e22 2021-08-26 stsp ret="$?"
779 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 c2105d00 2021-09-14 stsp ret="$?"
793 c2105d00 2021-09-14 stsp if [ "$ret" != "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 c2105d00 2021-09-14 stsp ret="$?"
808 c2105d00 2021-09-14 stsp if [ "$ret" != "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 f0fd0aaf 2021-09-14 stsp 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 26960ff7 2021-09-14 stsp ret="$?"
834 26960ff7 2021-09-14 stsp if [ "$ret" != "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 26960ff7 2021-09-14 stsp # modify alpha 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 26960ff7 2021-09-14 stsp > /dev/null)
853 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
854 26960ff7 2021-09-14 stsp
855 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
856 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
857 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
858 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
859 26960ff7 2021-09-14 stsp
860 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
861 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
862 26960ff7 2021-09-14 stsp
863 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
864 26960ff7 2021-09-14 stsp # and the tag
865 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
866 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
867 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
868 26960ff7 2021-09-14 stsp
869 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
870 26960ff7 2021-09-14 stsp ret="$?"
871 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
872 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
873 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
874 26960ff7 2021-09-14 stsp return 1
875 26960ff7 2021-09-14 stsp fi
876 26960ff7 2021-09-14 stsp
877 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
878 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
879 26960ff7 2021-09-14 stsp ret="$?"
880 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
881 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
883 26960ff7 2021-09-14 stsp return 1
884 26960ff7 2021-09-14 stsp fi
885 26960ff7 2021-09-14 stsp
886 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
887 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
888 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
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 wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
894 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
895 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
896 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
897 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
898 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
899 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
900 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
901 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
902 26960ff7 2021-09-14 stsp
903 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
904 26960ff7 2021-09-14 stsp ret="$?"
905 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
906 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
907 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
908 26960ff7 2021-09-14 stsp return 1
909 26960ff7 2021-09-14 stsp fi
910 26960ff7 2021-09-14 stsp
911 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
912 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
913 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
914 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
915 26960ff7 2021-09-14 stsp return 1
916 26960ff7 2021-09-14 stsp fi
917 26960ff7 2021-09-14 stsp
918 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
919 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
920 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
921 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
922 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
923 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
924 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
925 26960ff7 2021-09-14 stsp
926 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
927 26960ff7 2021-09-14 stsp ret="$?"
928 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
929 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
930 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
931 26960ff7 2021-09-14 stsp return 1
932 26960ff7 2021-09-14 stsp fi
933 26960ff7 2021-09-14 stsp
934 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
935 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
936 26960ff7 2021-09-14 stsp
937 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
938 26960ff7 2021-09-14 stsp ret="$?"
939 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
940 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
942 f0fd0aaf 2021-09-14 stsp return 1
943 26960ff7 2021-09-14 stsp fi
944 f0fd0aaf 2021-09-14 stsp
945 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
946 f0fd0aaf 2021-09-14 stsp ret="$?"
947 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
948 26960ff7 2021-09-14 stsp }
949 26960ff7 2021-09-14 stsp
950 f8a36e22 2021-08-26 stsp test_send_new_branch() {
951 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
952 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
953 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
954 f8a36e22 2021-08-26 stsp
955 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
956 f8a36e22 2021-08-26 stsp
957 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
958 f8a36e22 2021-08-26 stsp ret="$?"
959 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
960 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
961 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
962 f8a36e22 2021-08-26 stsp return 1
963 f8a36e22 2021-08-26 stsp fi
964 f8a36e22 2021-08-26 stsp
965 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
966 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
967 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
968 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
969 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
970 f8a36e22 2021-08-26 stsp
971 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
972 f8a36e22 2021-08-26 stsp ret="$?"
973 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
974 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
975 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
976 f8a36e22 2021-08-26 stsp return 1
977 f8a36e22 2021-08-26 stsp fi
978 f8a36e22 2021-08-26 stsp
979 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
980 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
981 f8a36e22 2021-08-26 stsp ret="$?"
982 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
983 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
984 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
985 f8a36e22 2021-08-26 stsp return 1
986 f8a36e22 2021-08-26 stsp fi
987 f8a36e22 2021-08-26 stsp
988 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
989 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
990 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
991 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
992 f8a36e22 2021-08-26 stsp return 1
993 f8a36e22 2021-08-26 stsp fi
994 f8a36e22 2021-08-26 stsp
995 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
996 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
997 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
998 f8a36e22 2021-08-26 stsp
999 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1000 f8a36e22 2021-08-26 stsp ret="$?"
1001 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1002 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1003 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1004 f8a36e22 2021-08-26 stsp return 1
1005 f8a36e22 2021-08-26 stsp fi
1006 f8a36e22 2021-08-26 stsp
1007 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1008 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1009 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1010 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1011 f8a36e22 2021-08-26 stsp return 1
1012 f8a36e22 2021-08-26 stsp fi
1013 f8a36e22 2021-08-26 stsp
1014 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1015 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1016 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1017 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1018 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1019 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1020 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1021 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1022 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1023 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1024 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1025 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1026 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1027 f8a36e22 2021-08-26 stsp
1028 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1029 f8a36e22 2021-08-26 stsp ret="$?"
1030 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1031 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1033 f0fd0aaf 2021-09-14 stsp return 1
1034 f8a36e22 2021-08-26 stsp fi
1035 f0fd0aaf 2021-09-14 stsp
1036 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1037 f0fd0aaf 2021-09-14 stsp ret="$?"
1038 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1039 f8a36e22 2021-08-26 stsp }
1040 f8a36e22 2021-08-26 stsp
1041 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1042 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1043 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1044 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1045 f8a36e22 2021-08-26 stsp
1046 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
1047 f8a36e22 2021-08-26 stsp
1048 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1049 f8a36e22 2021-08-26 stsp ret="$?"
1050 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1051 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1052 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1053 f8a36e22 2021-08-26 stsp return 1
1054 f8a36e22 2021-08-26 stsp fi
1055 f8a36e22 2021-08-26 stsp
1056 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1057 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1058 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1059 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1060 f8a36e22 2021-08-26 stsp
1061 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1062 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1063 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1064 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1065 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1066 f8a36e22 2021-08-26 stsp
1067 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1068 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1069 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $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_id4=`git_show_branch_head $testroot/repo-clone bar`
1072 f8a36e22 2021-08-26 stsp
1073 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1074 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1075 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1076 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1077 f8a36e22 2021-08-26 stsp return 1
1078 f8a36e22 2021-08-26 stsp fi
1079 f8a36e22 2021-08-26 stsp
1080 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1081 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1082 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1083 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1084 f8a36e22 2021-08-26 stsp
1085 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1086 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1087 f8a36e22 2021-08-26 stsp ret="$?"
1088 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got send command succeeded 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 echo "got: -a and -b options are mutually exclusive" \
1094 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1095 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.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/stderr.expected $testroot/stderr
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 send -a -q -r $testroot/repo-clone > $testroot/stdout \
1104 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1105 f8a36e22 2021-08-26 stsp ret="$?"
1106 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1107 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1108 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1109 f8a36e22 2021-08-26 stsp return 1
1110 f8a36e22 2021-08-26 stsp fi
1111 f8a36e22 2021-08-26 stsp
1112 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1113 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1114 f8a36e22 2021-08-26 stsp ret="$?"
1115 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1116 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1118 f8a36e22 2021-08-26 stsp return 1
1119 f8a36e22 2021-08-26 stsp fi
1120 f8a36e22 2021-08-26 stsp
1121 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1122 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1123 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1124 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1125 f8a36e22 2021-08-26 stsp return 1
1126 f8a36e22 2021-08-26 stsp fi
1127 f8a36e22 2021-08-26 stsp
1128 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1129 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1130 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1131 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1132 f8a36e22 2021-08-26 stsp
1133 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1134 f8a36e22 2021-08-26 stsp ret="$?"
1135 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1136 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1137 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1138 f8a36e22 2021-08-26 stsp return 1
1139 f8a36e22 2021-08-26 stsp fi
1140 f8a36e22 2021-08-26 stsp
1141 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1142 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1143 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1144 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1145 f8a36e22 2021-08-26 stsp return 1
1146 f8a36e22 2021-08-26 stsp fi
1147 f8a36e22 2021-08-26 stsp
1148 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1149 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1150 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1151 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1152 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1153 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1154 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1155 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1156 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1157 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1158 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1159 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1160 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1161 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1162 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1163 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1164 f8a36e22 2021-08-26 stsp
1165 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1166 f8a36e22 2021-08-26 stsp ret="$?"
1167 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1168 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1169 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1170 f0fd0aaf 2021-09-14 stsp return 1
1171 f8a36e22 2021-08-26 stsp fi
1172 f0fd0aaf 2021-09-14 stsp
1173 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1174 f0fd0aaf 2021-09-14 stsp ret="$?"
1175 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1176 f8a36e22 2021-08-26 stsp }
1177 f8a36e22 2021-08-26 stsp
1178 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1179 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1180 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1181 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1182 f8a36e22 2021-08-26 stsp
1183 f8a36e22 2021-08-26 stsp got init $testroot/repo2
1184 f8a36e22 2021-08-26 stsp
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 clone 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 cat > $testroot/repo/.git/got.conf <<EOF
1192 f8a36e22 2021-08-26 stsp remote "origin" {
1193 f8a36e22 2021-08-26 stsp protocol ssh
1194 f8a36e22 2021-08-26 stsp server 127.0.0.1
1195 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1196 f8a36e22 2021-08-26 stsp }
1197 f8a36e22 2021-08-26 stsp EOF
1198 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1199 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1200 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1201 f8a36e22 2021-08-26 stsp
1202 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1203 f8a36e22 2021-08-26 stsp ret="$?"
1204 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1205 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1206 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1207 f8a36e22 2021-08-26 stsp return 1
1208 f8a36e22 2021-08-26 stsp fi
1209 f8a36e22 2021-08-26 stsp
1210 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1211 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1212 f8a36e22 2021-08-26 stsp ret="$?"
1213 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1214 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1215 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1216 f8a36e22 2021-08-26 stsp return 1
1217 f8a36e22 2021-08-26 stsp fi
1218 f8a36e22 2021-08-26 stsp
1219 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1220 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1221 f8a36e22 2021-08-26 stsp
1222 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1223 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1224 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1225 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1226 f8a36e22 2021-08-26 stsp return 1
1227 f8a36e22 2021-08-26 stsp fi
1228 f8a36e22 2021-08-26 stsp
1229 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1230 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1231 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1232 f8a36e22 2021-08-26 stsp >> $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 ref -l -r $testroot/repo2 > $testroot/stdout
1243 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1244 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1245 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1246 f8a36e22 2021-08-26 stsp return 1
1247 f8a36e22 2021-08-26 stsp fi
1248 f8a36e22 2021-08-26 stsp
1249 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1250 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1251 f8a36e22 2021-08-26 stsp
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 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1257 f8a36e22 2021-08-26 stsp return 1
1258 f8a36e22 2021-08-26 stsp fi
1259 f8a36e22 2021-08-26 stsp
1260 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1261 f8a36e22 2021-08-26 stsp ret="$?"
1262 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1263 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1264 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1265 f8a36e22 2021-08-26 stsp return 1
1266 f8a36e22 2021-08-26 stsp fi
1267 f8a36e22 2021-08-26 stsp
1268 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1269 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1270 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1271 f8a36e22 2021-08-26 stsp ret="$?"
1272 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1273 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1275 f0fd0aaf 2021-09-14 stsp return 1
1276 f8a36e22 2021-08-26 stsp fi
1277 f0fd0aaf 2021-09-14 stsp
1278 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1279 f0fd0aaf 2021-09-14 stsp ret="$?"
1280 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1281 6480c871 2021-08-30 stsp }
1282 6480c871 2021-08-30 stsp
1283 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1284 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1285 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1286 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1287 6480c871 2021-08-30 stsp
1288 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1289 6480c871 2021-08-30 stsp ret="$?"
1290 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1291 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1292 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1293 6480c871 2021-08-30 stsp return 1
1294 6480c871 2021-08-30 stsp fi
1295 6480c871 2021-08-30 stsp
1296 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1297 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1298 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1299 6480c871 2021-08-30 stsp
1300 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1301 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1302 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1303 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1304 6480c871 2021-08-30 stsp
1305 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1306 6480c871 2021-08-30 stsp remote "origin" {
1307 6480c871 2021-08-30 stsp protocol ssh
1308 6480c871 2021-08-30 stsp server 127.0.0.1
1309 6480c871 2021-08-30 stsp send {
1310 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1311 6480c871 2021-08-30 stsp }
1312 6480c871 2021-08-30 stsp fetch {
1313 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1314 6480c871 2021-08-30 stsp }
1315 f8a36e22 2021-08-26 stsp }
1316 6480c871 2021-08-30 stsp EOF
1317 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1318 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1319 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1320 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1321 6480c871 2021-08-30 stsp return 1
1322 6480c871 2021-08-30 stsp fi
1323 f8a36e22 2021-08-26 stsp
1324 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1325 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1326 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1327 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1328 6480c871 2021-08-30 stsp ret="$?"
1329 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1330 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1331 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1332 6480c871 2021-08-30 stsp return 1
1333 6480c871 2021-08-30 stsp fi
1334 f8a36e22 2021-08-26 stsp
1335 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1336 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1337 6480c871 2021-08-30 stsp ret="$?"
1338 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1339 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1340 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1341 6480c871 2021-08-30 stsp return 1
1342 6480c871 2021-08-30 stsp fi
1343 6480c871 2021-08-30 stsp
1344 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1345 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1346 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1347 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1348 6480c871 2021-08-30 stsp return 1
1349 6480c871 2021-08-30 stsp fi
1350 6480c871 2021-08-30 stsp
1351 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1352 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1353 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1354 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1355 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1356 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1357 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1358 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1359 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1360 6480c871 2021-08-30 stsp ret="$?"
1361 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1362 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1363 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1364 6480c871 2021-08-30 stsp return 1
1365 6480c871 2021-08-30 stsp fi
1366 6480c871 2021-08-30 stsp
1367 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1368 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1369 6480c871 2021-08-30 stsp ret="$?"
1370 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1371 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1372 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1373 6480c871 2021-08-30 stsp return 1
1374 6480c871 2021-08-30 stsp fi
1375 6480c871 2021-08-30 stsp
1376 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1377 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1378 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1379 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1380 6480c871 2021-08-30 stsp return 1
1381 6480c871 2021-08-30 stsp fi
1382 6480c871 2021-08-30 stsp
1383 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1384 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1385 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1386 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1387 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1388 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1389 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1390 6480c871 2021-08-30 stsp
1391 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1392 6480c871 2021-08-30 stsp ret="$?"
1393 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1394 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1395 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1396 f0fd0aaf 2021-09-14 stsp return 1
1397 6480c871 2021-08-30 stsp fi
1398 6480c871 2021-08-30 stsp
1399 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1400 f0fd0aaf 2021-09-14 stsp ret="$?"
1401 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1402 eac1df47 2021-09-01 stsp }
1403 eac1df47 2021-09-01 stsp
1404 eac1df47 2021-09-01 stsp test_send_config() {
1405 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1406 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1407 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1408 eac1df47 2021-09-01 stsp
1409 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1410 eac1df47 2021-09-01 stsp ret="$?"
1411 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1412 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1413 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1414 eac1df47 2021-09-01 stsp return 1
1415 eac1df47 2021-09-01 stsp fi
1416 eac1df47 2021-09-01 stsp
1417 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1418 eac1df47 2021-09-01 stsp remote "origin" {
1419 eac1df47 2021-09-01 stsp protocol ssh
1420 eac1df47 2021-09-01 stsp server 127.0.0.1
1421 eac1df47 2021-09-01 stsp branch foo
1422 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1423 6480c871 2021-08-30 stsp }
1424 eac1df47 2021-09-01 stsp EOF
1425 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1426 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1427 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1428 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1429 eac1df47 2021-09-01 stsp return 1
1430 eac1df47 2021-09-01 stsp fi
1431 6480c871 2021-08-30 stsp
1432 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1433 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1434 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1435 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1436 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1437 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1438 eac1df47 2021-09-01 stsp
1439 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1440 eac1df47 2021-09-01 stsp ret="$?"
1441 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1442 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1443 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1444 eac1df47 2021-09-01 stsp return 1
1445 eac1df47 2021-09-01 stsp fi
1446 eac1df47 2021-09-01 stsp
1447 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1448 eac1df47 2021-09-01 stsp
1449 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1450 eac1df47 2021-09-01 stsp ret="$?"
1451 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1452 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1453 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1454 eac1df47 2021-09-01 stsp return 1
1455 eac1df47 2021-09-01 stsp fi
1456 eac1df47 2021-09-01 stsp
1457 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1458 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1459 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1460 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1461 eac1df47 2021-09-01 stsp return 1
1462 eac1df47 2021-09-01 stsp fi
1463 eac1df47 2021-09-01 stsp
1464 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1465 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1466 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1467 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1468 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1469 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1470 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1471 eac1df47 2021-09-01 stsp
1472 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1473 eac1df47 2021-09-01 stsp ret="$?"
1474 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1475 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1476 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1477 f0fd0aaf 2021-09-14 stsp return 1
1478 eac1df47 2021-09-01 stsp fi
1479 f0fd0aaf 2021-09-14 stsp
1480 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1481 f0fd0aaf 2021-09-14 stsp ret="$?"
1482 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1483 eac1df47 2021-09-01 stsp }
1484 eac1df47 2021-09-01 stsp
1485 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1486 f8a36e22 2021-08-26 stsp run_test test_send_basic
1487 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1488 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1489 f8a36e22 2021-08-26 stsp run_test test_send_delete
1490 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1491 f8a36e22 2021-08-26 stsp run_test test_send_tags
1492 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1493 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1494 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1495 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1496 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1497 eac1df47 2021-09-01 stsp run_test test_send_config