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