Blame


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