Blame


1 f8a36e22 2021-08-26 stsp #!/bin/sh
2 f8a36e22 2021-08-26 stsp #
3 f8a36e22 2021-08-26 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 f8a36e22 2021-08-26 stsp #
5 f8a36e22 2021-08-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp # copyright notice and this permission notice appear in all copies.
8 f8a36e22 2021-08-26 stsp #
9 f8a36e22 2021-08-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f8a36e22 2021-08-26 stsp
17 f8a36e22 2021-08-26 stsp . ./common.sh
18 f8a36e22 2021-08-26 stsp
19 f8a36e22 2021-08-26 stsp test_send_basic() {
20 f8a36e22 2021-08-26 stsp local testroot=`test_init send_basic`
21 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
22 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
23 f8a36e22 2021-08-26 stsp
24 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
25 f8a36e22 2021-08-26 stsp ret="$?"
26 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
27 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
28 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
29 f8a36e22 2021-08-26 stsp return 1
30 f8a36e22 2021-08-26 stsp fi
31 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
32 f8a36e22 2021-08-26 stsp remote "origin" {
33 f8a36e22 2021-08-26 stsp protocol ssh
34 f8a36e22 2021-08-26 stsp server 127.0.0.1
35 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
36 f8a36e22 2021-08-26 stsp }
37 f8a36e22 2021-08-26 stsp EOF
38 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
41 f8a36e22 2021-08-26 stsp
42 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
43 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
44 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
45 f8a36e22 2021-08-26 stsp
46 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
47 f8a36e22 2021-08-26 stsp ret="$?"
48 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
49 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
50 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
51 f8a36e22 2021-08-26 stsp return 1
52 f8a36e22 2021-08-26 stsp fi
53 f8a36e22 2021-08-26 stsp
54 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
55 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
56 f8a36e22 2021-08-26 stsp ret="$?"
57 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
58 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
59 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
60 f8a36e22 2021-08-26 stsp return 1
61 f8a36e22 2021-08-26 stsp fi
62 f8a36e22 2021-08-26 stsp
63 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
64 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
65 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
66 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
67 f8a36e22 2021-08-26 stsp return 1
68 f8a36e22 2021-08-26 stsp fi
69 f8a36e22 2021-08-26 stsp
70 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
71 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
72 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
73 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
74 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
75 f8a36e22 2021-08-26 stsp
76 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
77 f8a36e22 2021-08-26 stsp ret="$?"
78 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
79 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
81 f8a36e22 2021-08-26 stsp return 1
82 f8a36e22 2021-08-26 stsp fi
83 f8a36e22 2021-08-26 stsp
84 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
85 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
86 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
87 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
88 f8a36e22 2021-08-26 stsp return 1
89 f8a36e22 2021-08-26 stsp fi
90 f8a36e22 2021-08-26 stsp
91 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
92 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
93 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
94 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
95 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
96 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
97 f8a36e22 2021-08-26 stsp
98 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp ret="$?"
100 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
101 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
102 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
103 f8a36e22 2021-08-26 stsp return 1
104 f8a36e22 2021-08-26 stsp fi
105 f8a36e22 2021-08-26 stsp
106 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
107 f8a36e22 2021-08-26 stsp ret="$?"
108 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
109 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
110 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
111 f8a36e22 2021-08-26 stsp return 1
112 f8a36e22 2021-08-26 stsp fi
113 f8a36e22 2021-08-26 stsp
114 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
115 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
116 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
117 f8a36e22 2021-08-26 stsp ret="$?"
118 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
119 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
120 f8a36e22 2021-08-26 stsp fi
121 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
122 f8a36e22 2021-08-26 stsp }
123 f8a36e22 2021-08-26 stsp
124 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
125 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
126 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
127 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
128 f8a36e22 2021-08-26 stsp
129 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
130 f8a36e22 2021-08-26 stsp ret="$?"
131 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
132 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
133 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
134 f8a36e22 2021-08-26 stsp return 1
135 f8a36e22 2021-08-26 stsp fi
136 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
137 f8a36e22 2021-08-26 stsp remote "origin" {
138 f8a36e22 2021-08-26 stsp protocol ssh
139 f8a36e22 2021-08-26 stsp server 127.0.0.1
140 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
141 f8a36e22 2021-08-26 stsp }
142 f8a36e22 2021-08-26 stsp EOF
143 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
144 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
145 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
146 f8a36e22 2021-08-26 stsp
147 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
148 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
149 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
150 f8a36e22 2021-08-26 stsp
151 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
152 f8a36e22 2021-08-26 stsp ret="$?"
153 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
154 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
155 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
156 f8a36e22 2021-08-26 stsp return 1
157 f8a36e22 2021-08-26 stsp fi
158 f8a36e22 2021-08-26 stsp
159 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
160 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
161 f8a36e22 2021-08-26 stsp ret="$?"
162 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
163 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
164 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
165 f8a36e22 2021-08-26 stsp return 1
166 f8a36e22 2021-08-26 stsp fi
167 f8a36e22 2021-08-26 stsp
168 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
169 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
170 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
171 f8a36e22 2021-08-26 stsp ret="$?"
172 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
173 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
174 f8a36e22 2021-08-26 stsp fi
175 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
176 f8a36e22 2021-08-26 stsp }
177 f8a36e22 2021-08-26 stsp
178 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
179 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
180 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
181 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
182 f8a36e22 2021-08-26 stsp
183 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
184 f8a36e22 2021-08-26 stsp ret="$?"
185 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
186 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
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 cat > $testroot/repo/.git/got.conf <<EOF
191 f8a36e22 2021-08-26 stsp remote "foobar" {
192 f8a36e22 2021-08-26 stsp protocol ssh
193 f8a36e22 2021-08-26 stsp server 127.0.0.1
194 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
195 f8a36e22 2021-08-26 stsp }
196 f8a36e22 2021-08-26 stsp EOF
197 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
198 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
199 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
200 f8a36e22 2021-08-26 stsp
201 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
202 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
203 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
204 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
205 f8a36e22 2021-08-26 stsp
206 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
207 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
208 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
209 f8a36e22 2021-08-26 stsp ret="$?"
210 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
211 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
212 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
213 f8a36e22 2021-08-26 stsp return 1
214 f8a36e22 2021-08-26 stsp fi
215 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
216 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
217 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
218 f8a36e22 2021-08-26 stsp ret="$?"
219 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
220 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
222 f8a36e22 2021-08-26 stsp return 1
223 f8a36e22 2021-08-26 stsp fi
224 f8a36e22 2021-08-26 stsp
225 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
226 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
227 f8a36e22 2021-08-26 stsp ret="$?"
228 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
229 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
230 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
231 f8a36e22 2021-08-26 stsp return 1
232 f8a36e22 2021-08-26 stsp fi
233 f8a36e22 2021-08-26 stsp
234 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
235 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
236 f8a36e22 2021-08-26 stsp ret="$?"
237 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
238 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
239 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
240 f8a36e22 2021-08-26 stsp return 1
241 f8a36e22 2021-08-26 stsp fi
242 f8a36e22 2021-08-26 stsp
243 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
244 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
245 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
246 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
247 f8a36e22 2021-08-26 stsp return 1
248 f8a36e22 2021-08-26 stsp fi
249 f8a36e22 2021-08-26 stsp
250 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
251 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
252 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
253 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
254 f8a36e22 2021-08-26 stsp
255 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
256 f8a36e22 2021-08-26 stsp ret="$?"
257 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
258 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 f8a36e22 2021-08-26 stsp
263 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
264 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
265 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
266 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
267 f8a36e22 2021-08-26 stsp return 1
268 f8a36e22 2021-08-26 stsp fi
269 f8a36e22 2021-08-26 stsp
270 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
271 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
272 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
273 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
274 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
275 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
276 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
277 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
278 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
279 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
280 f8a36e22 2021-08-26 stsp
281 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
282 f8a36e22 2021-08-26 stsp ret="$?"
283 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
284 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 f8a36e22 2021-08-26 stsp fi
286 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
287 f8a36e22 2021-08-26 stsp }
288 f8a36e22 2021-08-26 stsp
289 f8a36e22 2021-08-26 stsp test_send_delete() {
290 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
291 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
292 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
293 f8a36e22 2021-08-26 stsp
294 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
295 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
296 f8a36e22 2021-08-26 stsp
297 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
298 f8a36e22 2021-08-26 stsp ret="$?"
299 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
300 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
301 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
302 f8a36e22 2021-08-26 stsp return 1
303 f8a36e22 2021-08-26 stsp fi
304 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
305 f8a36e22 2021-08-26 stsp remote "origin" {
306 f8a36e22 2021-08-26 stsp protocol ssh
307 f8a36e22 2021-08-26 stsp server 127.0.0.1
308 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
309 f8a36e22 2021-08-26 stsp }
310 f8a36e22 2021-08-26 stsp EOF
311 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
312 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
313 f8a36e22 2021-08-26 stsp
314 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
315 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
316 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
317 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
318 f8a36e22 2021-08-26 stsp return 1
319 f8a36e22 2021-08-26 stsp fi
320 f8a36e22 2021-08-26 stsp
321 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
322 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
323 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
324 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
325 f8a36e22 2021-08-26 stsp
326 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
327 f8a36e22 2021-08-26 stsp # time is not allowed.
328 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
329 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
330 f8a36e22 2021-08-26 stsp ret="$?"
331 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
332 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
333 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
334 f8a36e22 2021-08-26 stsp return 1
335 f8a36e22 2021-08-26 stsp fi
336 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
337 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
338 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
339 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
340 f8a36e22 2021-08-26 stsp ret="$?"
341 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
342 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
343 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
344 f8a36e22 2021-08-26 stsp return 1
345 f8a36e22 2021-08-26 stsp fi
346 f8a36e22 2021-08-26 stsp
347 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
348 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
349 f8a36e22 2021-08-26 stsp ret="$?"
350 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
351 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
352 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
353 f8a36e22 2021-08-26 stsp return 1
354 f8a36e22 2021-08-26 stsp fi
355 f8a36e22 2021-08-26 stsp
356 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
357 1bd76734 2021-08-26 stsp > $testroot/stdout.raw 2>$testroot/stderr
358 f8a36e22 2021-08-26 stsp ret="$?"
359 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
360 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
361 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
362 1bd76734 2021-08-26 stsp return 1
363 1bd76734 2021-08-26 stsp fi
364 1bd76734 2021-08-26 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
365 1bd76734 2021-08-26 stsp
366 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
367 1bd76734 2021-08-26 stsp echo -n "packing 0 references; 0 objects; deltify: 0%; " \
368 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
369 1bd76734 2021-08-26 stsp echo "uploading pack: 32B 100%" >> $testroot/stdout.expected
370 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
371 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
372 1bd76734 2021-08-26 stsp
373 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
374 1bd76734 2021-08-26 stsp ret="$?"
375 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
376 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
378 f8a36e22 2021-08-26 stsp return 1
379 f8a36e22 2021-08-26 stsp fi
380 f8a36e22 2021-08-26 stsp
381 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
382 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
383 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
384 f8a36e22 2021-08-26 stsp ret="$?"
385 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
386 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
387 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
388 f8a36e22 2021-08-26 stsp return 1
389 f8a36e22 2021-08-26 stsp fi
390 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
391 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
392 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
393 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
394 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
395 f8a36e22 2021-08-26 stsp ret="$?"
396 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
397 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
398 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
399 f8a36e22 2021-08-26 stsp return 1
400 f8a36e22 2021-08-26 stsp fi
401 f8a36e22 2021-08-26 stsp
402 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
403 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
404 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
405 f8a36e22 2021-08-26 stsp ret="$?"
406 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
407 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
408 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
409 f8a36e22 2021-08-26 stsp return 1
410 f8a36e22 2021-08-26 stsp fi
411 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
412 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
413 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
414 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
415 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
416 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
417 f8a36e22 2021-08-26 stsp ret="$?"
418 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
419 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
421 f8a36e22 2021-08-26 stsp return 1
422 f8a36e22 2021-08-26 stsp fi
423 f8a36e22 2021-08-26 stsp
424 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
425 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
426 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
427 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
428 f8a36e22 2021-08-26 stsp return 1
429 f8a36e22 2021-08-26 stsp fi
430 f8a36e22 2021-08-26 stsp
431 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
432 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
433 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
434 f8a36e22 2021-08-26 stsp
435 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
436 f8a36e22 2021-08-26 stsp ret="$?"
437 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
438 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
440 f8a36e22 2021-08-26 stsp return 1
441 f8a36e22 2021-08-26 stsp fi
442 f8a36e22 2021-08-26 stsp
443 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
444 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
445 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
446 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
447 f8a36e22 2021-08-26 stsp return 1
448 f8a36e22 2021-08-26 stsp fi
449 f8a36e22 2021-08-26 stsp
450 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
451 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
452 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
453 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
454 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
455 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
456 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
457 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
458 f8a36e22 2021-08-26 stsp
459 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
460 f8a36e22 2021-08-26 stsp ret="$?"
461 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
462 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
463 f8a36e22 2021-08-26 stsp fi
464 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
465 f8a36e22 2021-08-26 stsp }
466 f8a36e22 2021-08-26 stsp
467 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
468 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
469 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
470 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
471 f8a36e22 2021-08-26 stsp
472 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
473 f8a36e22 2021-08-26 stsp
474 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
475 f8a36e22 2021-08-26 stsp ret="$?"
476 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
477 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
478 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
479 f8a36e22 2021-08-26 stsp return 1
480 f8a36e22 2021-08-26 stsp fi
481 f8a36e22 2021-08-26 stsp
482 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
483 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
484 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
485 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
486 f8a36e22 2021-08-26 stsp
487 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
488 f8a36e22 2021-08-26 stsp ret="$?"
489 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
490 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
491 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
492 f8a36e22 2021-08-26 stsp return 1
493 f8a36e22 2021-08-26 stsp fi
494 f8a36e22 2021-08-26 stsp
495 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
496 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
497 f8a36e22 2021-08-26 stsp ret="$?"
498 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
499 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
501 f8a36e22 2021-08-26 stsp return 1
502 f8a36e22 2021-08-26 stsp fi
503 f8a36e22 2021-08-26 stsp
504 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
505 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
506 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
507 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
508 f8a36e22 2021-08-26 stsp return 1
509 f8a36e22 2021-08-26 stsp fi
510 f8a36e22 2021-08-26 stsp
511 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
512 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
513 f8a36e22 2021-08-26 stsp
514 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
515 f8a36e22 2021-08-26 stsp ret="$?"
516 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
517 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
518 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
519 f8a36e22 2021-08-26 stsp return 1
520 f8a36e22 2021-08-26 stsp fi
521 f8a36e22 2021-08-26 stsp
522 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
523 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
524 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
525 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
526 f8a36e22 2021-08-26 stsp return 1
527 f8a36e22 2021-08-26 stsp fi
528 f8a36e22 2021-08-26 stsp
529 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
530 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
531 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
532 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
533 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
534 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
535 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
536 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
537 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
538 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
539 f8a36e22 2021-08-26 stsp
540 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
541 f8a36e22 2021-08-26 stsp ret="$?"
542 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
543 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
544 f8a36e22 2021-08-26 stsp fi
545 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
546 f8a36e22 2021-08-26 stsp }
547 f8a36e22 2021-08-26 stsp
548 f8a36e22 2021-08-26 stsp test_send_tags() {
549 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
550 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
551 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
552 f8a36e22 2021-08-26 stsp
553 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
554 f8a36e22 2021-08-26 stsp ret="$?"
555 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
556 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
557 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
558 f8a36e22 2021-08-26 stsp return 1
559 f8a36e22 2021-08-26 stsp fi
560 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
561 f8a36e22 2021-08-26 stsp remote "origin" {
562 f8a36e22 2021-08-26 stsp protocol ssh
563 f8a36e22 2021-08-26 stsp server 127.0.0.1
564 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
565 f8a36e22 2021-08-26 stsp }
566 f8a36e22 2021-08-26 stsp EOF
567 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
568 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
569 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
570 f8a36e22 2021-08-26 stsp
571 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
572 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
573 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
574 f8a36e22 2021-08-26 stsp
575 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
576 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
577 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
578 f8a36e22 2021-08-26 stsp
579 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
580 f8a36e22 2021-08-26 stsp ret="$?"
581 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
582 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
583 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
584 f8a36e22 2021-08-26 stsp return 1
585 f8a36e22 2021-08-26 stsp fi
586 f8a36e22 2021-08-26 stsp
587 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
588 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
589 f8a36e22 2021-08-26 stsp ret="$?"
590 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
591 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
593 f8a36e22 2021-08-26 stsp return 1
594 f8a36e22 2021-08-26 stsp fi
595 f8a36e22 2021-08-26 stsp
596 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
597 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
598 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
599 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
600 f8a36e22 2021-08-26 stsp return 1
601 f8a36e22 2021-08-26 stsp fi
602 f8a36e22 2021-08-26 stsp
603 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
604 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
605 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
606 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
607 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
608 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
609 f8a36e22 2021-08-26 stsp
610 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
611 f8a36e22 2021-08-26 stsp ret="$?"
612 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
613 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
614 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
615 f8a36e22 2021-08-26 stsp return 1
616 f8a36e22 2021-08-26 stsp fi
617 f8a36e22 2021-08-26 stsp
618 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
619 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
620 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
621 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
622 f8a36e22 2021-08-26 stsp return 1
623 f8a36e22 2021-08-26 stsp fi
624 f8a36e22 2021-08-26 stsp
625 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
626 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
627 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
628 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
629 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
630 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
631 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
632 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
633 f8a36e22 2021-08-26 stsp
634 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
635 f8a36e22 2021-08-26 stsp ret="$?"
636 f8a36e22 2021-08-26 stsp if [ "$ret" != "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 tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
643 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
644 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
645 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
646 f8a36e22 2021-08-26 stsp ret="$?"
647 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
648 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
649 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
650 f8a36e22 2021-08-26 stsp return 1
651 f8a36e22 2021-08-26 stsp fi
652 f8a36e22 2021-08-26 stsp
653 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
654 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
655 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
656 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
657 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
658 f8a36e22 2021-08-26 stsp
659 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
660 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
661 f8a36e22 2021-08-26 stsp ret="$?"
662 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
663 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
664 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
665 f8a36e22 2021-08-26 stsp return 1
666 f8a36e22 2021-08-26 stsp fi
667 f8a36e22 2021-08-26 stsp
668 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
669 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
670 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
671 f8a36e22 2021-08-26 stsp ret="$?"
672 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
673 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
674 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
675 f8a36e22 2021-08-26 stsp return 1
676 f8a36e22 2021-08-26 stsp fi
677 f8a36e22 2021-08-26 stsp
678 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
679 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
680 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
681 f8a36e22 2021-08-26 stsp ret="$?"
682 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
683 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
684 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
685 f8a36e22 2021-08-26 stsp return 1
686 f8a36e22 2021-08-26 stsp fi
687 f8a36e22 2021-08-26 stsp
688 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
689 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
690 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
691 f8a36e22 2021-08-26 stsp ret="$?"
692 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
693 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
694 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
695 f8a36e22 2021-08-26 stsp return 1
696 f8a36e22 2021-08-26 stsp fi
697 f8a36e22 2021-08-26 stsp
698 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
699 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
700 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
701 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
702 f8a36e22 2021-08-26 stsp ret="$?"
703 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
704 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
706 f8a36e22 2021-08-26 stsp return 1
707 f8a36e22 2021-08-26 stsp fi
708 f8a36e22 2021-08-26 stsp
709 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
710 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
711 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
712 f8a36e22 2021-08-26 stsp ret="$?"
713 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
714 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
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 got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
720 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
721 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
722 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
723 f8a36e22 2021-08-26 stsp ret="$?"
724 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
725 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
726 f8a36e22 2021-08-26 stsp fi
727 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
728 f8a36e22 2021-08-26 stsp }
729 f8a36e22 2021-08-26 stsp
730 f8a36e22 2021-08-26 stsp test_send_new_branch() {
731 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
732 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
733 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
734 f8a36e22 2021-08-26 stsp
735 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
736 f8a36e22 2021-08-26 stsp
737 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
738 f8a36e22 2021-08-26 stsp ret="$?"
739 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
740 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
741 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
742 f8a36e22 2021-08-26 stsp return 1
743 f8a36e22 2021-08-26 stsp fi
744 f8a36e22 2021-08-26 stsp
745 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
746 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
747 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
748 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
749 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
750 f8a36e22 2021-08-26 stsp
751 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
752 f8a36e22 2021-08-26 stsp ret="$?"
753 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
754 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
755 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
756 f8a36e22 2021-08-26 stsp return 1
757 f8a36e22 2021-08-26 stsp fi
758 f8a36e22 2021-08-26 stsp
759 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
760 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
761 f8a36e22 2021-08-26 stsp ret="$?"
762 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
763 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
764 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
765 f8a36e22 2021-08-26 stsp return 1
766 f8a36e22 2021-08-26 stsp fi
767 f8a36e22 2021-08-26 stsp
768 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
769 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
770 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
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 f8a36e22 2021-08-26 stsp
775 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
776 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
777 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
778 f8a36e22 2021-08-26 stsp
779 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
780 f8a36e22 2021-08-26 stsp ret="$?"
781 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
782 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 f8a36e22 2021-08-26 stsp
787 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
788 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
789 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
790 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
791 f8a36e22 2021-08-26 stsp return 1
792 f8a36e22 2021-08-26 stsp fi
793 f8a36e22 2021-08-26 stsp
794 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
795 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
796 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
797 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
798 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
799 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
800 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
801 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
802 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
803 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
804 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
805 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
806 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
807 f8a36e22 2021-08-26 stsp
808 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
809 f8a36e22 2021-08-26 stsp ret="$?"
810 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
811 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
812 f8a36e22 2021-08-26 stsp fi
813 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
814 f8a36e22 2021-08-26 stsp }
815 f8a36e22 2021-08-26 stsp
816 f8a36e22 2021-08-26 stsp test_send_all_branches() {
817 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
818 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
819 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
820 f8a36e22 2021-08-26 stsp
821 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
822 f8a36e22 2021-08-26 stsp
823 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
824 f8a36e22 2021-08-26 stsp ret="$?"
825 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
826 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
827 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
828 f8a36e22 2021-08-26 stsp return 1
829 f8a36e22 2021-08-26 stsp fi
830 f8a36e22 2021-08-26 stsp
831 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
832 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
833 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
834 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
835 f8a36e22 2021-08-26 stsp
836 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
837 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
838 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
839 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
840 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
841 f8a36e22 2021-08-26 stsp
842 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
843 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
844 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
845 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
846 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
847 f8a36e22 2021-08-26 stsp
848 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
849 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
850 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
851 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
852 f8a36e22 2021-08-26 stsp return 1
853 f8a36e22 2021-08-26 stsp fi
854 f8a36e22 2021-08-26 stsp
855 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
856 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
857 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
858 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
859 f8a36e22 2021-08-26 stsp
860 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
861 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
862 f8a36e22 2021-08-26 stsp ret="$?"
863 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
864 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
865 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
866 f8a36e22 2021-08-26 stsp return 1
867 f8a36e22 2021-08-26 stsp fi
868 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
869 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
870 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
871 f8a36e22 2021-08-26 stsp ret="$?"
872 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
873 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
874 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
875 f8a36e22 2021-08-26 stsp return 1
876 f8a36e22 2021-08-26 stsp fi
877 f8a36e22 2021-08-26 stsp
878 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
879 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
880 f8a36e22 2021-08-26 stsp ret="$?"
881 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
882 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
883 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
884 f8a36e22 2021-08-26 stsp return 1
885 f8a36e22 2021-08-26 stsp fi
886 f8a36e22 2021-08-26 stsp
887 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
888 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
889 f8a36e22 2021-08-26 stsp ret="$?"
890 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
891 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
892 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
893 f8a36e22 2021-08-26 stsp return 1
894 f8a36e22 2021-08-26 stsp fi
895 f8a36e22 2021-08-26 stsp
896 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
897 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
898 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
899 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
900 f8a36e22 2021-08-26 stsp return 1
901 f8a36e22 2021-08-26 stsp fi
902 f8a36e22 2021-08-26 stsp
903 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
904 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
905 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
906 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
907 f8a36e22 2021-08-26 stsp
908 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
909 f8a36e22 2021-08-26 stsp ret="$?"
910 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
911 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
912 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
913 f8a36e22 2021-08-26 stsp return 1
914 f8a36e22 2021-08-26 stsp fi
915 f8a36e22 2021-08-26 stsp
916 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
917 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
918 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
919 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
920 f8a36e22 2021-08-26 stsp return 1
921 f8a36e22 2021-08-26 stsp fi
922 f8a36e22 2021-08-26 stsp
923 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
924 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
925 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
926 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
927 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
928 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
929 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
930 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
931 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
932 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
933 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
934 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
935 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
936 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
937 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
938 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
939 f8a36e22 2021-08-26 stsp
940 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
941 f8a36e22 2021-08-26 stsp ret="$?"
942 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
943 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
944 f8a36e22 2021-08-26 stsp fi
945 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
946 f8a36e22 2021-08-26 stsp }
947 f8a36e22 2021-08-26 stsp
948 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
949 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
950 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
951 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
952 f8a36e22 2021-08-26 stsp
953 f8a36e22 2021-08-26 stsp got init $testroot/repo2
954 f8a36e22 2021-08-26 stsp
955 f8a36e22 2021-08-26 stsp ret="$?"
956 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
957 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
958 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
959 f8a36e22 2021-08-26 stsp return 1
960 f8a36e22 2021-08-26 stsp fi
961 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
962 f8a36e22 2021-08-26 stsp remote "origin" {
963 f8a36e22 2021-08-26 stsp protocol ssh
964 f8a36e22 2021-08-26 stsp server 127.0.0.1
965 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
966 f8a36e22 2021-08-26 stsp }
967 f8a36e22 2021-08-26 stsp EOF
968 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
969 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
970 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
971 f8a36e22 2021-08-26 stsp
972 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
973 f8a36e22 2021-08-26 stsp ret="$?"
974 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
975 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
976 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
977 f8a36e22 2021-08-26 stsp return 1
978 f8a36e22 2021-08-26 stsp fi
979 f8a36e22 2021-08-26 stsp
980 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
981 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
982 f8a36e22 2021-08-26 stsp ret="$?"
983 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
984 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
986 f8a36e22 2021-08-26 stsp return 1
987 f8a36e22 2021-08-26 stsp fi
988 f8a36e22 2021-08-26 stsp
989 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
990 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
991 f8a36e22 2021-08-26 stsp
992 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
993 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
994 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
995 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
996 f8a36e22 2021-08-26 stsp return 1
997 f8a36e22 2021-08-26 stsp fi
998 f8a36e22 2021-08-26 stsp
999 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1000 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1001 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1002 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1003 f8a36e22 2021-08-26 stsp
1004 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1005 f8a36e22 2021-08-26 stsp ret="$?"
1006 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1007 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1008 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1009 f8a36e22 2021-08-26 stsp return 1
1010 f8a36e22 2021-08-26 stsp fi
1011 f8a36e22 2021-08-26 stsp
1012 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1013 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1014 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1015 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1016 f8a36e22 2021-08-26 stsp return 1
1017 f8a36e22 2021-08-26 stsp fi
1018 f8a36e22 2021-08-26 stsp
1019 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1020 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1021 f8a36e22 2021-08-26 stsp
1022 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1023 f8a36e22 2021-08-26 stsp ret="$?"
1024 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1025 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1027 f8a36e22 2021-08-26 stsp return 1
1028 f8a36e22 2021-08-26 stsp fi
1029 f8a36e22 2021-08-26 stsp
1030 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1031 f8a36e22 2021-08-26 stsp ret="$?"
1032 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1033 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1034 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1035 f8a36e22 2021-08-26 stsp return 1
1036 f8a36e22 2021-08-26 stsp fi
1037 f8a36e22 2021-08-26 stsp
1038 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1039 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1041 f8a36e22 2021-08-26 stsp ret="$?"
1042 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1043 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 f8a36e22 2021-08-26 stsp fi
1045 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1046 f8a36e22 2021-08-26 stsp }
1047 f8a36e22 2021-08-26 stsp
1048 f8a36e22 2021-08-26 stsp
1049 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1050 f8a36e22 2021-08-26 stsp run_test test_send_basic
1051 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1052 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1053 f8a36e22 2021-08-26 stsp run_test test_send_delete
1054 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1055 f8a36e22 2021-08-26 stsp run_test test_send_tags
1056 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1057 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1058 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo