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 27b75514 2021-08-28 stsp > $testroot/stdout 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
365 1bd76734 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
366 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
367 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
368 1bd76734 2021-08-26 stsp
369 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
370 1bd76734 2021-08-26 stsp ret="$?"
371 1bd76734 2021-08-26 stsp if [ "$ret" != "0" ]; then
372 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
373 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
374 f8a36e22 2021-08-26 stsp return 1
375 f8a36e22 2021-08-26 stsp fi
376 f8a36e22 2021-08-26 stsp
377 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
378 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
379 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
380 f8a36e22 2021-08-26 stsp ret="$?"
381 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
382 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
383 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
384 f8a36e22 2021-08-26 stsp return 1
385 f8a36e22 2021-08-26 stsp fi
386 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
387 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
388 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
389 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
390 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
391 f8a36e22 2021-08-26 stsp ret="$?"
392 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
393 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
394 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
395 f8a36e22 2021-08-26 stsp return 1
396 f8a36e22 2021-08-26 stsp fi
397 f8a36e22 2021-08-26 stsp
398 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
399 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
400 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
401 f8a36e22 2021-08-26 stsp ret="$?"
402 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
403 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
404 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
405 f8a36e22 2021-08-26 stsp return 1
406 f8a36e22 2021-08-26 stsp fi
407 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
408 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
409 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
410 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
411 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
412 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
413 f8a36e22 2021-08-26 stsp ret="$?"
414 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
415 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
416 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
417 f8a36e22 2021-08-26 stsp return 1
418 f8a36e22 2021-08-26 stsp fi
419 f8a36e22 2021-08-26 stsp
420 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
421 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
422 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
423 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
424 f8a36e22 2021-08-26 stsp return 1
425 f8a36e22 2021-08-26 stsp fi
426 f8a36e22 2021-08-26 stsp
427 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
428 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
429 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
430 f8a36e22 2021-08-26 stsp
431 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
432 f8a36e22 2021-08-26 stsp ret="$?"
433 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
434 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
435 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
436 f8a36e22 2021-08-26 stsp return 1
437 f8a36e22 2021-08-26 stsp fi
438 f8a36e22 2021-08-26 stsp
439 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
440 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
441 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
442 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
443 f8a36e22 2021-08-26 stsp return 1
444 f8a36e22 2021-08-26 stsp fi
445 f8a36e22 2021-08-26 stsp
446 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
447 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
448 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
449 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
450 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
451 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
452 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
453 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
454 f8a36e22 2021-08-26 stsp
455 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
456 f8a36e22 2021-08-26 stsp ret="$?"
457 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
458 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
459 f8a36e22 2021-08-26 stsp fi
460 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
461 f8a36e22 2021-08-26 stsp }
462 f8a36e22 2021-08-26 stsp
463 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
464 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
465 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
466 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
467 f8a36e22 2021-08-26 stsp
468 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
469 f8a36e22 2021-08-26 stsp
470 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
471 f8a36e22 2021-08-26 stsp ret="$?"
472 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
473 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
474 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
475 f8a36e22 2021-08-26 stsp return 1
476 f8a36e22 2021-08-26 stsp fi
477 f8a36e22 2021-08-26 stsp
478 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
479 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
480 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
481 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
482 f8a36e22 2021-08-26 stsp
483 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
484 f8a36e22 2021-08-26 stsp ret="$?"
485 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
486 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
487 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
488 f8a36e22 2021-08-26 stsp return 1
489 f8a36e22 2021-08-26 stsp fi
490 f8a36e22 2021-08-26 stsp
491 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
492 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
493 f8a36e22 2021-08-26 stsp ret="$?"
494 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
495 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
497 f8a36e22 2021-08-26 stsp return 1
498 f8a36e22 2021-08-26 stsp fi
499 f8a36e22 2021-08-26 stsp
500 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
501 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
502 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
503 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
504 f8a36e22 2021-08-26 stsp return 1
505 f8a36e22 2021-08-26 stsp fi
506 f8a36e22 2021-08-26 stsp
507 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
508 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
509 f8a36e22 2021-08-26 stsp
510 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
511 f8a36e22 2021-08-26 stsp ret="$?"
512 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
513 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
514 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
515 f8a36e22 2021-08-26 stsp return 1
516 f8a36e22 2021-08-26 stsp fi
517 f8a36e22 2021-08-26 stsp
518 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
519 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
520 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
521 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
522 f8a36e22 2021-08-26 stsp return 1
523 f8a36e22 2021-08-26 stsp fi
524 f8a36e22 2021-08-26 stsp
525 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
526 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
527 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
529 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
531 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
532 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
533 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
534 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
535 f8a36e22 2021-08-26 stsp
536 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
537 f8a36e22 2021-08-26 stsp ret="$?"
538 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
539 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
540 f8a36e22 2021-08-26 stsp fi
541 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
542 f8a36e22 2021-08-26 stsp }
543 f8a36e22 2021-08-26 stsp
544 f8a36e22 2021-08-26 stsp test_send_tags() {
545 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
546 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
547 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
548 f8a36e22 2021-08-26 stsp
549 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
550 f8a36e22 2021-08-26 stsp ret="$?"
551 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
552 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
553 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
554 f8a36e22 2021-08-26 stsp return 1
555 f8a36e22 2021-08-26 stsp fi
556 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
557 f8a36e22 2021-08-26 stsp remote "origin" {
558 f8a36e22 2021-08-26 stsp protocol ssh
559 f8a36e22 2021-08-26 stsp server 127.0.0.1
560 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
561 f8a36e22 2021-08-26 stsp }
562 f8a36e22 2021-08-26 stsp EOF
563 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
564 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
565 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
566 f8a36e22 2021-08-26 stsp
567 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
568 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
569 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
570 f8a36e22 2021-08-26 stsp
571 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
572 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
573 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
574 f8a36e22 2021-08-26 stsp
575 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
576 f8a36e22 2021-08-26 stsp ret="$?"
577 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
578 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
579 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
580 f8a36e22 2021-08-26 stsp return 1
581 f8a36e22 2021-08-26 stsp fi
582 f8a36e22 2021-08-26 stsp
583 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
584 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
585 f8a36e22 2021-08-26 stsp ret="$?"
586 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
587 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
589 f8a36e22 2021-08-26 stsp return 1
590 f8a36e22 2021-08-26 stsp fi
591 f8a36e22 2021-08-26 stsp
592 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
593 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
594 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
595 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
596 f8a36e22 2021-08-26 stsp return 1
597 f8a36e22 2021-08-26 stsp fi
598 f8a36e22 2021-08-26 stsp
599 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
600 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
601 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
602 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
603 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
604 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
605 f8a36e22 2021-08-26 stsp
606 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
607 f8a36e22 2021-08-26 stsp ret="$?"
608 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
609 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
610 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
611 f8a36e22 2021-08-26 stsp return 1
612 f8a36e22 2021-08-26 stsp fi
613 f8a36e22 2021-08-26 stsp
614 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
615 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
616 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
617 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
618 f8a36e22 2021-08-26 stsp return 1
619 f8a36e22 2021-08-26 stsp fi
620 f8a36e22 2021-08-26 stsp
621 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
622 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
623 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
624 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
625 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
626 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
627 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
628 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
629 f8a36e22 2021-08-26 stsp
630 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
631 f8a36e22 2021-08-26 stsp ret="$?"
632 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
633 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
634 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
635 f8a36e22 2021-08-26 stsp return 1
636 f8a36e22 2021-08-26 stsp fi
637 f8a36e22 2021-08-26 stsp
638 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
639 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
640 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
641 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
642 f8a36e22 2021-08-26 stsp ret="$?"
643 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
644 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
645 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
646 f8a36e22 2021-08-26 stsp return 1
647 f8a36e22 2021-08-26 stsp fi
648 f8a36e22 2021-08-26 stsp
649 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
650 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
651 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
652 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
653 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
654 f8a36e22 2021-08-26 stsp
655 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
656 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
657 f8a36e22 2021-08-26 stsp ret="$?"
658 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
659 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
660 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
661 f8a36e22 2021-08-26 stsp return 1
662 f8a36e22 2021-08-26 stsp fi
663 f8a36e22 2021-08-26 stsp
664 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
665 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
666 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
667 f8a36e22 2021-08-26 stsp ret="$?"
668 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
669 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
670 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
671 f8a36e22 2021-08-26 stsp return 1
672 f8a36e22 2021-08-26 stsp fi
673 f8a36e22 2021-08-26 stsp
674 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
675 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
676 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
677 f8a36e22 2021-08-26 stsp ret="$?"
678 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
679 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
680 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
681 f8a36e22 2021-08-26 stsp return 1
682 f8a36e22 2021-08-26 stsp fi
683 f8a36e22 2021-08-26 stsp
684 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
685 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
686 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
687 f8a36e22 2021-08-26 stsp ret="$?"
688 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
689 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
690 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
691 f8a36e22 2021-08-26 stsp return 1
692 f8a36e22 2021-08-26 stsp fi
693 f8a36e22 2021-08-26 stsp
694 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
695 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
696 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
697 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
698 f8a36e22 2021-08-26 stsp ret="$?"
699 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
700 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
701 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
702 f8a36e22 2021-08-26 stsp return 1
703 f8a36e22 2021-08-26 stsp fi
704 f8a36e22 2021-08-26 stsp
705 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
706 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
707 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
708 f8a36e22 2021-08-26 stsp ret="$?"
709 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
710 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
711 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
712 f8a36e22 2021-08-26 stsp return 1
713 f8a36e22 2021-08-26 stsp fi
714 f8a36e22 2021-08-26 stsp
715 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
716 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
717 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
718 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
719 f8a36e22 2021-08-26 stsp ret="$?"
720 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
721 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
722 f8a36e22 2021-08-26 stsp fi
723 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
724 f8a36e22 2021-08-26 stsp }
725 f8a36e22 2021-08-26 stsp
726 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
727 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
728 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
729 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
730 26960ff7 2021-09-14 stsp
731 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
732 26960ff7 2021-09-14 stsp ret="$?"
733 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
734 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
735 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
736 26960ff7 2021-09-14 stsp return 1
737 26960ff7 2021-09-14 stsp fi
738 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
739 26960ff7 2021-09-14 stsp remote "origin" {
740 26960ff7 2021-09-14 stsp protocol ssh
741 26960ff7 2021-09-14 stsp server 127.0.0.1
742 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
743 26960ff7 2021-09-14 stsp }
744 26960ff7 2021-09-14 stsp EOF
745 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
746 26960ff7 2021-09-14 stsp
747 26960ff7 2021-09-14 stsp # modify alpha on branch foo
748 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
749 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
750 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
751 26960ff7 2021-09-14 stsp > /dev/null)
752 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
753 26960ff7 2021-09-14 stsp
754 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
755 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
756 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
757 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
758 26960ff7 2021-09-14 stsp
759 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
760 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
761 26960ff7 2021-09-14 stsp
762 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
763 26960ff7 2021-09-14 stsp # and the tag
764 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
765 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
766 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
767 26960ff7 2021-09-14 stsp
768 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
769 26960ff7 2021-09-14 stsp ret="$?"
770 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
771 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
772 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
773 26960ff7 2021-09-14 stsp return 1
774 26960ff7 2021-09-14 stsp fi
775 26960ff7 2021-09-14 stsp
776 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
777 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
778 26960ff7 2021-09-14 stsp ret="$?"
779 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
780 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
781 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
782 26960ff7 2021-09-14 stsp return 1
783 26960ff7 2021-09-14 stsp fi
784 26960ff7 2021-09-14 stsp
785 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
786 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
787 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
788 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
789 26960ff7 2021-09-14 stsp return 1
790 26960ff7 2021-09-14 stsp fi
791 26960ff7 2021-09-14 stsp
792 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
793 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
794 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
795 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
796 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
797 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
798 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
799 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
800 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
801 26960ff7 2021-09-14 stsp
802 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
803 26960ff7 2021-09-14 stsp ret="$?"
804 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
805 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
806 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
807 26960ff7 2021-09-14 stsp return 1
808 26960ff7 2021-09-14 stsp fi
809 26960ff7 2021-09-14 stsp
810 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
811 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
812 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
813 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
814 26960ff7 2021-09-14 stsp return 1
815 26960ff7 2021-09-14 stsp fi
816 26960ff7 2021-09-14 stsp
817 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
818 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
819 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
820 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
821 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
822 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
823 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
824 26960ff7 2021-09-14 stsp
825 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
826 26960ff7 2021-09-14 stsp ret="$?"
827 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
828 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
829 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
830 26960ff7 2021-09-14 stsp return 1
831 26960ff7 2021-09-14 stsp fi
832 26960ff7 2021-09-14 stsp
833 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
834 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
835 26960ff7 2021-09-14 stsp
836 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
837 26960ff7 2021-09-14 stsp ret="$?"
838 26960ff7 2021-09-14 stsp if [ "$ret" != "0" ]; then
839 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
840 26960ff7 2021-09-14 stsp fi
841 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
842 26960ff7 2021-09-14 stsp }
843 26960ff7 2021-09-14 stsp
844 f8a36e22 2021-08-26 stsp test_send_new_branch() {
845 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
846 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
847 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
848 f8a36e22 2021-08-26 stsp
849 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
850 f8a36e22 2021-08-26 stsp
851 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
852 f8a36e22 2021-08-26 stsp ret="$?"
853 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
854 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
855 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
856 f8a36e22 2021-08-26 stsp return 1
857 f8a36e22 2021-08-26 stsp fi
858 f8a36e22 2021-08-26 stsp
859 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
860 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
861 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
862 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
863 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
864 f8a36e22 2021-08-26 stsp
865 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
866 f8a36e22 2021-08-26 stsp ret="$?"
867 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
868 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
869 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
870 f8a36e22 2021-08-26 stsp return 1
871 f8a36e22 2021-08-26 stsp fi
872 f8a36e22 2021-08-26 stsp
873 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
874 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
875 f8a36e22 2021-08-26 stsp ret="$?"
876 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
877 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
879 f8a36e22 2021-08-26 stsp return 1
880 f8a36e22 2021-08-26 stsp fi
881 f8a36e22 2021-08-26 stsp
882 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
883 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
884 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
885 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
886 f8a36e22 2021-08-26 stsp return 1
887 f8a36e22 2021-08-26 stsp fi
888 f8a36e22 2021-08-26 stsp
889 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
890 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
891 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
892 f8a36e22 2021-08-26 stsp
893 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
894 f8a36e22 2021-08-26 stsp ret="$?"
895 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
896 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
898 f8a36e22 2021-08-26 stsp return 1
899 f8a36e22 2021-08-26 stsp fi
900 f8a36e22 2021-08-26 stsp
901 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
902 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
903 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
904 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
905 f8a36e22 2021-08-26 stsp return 1
906 f8a36e22 2021-08-26 stsp fi
907 f8a36e22 2021-08-26 stsp
908 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
909 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
910 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
911 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
912 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
913 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
914 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
915 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
916 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
917 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
918 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
919 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
920 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
921 f8a36e22 2021-08-26 stsp
922 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
923 f8a36e22 2021-08-26 stsp ret="$?"
924 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
925 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
926 f8a36e22 2021-08-26 stsp fi
927 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
928 f8a36e22 2021-08-26 stsp }
929 f8a36e22 2021-08-26 stsp
930 f8a36e22 2021-08-26 stsp test_send_all_branches() {
931 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
932 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
933 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
934 f8a36e22 2021-08-26 stsp
935 f8a36e22 2021-08-26 stsp (cd $testroot/repo && git config receive.denyCurrentBranch ignore)
936 f8a36e22 2021-08-26 stsp
937 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
938 f8a36e22 2021-08-26 stsp ret="$?"
939 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
940 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
941 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
942 f8a36e22 2021-08-26 stsp return 1
943 f8a36e22 2021-08-26 stsp fi
944 f8a36e22 2021-08-26 stsp
945 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
946 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
947 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
948 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
949 f8a36e22 2021-08-26 stsp
950 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
951 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
952 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
953 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
954 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
955 f8a36e22 2021-08-26 stsp
956 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
957 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
958 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
959 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
960 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
961 f8a36e22 2021-08-26 stsp
962 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
963 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
964 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
965 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
966 f8a36e22 2021-08-26 stsp return 1
967 f8a36e22 2021-08-26 stsp fi
968 f8a36e22 2021-08-26 stsp
969 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
970 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
971 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
972 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
973 f8a36e22 2021-08-26 stsp
974 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
975 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
976 f8a36e22 2021-08-26 stsp ret="$?"
977 f9756a57 2021-08-26 stsp if [ "$ret" = "0" ]; then
978 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
979 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
980 f8a36e22 2021-08-26 stsp return 1
981 f8a36e22 2021-08-26 stsp fi
982 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
983 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
984 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
985 f8a36e22 2021-08-26 stsp ret="$?"
986 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
987 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
988 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
989 f8a36e22 2021-08-26 stsp return 1
990 f8a36e22 2021-08-26 stsp fi
991 f8a36e22 2021-08-26 stsp
992 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
993 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
994 f8a36e22 2021-08-26 stsp ret="$?"
995 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
996 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
997 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
998 f8a36e22 2021-08-26 stsp return 1
999 f8a36e22 2021-08-26 stsp fi
1000 f8a36e22 2021-08-26 stsp
1001 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1002 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1003 f8a36e22 2021-08-26 stsp ret="$?"
1004 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1005 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1006 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1007 f8a36e22 2021-08-26 stsp return 1
1008 f8a36e22 2021-08-26 stsp fi
1009 f8a36e22 2021-08-26 stsp
1010 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1011 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1012 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1013 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1014 f8a36e22 2021-08-26 stsp return 1
1015 f8a36e22 2021-08-26 stsp fi
1016 f8a36e22 2021-08-26 stsp
1017 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1018 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1019 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $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 ref -l -r $testroot/repo-clone > $testroot/stdout
1031 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1032 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1033 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1034 f8a36e22 2021-08-26 stsp return 1
1035 f8a36e22 2021-08-26 stsp fi
1036 f8a36e22 2021-08-26 stsp
1037 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1038 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1039 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1040 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1041 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1042 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1043 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1044 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1045 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1046 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1047 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1048 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1049 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1050 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1051 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1052 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1053 f8a36e22 2021-08-26 stsp
1054 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1055 f8a36e22 2021-08-26 stsp ret="$?"
1056 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1057 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1058 f8a36e22 2021-08-26 stsp fi
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_to_empty_repo() {
1063 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
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 got init $testroot/repo2
1068 f8a36e22 2021-08-26 stsp
1069 f8a36e22 2021-08-26 stsp ret="$?"
1070 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1071 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1072 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1073 f8a36e22 2021-08-26 stsp return 1
1074 f8a36e22 2021-08-26 stsp fi
1075 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1076 f8a36e22 2021-08-26 stsp remote "origin" {
1077 f8a36e22 2021-08-26 stsp protocol ssh
1078 f8a36e22 2021-08-26 stsp server 127.0.0.1
1079 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1080 f8a36e22 2021-08-26 stsp }
1081 f8a36e22 2021-08-26 stsp EOF
1082 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1083 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1084 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1085 f8a36e22 2021-08-26 stsp
1086 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1087 f8a36e22 2021-08-26 stsp ret="$?"
1088 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1089 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1090 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1091 f8a36e22 2021-08-26 stsp return 1
1092 f8a36e22 2021-08-26 stsp fi
1093 f8a36e22 2021-08-26 stsp
1094 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1095 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1096 f8a36e22 2021-08-26 stsp ret="$?"
1097 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1098 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1099 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1100 f8a36e22 2021-08-26 stsp return 1
1101 f8a36e22 2021-08-26 stsp fi
1102 f8a36e22 2021-08-26 stsp
1103 f8a36e22 2021-08-26 stsp # XXX Workaround: We cannot give the target for HEAD to 'got init'
1104 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1105 f8a36e22 2021-08-26 stsp
1106 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1107 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1108 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1109 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1110 f8a36e22 2021-08-26 stsp return 1
1111 f8a36e22 2021-08-26 stsp fi
1112 f8a36e22 2021-08-26 stsp
1113 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1114 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1115 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1116 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1117 f8a36e22 2021-08-26 stsp
1118 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1119 f8a36e22 2021-08-26 stsp ret="$?"
1120 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1121 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1122 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1123 f8a36e22 2021-08-26 stsp return 1
1124 f8a36e22 2021-08-26 stsp fi
1125 f8a36e22 2021-08-26 stsp
1126 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1127 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1128 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1129 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1130 f8a36e22 2021-08-26 stsp return 1
1131 f8a36e22 2021-08-26 stsp fi
1132 f8a36e22 2021-08-26 stsp
1133 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1134 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1135 f8a36e22 2021-08-26 stsp
1136 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1137 f8a36e22 2021-08-26 stsp ret="$?"
1138 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1139 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1140 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1141 f8a36e22 2021-08-26 stsp return 1
1142 f8a36e22 2021-08-26 stsp fi
1143 f8a36e22 2021-08-26 stsp
1144 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1145 f8a36e22 2021-08-26 stsp ret="$?"
1146 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1147 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1148 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1149 f8a36e22 2021-08-26 stsp return 1
1150 f8a36e22 2021-08-26 stsp fi
1151 f8a36e22 2021-08-26 stsp
1152 f8a36e22 2021-08-26 stsp echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
1153 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1154 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1155 f8a36e22 2021-08-26 stsp ret="$?"
1156 f8a36e22 2021-08-26 stsp if [ "$ret" != "0" ]; then
1157 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1158 f8a36e22 2021-08-26 stsp fi
1159 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1160 6480c871 2021-08-30 stsp }
1161 6480c871 2021-08-30 stsp
1162 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1163 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1164 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1165 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1166 6480c871 2021-08-30 stsp
1167 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1168 6480c871 2021-08-30 stsp ret="$?"
1169 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1170 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1171 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1172 6480c871 2021-08-30 stsp return 1
1173 6480c871 2021-08-30 stsp fi
1174 6480c871 2021-08-30 stsp
1175 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1176 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1177 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1178 6480c871 2021-08-30 stsp
1179 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1180 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1181 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1182 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1183 6480c871 2021-08-30 stsp
1184 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1185 6480c871 2021-08-30 stsp remote "origin" {
1186 6480c871 2021-08-30 stsp protocol ssh
1187 6480c871 2021-08-30 stsp server 127.0.0.1
1188 6480c871 2021-08-30 stsp send {
1189 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1190 6480c871 2021-08-30 stsp }
1191 6480c871 2021-08-30 stsp fetch {
1192 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1193 6480c871 2021-08-30 stsp }
1194 f8a36e22 2021-08-26 stsp }
1195 6480c871 2021-08-30 stsp EOF
1196 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1197 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1198 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1199 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1200 6480c871 2021-08-30 stsp return 1
1201 6480c871 2021-08-30 stsp fi
1202 f8a36e22 2021-08-26 stsp
1203 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1204 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1205 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1206 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1207 6480c871 2021-08-30 stsp ret="$?"
1208 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1209 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1210 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1211 6480c871 2021-08-30 stsp return 1
1212 6480c871 2021-08-30 stsp fi
1213 f8a36e22 2021-08-26 stsp
1214 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1215 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1216 6480c871 2021-08-30 stsp ret="$?"
1217 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1218 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1219 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1220 6480c871 2021-08-30 stsp return 1
1221 6480c871 2021-08-30 stsp fi
1222 6480c871 2021-08-30 stsp
1223 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1224 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1225 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1226 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1227 6480c871 2021-08-30 stsp return 1
1228 6480c871 2021-08-30 stsp fi
1229 6480c871 2021-08-30 stsp
1230 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1231 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1232 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1233 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1234 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1235 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1236 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1237 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1238 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1239 6480c871 2021-08-30 stsp ret="$?"
1240 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1241 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1242 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1243 6480c871 2021-08-30 stsp return 1
1244 6480c871 2021-08-30 stsp fi
1245 6480c871 2021-08-30 stsp
1246 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1247 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1248 6480c871 2021-08-30 stsp ret="$?"
1249 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1250 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1251 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1252 6480c871 2021-08-30 stsp return 1
1253 6480c871 2021-08-30 stsp fi
1254 6480c871 2021-08-30 stsp
1255 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1256 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1257 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1258 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1259 6480c871 2021-08-30 stsp return 1
1260 6480c871 2021-08-30 stsp fi
1261 6480c871 2021-08-30 stsp
1262 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1263 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1264 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1265 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1266 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1267 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1268 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1269 6480c871 2021-08-30 stsp
1270 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1271 6480c871 2021-08-30 stsp ret="$?"
1272 6480c871 2021-08-30 stsp if [ "$ret" != "0" ]; then
1273 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 6480c871 2021-08-30 stsp fi
1275 6480c871 2021-08-30 stsp
1276 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1277 eac1df47 2021-09-01 stsp }
1278 eac1df47 2021-09-01 stsp
1279 eac1df47 2021-09-01 stsp test_send_config() {
1280 eac1df47 2021-09-01 stsp local testroot=`test_init send_fetch_conf`
1281 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1282 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1283 eac1df47 2021-09-01 stsp
1284 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1285 eac1df47 2021-09-01 stsp ret="$?"
1286 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1287 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1288 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1289 eac1df47 2021-09-01 stsp return 1
1290 eac1df47 2021-09-01 stsp fi
1291 eac1df47 2021-09-01 stsp
1292 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1293 eac1df47 2021-09-01 stsp remote "origin" {
1294 eac1df47 2021-09-01 stsp protocol ssh
1295 eac1df47 2021-09-01 stsp server 127.0.0.1
1296 eac1df47 2021-09-01 stsp branch foo
1297 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1298 6480c871 2021-08-30 stsp }
1299 eac1df47 2021-09-01 stsp EOF
1300 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1301 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1302 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1303 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1304 eac1df47 2021-09-01 stsp return 1
1305 eac1df47 2021-09-01 stsp fi
1306 6480c871 2021-08-30 stsp
1307 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1308 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1309 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1310 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1311 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1312 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1313 eac1df47 2021-09-01 stsp
1314 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1315 eac1df47 2021-09-01 stsp ret="$?"
1316 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1317 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1318 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1319 eac1df47 2021-09-01 stsp return 1
1320 eac1df47 2021-09-01 stsp fi
1321 eac1df47 2021-09-01 stsp
1322 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1323 eac1df47 2021-09-01 stsp
1324 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1325 eac1df47 2021-09-01 stsp ret="$?"
1326 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1327 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1328 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1329 eac1df47 2021-09-01 stsp return 1
1330 eac1df47 2021-09-01 stsp fi
1331 eac1df47 2021-09-01 stsp
1332 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1333 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1334 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1335 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1336 eac1df47 2021-09-01 stsp return 1
1337 eac1df47 2021-09-01 stsp fi
1338 eac1df47 2021-09-01 stsp
1339 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1340 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1341 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1342 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1343 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1344 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1345 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1346 eac1df47 2021-09-01 stsp
1347 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1348 eac1df47 2021-09-01 stsp ret="$?"
1349 eac1df47 2021-09-01 stsp if [ "$ret" != "0" ]; then
1350 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1351 eac1df47 2021-09-01 stsp fi
1352 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1353 eac1df47 2021-09-01 stsp }
1354 eac1df47 2021-09-01 stsp
1355 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1356 f8a36e22 2021-08-26 stsp run_test test_send_basic
1357 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1358 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1359 f8a36e22 2021-08-26 stsp run_test test_send_delete
1360 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1361 f8a36e22 2021-08-26 stsp run_test test_send_tags
1362 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1363 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1364 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1365 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1366 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1367 eac1df47 2021-09-01 stsp run_test test_send_config