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