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