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