Blame


1 f8a36e22 2021-08-26 stsp #!/bin/sh
2 f8a36e22 2021-08-26 stsp #
3 f8a36e22 2021-08-26 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 f8a36e22 2021-08-26 stsp #
5 f8a36e22 2021-08-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp # copyright notice and this permission notice appear in all copies.
8 f8a36e22 2021-08-26 stsp #
9 f8a36e22 2021-08-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f8a36e22 2021-08-26 stsp
17 f8a36e22 2021-08-26 stsp . ./common.sh
18 f8a36e22 2021-08-26 stsp
19 f8a36e22 2021-08-26 stsp test_send_basic() {
20 f8a36e22 2021-08-26 stsp local testroot=`test_init send_basic`
21 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
22 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
23 f8a36e22 2021-08-26 stsp
24 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
25 49c543a6 2022-03-31 naddy ret=$?
26 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
27 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
28 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
29 f8a36e22 2021-08-26 stsp return 1
30 f8a36e22 2021-08-26 stsp fi
31 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
32 f8a36e22 2021-08-26 stsp remote "origin" {
33 f8a36e22 2021-08-26 stsp protocol ssh
34 f8a36e22 2021-08-26 stsp server 127.0.0.1
35 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
36 f8a36e22 2021-08-26 stsp }
37 f8a36e22 2021-08-26 stsp EOF
38 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
39 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
40 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
41 f8a36e22 2021-08-26 stsp
42 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
43 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
44 f73bf5bd 2023-10-01 naddy (cd $testroot/repo && ln -s epsilon/zeta symlink)
45 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add symlink
46 3af9de88 2021-09-22 stsp echo "new file alpha" > $testroot/repo/new
47 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add new
48 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
49 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
50 f8a36e22 2021-08-26 stsp
51 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
52 49c543a6 2022-03-31 naddy ret=$?
53 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
54 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
55 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
56 f8a36e22 2021-08-26 stsp return 1
57 f8a36e22 2021-08-26 stsp fi
58 5e91dae4 2022-08-30 stsp
59 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
60 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
61 49c543a6 2022-03-31 naddy ret=$?
62 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
63 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
64 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
65 f8a36e22 2021-08-26 stsp return 1
66 f8a36e22 2021-08-26 stsp fi
67 f8a36e22 2021-08-26 stsp
68 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
69 84246752 2022-06-03 op ret=$?
70 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
71 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
72 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
73 f8a36e22 2021-08-26 stsp return 1
74 f8a36e22 2021-08-26 stsp fi
75 f8a36e22 2021-08-26 stsp
76 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
77 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
78 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
79 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
80 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
81 f8a36e22 2021-08-26 stsp
82 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
83 49c543a6 2022-03-31 naddy ret=$?
84 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
85 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
86 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
87 f8a36e22 2021-08-26 stsp return 1
88 f8a36e22 2021-08-26 stsp fi
89 f8a36e22 2021-08-26 stsp
90 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
91 84246752 2022-06-03 op ret=$?
92 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
93 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
94 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
95 f8a36e22 2021-08-26 stsp return 1
96 f8a36e22 2021-08-26 stsp fi
97 f8a36e22 2021-08-26 stsp
98 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
99 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
100 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
101 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
102 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
103 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
104 3af9de88 2021-09-22 stsp
105 3af9de88 2021-09-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
106 49c543a6 2022-03-31 naddy ret=$?
107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
108 3af9de88 2021-09-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
109 3af9de88 2021-09-22 stsp test_done "$testroot" "$ret"
110 3af9de88 2021-09-22 stsp return 1
111 3af9de88 2021-09-22 stsp fi
112 f8a36e22 2021-08-26 stsp
113 3af9de88 2021-09-22 stsp got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
114 3af9de88 2021-09-22 stsp > $testroot/stdout
115 3af9de88 2021-09-22 stsp got tree -r $testroot/repo -c $commit_id2 -i -R \
116 3af9de88 2021-09-22 stsp > $testroot/stdout.expected
117 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
118 49c543a6 2022-03-31 naddy ret=$?
119 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
120 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
121 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
122 f8a36e22 2021-08-26 stsp return 1
123 f8a36e22 2021-08-26 stsp fi
124 f8a36e22 2021-08-26 stsp
125 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
126 49c543a6 2022-03-31 naddy ret=$?
127 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
128 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
129 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
130 f8a36e22 2021-08-26 stsp return 1
131 f8a36e22 2021-08-26 stsp fi
132 5e91dae4 2022-08-30 stsp
133 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
134 0deb9607 2022-11-18 op > $testroot/stdout.expected
135 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
136 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
137 49c543a6 2022-03-31 naddy ret=$?
138 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
139 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
140 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
141 f0fd0aaf 2021-09-14 stsp return 1
142 f8a36e22 2021-08-26 stsp fi
143 f0fd0aaf 2021-09-14 stsp
144 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
145 49c543a6 2022-03-31 naddy ret=$?
146 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
147 f8a36e22 2021-08-26 stsp }
148 f8a36e22 2021-08-26 stsp
149 f8a36e22 2021-08-26 stsp test_send_rebase_required() {
150 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required`
151 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
152 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
153 f8a36e22 2021-08-26 stsp
154 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
155 49c543a6 2022-03-31 naddy ret=$?
156 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
157 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
158 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
159 f8a36e22 2021-08-26 stsp return 1
160 f8a36e22 2021-08-26 stsp fi
161 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
162 f8a36e22 2021-08-26 stsp remote "origin" {
163 f8a36e22 2021-08-26 stsp protocol ssh
164 f8a36e22 2021-08-26 stsp server 127.0.0.1
165 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
166 f8a36e22 2021-08-26 stsp }
167 f8a36e22 2021-08-26 stsp EOF
168 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
169 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
170 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
171 f8a36e22 2021-08-26 stsp
172 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
173 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
174 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
175 f8a36e22 2021-08-26 stsp
176 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
177 49c543a6 2022-03-31 naddy ret=$?
178 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
179 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
180 a19f439c 2022-06-03 op test_done "$testroot" 1
181 f8a36e22 2021-08-26 stsp return 1
182 f8a36e22 2021-08-26 stsp fi
183 5e91dae4 2022-08-30 stsp
184 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
185 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
186 49c543a6 2022-03-31 naddy ret=$?
187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
188 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
190 f8a36e22 2021-08-26 stsp return 1
191 f8a36e22 2021-08-26 stsp fi
192 f8a36e22 2021-08-26 stsp
193 f8a36e22 2021-08-26 stsp echo "got: refs/heads/master: fetch and rebase required" \
194 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
195 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
196 49c543a6 2022-03-31 naddy ret=$?
197 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
198 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
199 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
200 f0fd0aaf 2021-09-14 stsp return 1
201 f8a36e22 2021-08-26 stsp fi
202 f0fd0aaf 2021-09-14 stsp
203 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
204 49c543a6 2022-03-31 naddy ret=$?
205 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
206 f8a36e22 2021-08-26 stsp }
207 f8a36e22 2021-08-26 stsp
208 f8a36e22 2021-08-26 stsp test_send_rebase_required_overwrite() {
209 f8a36e22 2021-08-26 stsp local testroot=`test_init send_rebase_required_overwrite`
210 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
211 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
212 f8a36e22 2021-08-26 stsp
213 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
214 49c543a6 2022-03-31 naddy ret=$?
215 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
216 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
217 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
218 f8a36e22 2021-08-26 stsp return 1
219 f8a36e22 2021-08-26 stsp fi
220 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
221 f8a36e22 2021-08-26 stsp remote "foobar" {
222 f8a36e22 2021-08-26 stsp protocol ssh
223 f8a36e22 2021-08-26 stsp server 127.0.0.1
224 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
225 f8a36e22 2021-08-26 stsp }
226 f8a36e22 2021-08-26 stsp EOF
227 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
228 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
229 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
230 f8a36e22 2021-08-26 stsp
231 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt-clone >/dev/null
232 f8a36e22 2021-08-26 stsp echo "modified alpha, too" > $testroot/wt-clone/alpha
233 f8a36e22 2021-08-26 stsp (cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
234 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_head $testroot/repo-clone`
235 f8a36e22 2021-08-26 stsp
236 f8a36e22 2021-08-26 stsp # non-default remote requires an explicit argument
237 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f > $testroot/stdout \
238 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
239 49c543a6 2022-03-31 naddy ret=$?
240 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
241 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
242 a19f439c 2022-06-03 op test_done "$testroot" 1
243 f8a36e22 2021-08-26 stsp return 1
244 f8a36e22 2021-08-26 stsp fi
245 f8a36e22 2021-08-26 stsp echo "got: origin: remote repository not found" \
246 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
247 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
248 49c543a6 2022-03-31 naddy ret=$?
249 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
250 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
251 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
252 f8a36e22 2021-08-26 stsp return 1
253 f8a36e22 2021-08-26 stsp fi
254 f8a36e22 2021-08-26 stsp
255 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -f foobar > $testroot/stdout \
256 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
257 49c543a6 2022-03-31 naddy ret=$?
258 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
259 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
260 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
261 f8a36e22 2021-08-26 stsp return 1
262 f8a36e22 2021-08-26 stsp fi
263 5e91dae4 2022-08-30 stsp
264 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
265 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
266 49c543a6 2022-03-31 naddy ret=$?
267 49c543a6 2022-03-31 naddy if [ $ret -ne 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 > $testroot/stdout
274 84246752 2022-06-03 op ret=$?
275 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
276 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
277 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
278 f8a36e22 2021-08-26 stsp return 1
279 f8a36e22 2021-08-26 stsp fi
280 f8a36e22 2021-08-26 stsp
281 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
282 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
283 f8a36e22 2021-08-26 stsp echo "refs/remotes/foobar/master: $commit_id2" \
284 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
285 f8a36e22 2021-08-26 stsp
286 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
287 49c543a6 2022-03-31 naddy ret=$?
288 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
289 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
290 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
291 f8a36e22 2021-08-26 stsp return 1
292 f8a36e22 2021-08-26 stsp fi
293 f8a36e22 2021-08-26 stsp
294 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
295 84246752 2022-06-03 op ret=$?
296 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
297 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
298 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
299 f8a36e22 2021-08-26 stsp return 1
300 f8a36e22 2021-08-26 stsp fi
301 f8a36e22 2021-08-26 stsp
302 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt-clone && got info | grep 'UUID:' | \
303 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
304 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
305 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id3" \
306 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
307 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
308 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
309 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
310 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
311 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
312 f8a36e22 2021-08-26 stsp
313 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
314 49c543a6 2022-03-31 naddy ret=$?
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
318 f0fd0aaf 2021-09-14 stsp return 1
319 f8a36e22 2021-08-26 stsp fi
320 f0fd0aaf 2021-09-14 stsp
321 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
322 49c543a6 2022-03-31 naddy ret=$?
323 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
324 e166551f 2023-04-17 stsp }
325 e166551f 2023-04-17 stsp
326 e166551f 2023-04-17 stsp test_send_merge_commit() {
327 e166551f 2023-04-17 stsp local testroot=`test_init send_merge_commit`
328 e166551f 2023-04-17 stsp local testurl=ssh://127.0.0.1/$testroot
329 e166551f 2023-04-17 stsp
330 e166551f 2023-04-17 stsp if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
331 e166551f 2023-04-17 stsp echo "got clone command failed unexpectedly" >&2
332 e166551f 2023-04-17 stsp test_done "$testroot" 1
333 e166551f 2023-04-17 stsp return 1
334 e166551f 2023-04-17 stsp fi
335 e166551f 2023-04-17 stsp
336 e166551f 2023-04-17 stsp echo 'upstream change' > $testroot/repo/alpha
337 e166551f 2023-04-17 stsp git_commit $testroot/repo -m 'upstream change'
338 e166551f 2023-04-17 stsp
339 e166551f 2023-04-17 stsp got checkout $testroot/repo-clone $testroot/wt-clone > /dev/null
340 e166551f 2023-04-17 stsp echo 'downstream change' > $testroot/wt-clone/beta
341 e166551f 2023-04-17 stsp (cd $testroot/wt-clone && got commit -m 'downstream change' > /dev/null)
342 e166551f 2023-04-17 stsp
343 e166551f 2023-04-17 stsp got fetch -q -r $testroot/repo-clone
344 e166551f 2023-04-17 stsp (cd $testroot/wt-clone && got update > /dev/null)
345 e166551f 2023-04-17 stsp (cd $testroot/wt-clone && got merge origin/master > /dev/null)
346 e166551f 2023-04-17 stsp ret=$?
347 e166551f 2023-04-17 stsp if [ $ret -ne 0 ]; then
348 e166551f 2023-04-17 stsp echo "got merge command failed unexpectedly" >&2
349 e166551f 2023-04-17 stsp test_done "$testroot" "$ret"
350 e166551f 2023-04-17 stsp return 1
351 e166551f 2023-04-17 stsp fi
352 e166551f 2023-04-17 stsp
353 f73bf5bd 2023-10-01 naddy git -C $testroot/repo config receive.denyCurrentBranch ignore
354 e166551f 2023-04-17 stsp
355 e166551f 2023-04-17 stsp got send -q -r $testroot/repo-clone
356 e166551f 2023-04-17 stsp ret=$?
357 e166551f 2023-04-17 stsp if [ $ret -ne 0 ]; then
358 e166551f 2023-04-17 stsp test_done "$testroot" "$ret"
359 e166551f 2023-04-17 stsp return 1
360 e166551f 2023-04-17 stsp fi
361 e166551f 2023-04-17 stsp
362 e166551f 2023-04-17 stsp test_done "$testroot" 0
363 f8a36e22 2021-08-26 stsp }
364 f8a36e22 2021-08-26 stsp
365 f8a36e22 2021-08-26 stsp test_send_delete() {
366 f8a36e22 2021-08-26 stsp local testroot=`test_init send_delete`
367 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
368 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
369 f8a36e22 2021-08-26 stsp
370 f8a36e22 2021-08-26 stsp # branch1 exists in both repositories
371 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo branch1
372 f8a36e22 2021-08-26 stsp
373 f8a36e22 2021-08-26 stsp got clone -a -q $testurl/repo $testroot/repo-clone
374 49c543a6 2022-03-31 naddy ret=$?
375 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
376 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
377 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
378 f8a36e22 2021-08-26 stsp return 1
379 f8a36e22 2021-08-26 stsp fi
380 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
381 f8a36e22 2021-08-26 stsp remote "origin" {
382 f8a36e22 2021-08-26 stsp protocol ssh
383 f8a36e22 2021-08-26 stsp server 127.0.0.1
384 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
385 f8a36e22 2021-08-26 stsp }
386 f8a36e22 2021-08-26 stsp EOF
387 f8a36e22 2021-08-26 stsp # branch2 exists only in the remote repository
388 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone branch2
389 f8a36e22 2021-08-26 stsp
390 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
391 84246752 2022-06-03 op ret=$?
392 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
393 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
399 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
400 f8a36e22 2021-08-26 stsp echo "refs/heads/branch2: $commit_id" >> $testroot/stdout.expected
401 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
402 f8a36e22 2021-08-26 stsp
403 f8a36e22 2021-08-26 stsp # Sending changes for a branch and deleting it at the same
404 f8a36e22 2021-08-26 stsp # time is not allowed.
405 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d branch1 -b branch1 \
406 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
407 49c543a6 2022-03-31 naddy ret=$?
408 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
409 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
410 a19f439c 2022-06-03 op test_done "$testroot" 1
411 f8a36e22 2021-08-26 stsp return 1
412 f8a36e22 2021-08-26 stsp fi
413 f8a36e22 2021-08-26 stsp echo -n "got: changes on refs/heads/branch1 will be sent to server" \
414 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
415 f8a36e22 2021-08-26 stsp echo ": reference cannot be deleted" >> $testroot/stderr.expected
416 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
417 49c543a6 2022-03-31 naddy ret=$?
418 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
419 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
421 f8a36e22 2021-08-26 stsp return 1
422 f8a36e22 2021-08-26 stsp fi
423 f8a36e22 2021-08-26 stsp
424 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branch1 origin \
425 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
426 49c543a6 2022-03-31 naddy ret=$?
427 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
428 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
429 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
430 f8a36e22 2021-08-26 stsp return 1
431 f8a36e22 2021-08-26 stsp fi
432 f8a36e22 2021-08-26 stsp
433 1bd76734 2021-08-26 stsp got send -r $testroot/repo -d refs/heads/branch2 origin \
434 27b75514 2021-08-28 stsp > $testroot/stdout 2>$testroot/stderr
435 49c543a6 2022-03-31 naddy ret=$?
436 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
437 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
438 1bd76734 2021-08-26 stsp test_done "$testroot" "$ret"
439 1bd76734 2021-08-26 stsp return 1
440 1bd76734 2021-08-26 stsp fi
441 1bd76734 2021-08-26 stsp
442 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo-clone" \
443 0deb9607 2022-11-18 op > $testroot/stdout.expected
444 1bd76734 2021-08-26 stsp echo "Server has deleted refs/heads/branch2" \
445 1bd76734 2021-08-26 stsp >> $testroot/stdout.expected
446 1bd76734 2021-08-26 stsp
447 1bd76734 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
448 49c543a6 2022-03-31 naddy ret=$?
449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
450 1bd76734 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
451 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
452 f8a36e22 2021-08-26 stsp return 1
453 f8a36e22 2021-08-26 stsp fi
454 f8a36e22 2021-08-26 stsp
455 f8a36e22 2021-08-26 stsp # branchX exists in neither repository
456 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/heads/branchX origin \
457 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
458 49c543a6 2022-03-31 naddy ret=$?
459 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
460 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
461 a19f439c 2022-06-03 op test_done "$testroot" 1
462 f8a36e22 2021-08-26 stsp return 1
463 f8a36e22 2021-08-26 stsp fi
464 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/branchX does not exist in remote " \
465 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
466 f8a36e22 2021-08-26 stsp echo "repository: no such reference found" >> $testroot/stderr.expected
467 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
468 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
469 49c543a6 2022-03-31 naddy ret=$?
470 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
471 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
472 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
473 f8a36e22 2021-08-26 stsp return 1
474 f8a36e22 2021-08-26 stsp fi
475 f8a36e22 2021-08-26 stsp
476 f8a36e22 2021-08-26 stsp # References outside of refs/heads/ cannot be deleted with 'got send'.
477 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -d refs/tags/1.0 origin \
478 f8a36e22 2021-08-26 stsp > $testroot/stdout 2> $testroot/stderr
479 49c543a6 2022-03-31 naddy ret=$?
480 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
481 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
482 a19f439c 2022-06-03 op test_done "$testroot" 1
483 f8a36e22 2021-08-26 stsp return 1
484 f8a36e22 2021-08-26 stsp fi
485 f8a36e22 2021-08-26 stsp echo -n "got-send-pack: refs/heads/refs/tags/1.0 does not exist " \
486 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
487 f8a36e22 2021-08-26 stsp echo "in remote repository: no such reference found" \
488 f8a36e22 2021-08-26 stsp >> $testroot/stderr.expected
489 f8a36e22 2021-08-26 stsp echo "got: no such reference found" >> $testroot/stderr.expected
490 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
491 49c543a6 2022-03-31 naddy ret=$?
492 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
493 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
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 84246752 2022-06-03 op
498 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
499 84246752 2022-06-03 op ret=$?
500 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
501 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
502 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
503 f8a36e22 2021-08-26 stsp return 1
504 f8a36e22 2021-08-26 stsp fi
505 f8a36e22 2021-08-26 stsp
506 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
507 f8a36e22 2021-08-26 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
508 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
509 f8a36e22 2021-08-26 stsp
510 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
511 49c543a6 2022-03-31 naddy ret=$?
512 49c543a6 2022-03-31 naddy if [ $ret -ne 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 84246752 2022-06-03 op ret=$?
520 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
521 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
522 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
523 f8a36e22 2021-08-26 stsp return 1
524 f8a36e22 2021-08-26 stsp fi
525 f8a36e22 2021-08-26 stsp
526 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
527 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
528 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
529 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
530 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/branch1: $commit_id" \
531 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
532 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
533 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
534 f8a36e22 2021-08-26 stsp
535 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
536 49c543a6 2022-03-31 naddy ret=$?
537 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
538 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
540 f0fd0aaf 2021-09-14 stsp return 1
541 f8a36e22 2021-08-26 stsp fi
542 f0fd0aaf 2021-09-14 stsp
543 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
544 49c543a6 2022-03-31 naddy ret=$?
545 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
546 f8a36e22 2021-08-26 stsp }
547 f8a36e22 2021-08-26 stsp
548 f8a36e22 2021-08-26 stsp test_send_clone_and_send() {
549 f8a36e22 2021-08-26 stsp local testroot=`test_init send_clone_and_send`
550 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
551 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
552 f8a36e22 2021-08-26 stsp
553 f73bf5bd 2023-10-01 naddy git -C $testroot/repo config receive.denyCurrentBranch ignore
554 f8a36e22 2021-08-26 stsp
555 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
556 49c543a6 2022-03-31 naddy ret=$?
557 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
558 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
559 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
560 f8a36e22 2021-08-26 stsp return 1
561 f8a36e22 2021-08-26 stsp fi
562 f8a36e22 2021-08-26 stsp
563 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
564 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
565 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
566 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
567 f8a36e22 2021-08-26 stsp
568 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
569 49c543a6 2022-03-31 naddy ret=$?
570 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
571 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
572 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
573 f8a36e22 2021-08-26 stsp return 1
574 f8a36e22 2021-08-26 stsp fi
575 5e91dae4 2022-08-30 stsp
576 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
577 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
578 49c543a6 2022-03-31 naddy ret=$?
579 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
580 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
581 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
582 f8a36e22 2021-08-26 stsp return 1
583 f8a36e22 2021-08-26 stsp fi
584 f8a36e22 2021-08-26 stsp
585 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
586 84246752 2022-06-03 op ret=$?
587 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
588 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
589 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
590 f8a36e22 2021-08-26 stsp return 1
591 f8a36e22 2021-08-26 stsp fi
592 f8a36e22 2021-08-26 stsp
593 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
594 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
595 f8a36e22 2021-08-26 stsp
596 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
597 49c543a6 2022-03-31 naddy ret=$?
598 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
599 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
600 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
601 f8a36e22 2021-08-26 stsp return 1
602 f8a36e22 2021-08-26 stsp fi
603 f8a36e22 2021-08-26 stsp
604 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
605 84246752 2022-06-03 op ret=$?
606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
607 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
608 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
609 f8a36e22 2021-08-26 stsp return 1
610 f8a36e22 2021-08-26 stsp fi
611 f8a36e22 2021-08-26 stsp
612 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
613 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
614 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
615 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
616 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
617 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
618 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
619 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
620 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
621 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
622 f8a36e22 2021-08-26 stsp
623 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
624 49c543a6 2022-03-31 naddy ret=$?
625 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
626 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
627 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
628 f0fd0aaf 2021-09-14 stsp return 1
629 f8a36e22 2021-08-26 stsp fi
630 f0fd0aaf 2021-09-14 stsp
631 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
632 49c543a6 2022-03-31 naddy ret=$?
633 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
634 f8a36e22 2021-08-26 stsp }
635 f8a36e22 2021-08-26 stsp
636 f8a36e22 2021-08-26 stsp test_send_tags() {
637 f8a36e22 2021-08-26 stsp local testroot=`test_init send_tags`
638 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
639 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
640 f8a36e22 2021-08-26 stsp
641 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
642 49c543a6 2022-03-31 naddy ret=$?
643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
644 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
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 cat > $testroot/repo/.git/got.conf <<EOF
649 f8a36e22 2021-08-26 stsp remote "origin" {
650 f8a36e22 2021-08-26 stsp protocol ssh
651 f8a36e22 2021-08-26 stsp server 127.0.0.1
652 f8a36e22 2021-08-26 stsp repository "$testroot/repo-clone"
653 f8a36e22 2021-08-26 stsp }
654 f8a36e22 2021-08-26 stsp EOF
655 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
656 f8a36e22 2021-08-26 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
657 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
658 f8a36e22 2021-08-26 stsp
659 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
660 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
661 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
662 f8a36e22 2021-08-26 stsp
663 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '2.0' 2.0 >/dev/null
664 f8a36e22 2021-08-26 stsp tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
665 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
666 f8a36e22 2021-08-26 stsp
667 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
668 49c543a6 2022-03-31 naddy ret=$?
669 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
670 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
671 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
672 f8a36e22 2021-08-26 stsp return 1
673 f8a36e22 2021-08-26 stsp fi
674 5e91dae4 2022-08-30 stsp
675 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
676 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
677 49c543a6 2022-03-31 naddy ret=$?
678 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
679 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 got ref -l -r $testroot/repo > $testroot/stdout
685 84246752 2022-06-03 op ret=$?
686 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
687 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
688 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
689 f8a36e22 2021-08-26 stsp return 1
690 f8a36e22 2021-08-26 stsp fi
691 f8a36e22 2021-08-26 stsp
692 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
693 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
694 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
695 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
696 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
697 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
698 f8a36e22 2021-08-26 stsp
699 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
700 49c543a6 2022-03-31 naddy ret=$?
701 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
702 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
703 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
704 f8a36e22 2021-08-26 stsp return 1
705 f8a36e22 2021-08-26 stsp fi
706 f8a36e22 2021-08-26 stsp
707 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
708 84246752 2022-06-03 op ret=$?
709 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
710 f8a36e22 2021-08-26 stsp echo "got ref 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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
716 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
717 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
718 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
719 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
720 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
721 f8a36e22 2021-08-26 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
722 f8a36e22 2021-08-26 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
723 f8a36e22 2021-08-26 stsp
724 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
725 49c543a6 2022-03-31 naddy ret=$?
726 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
727 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
729 f8a36e22 2021-08-26 stsp return 1
730 f8a36e22 2021-08-26 stsp fi
731 f8a36e22 2021-08-26 stsp
732 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
733 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
734 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
735 92410079 2021-10-16 stsp cmp -s $testroot/stdout $testroot/stdout.expected
736 49c543a6 2022-03-31 naddy ret=$?
737 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
738 92410079 2021-10-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
740 92410079 2021-10-16 stsp return 1
741 92410079 2021-10-16 stsp fi
742 92410079 2021-10-16 stsp
743 92410079 2021-10-16 stsp # Send the same tags again. This should be a no-op.
744 92410079 2021-10-16 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
745 49c543a6 2022-03-31 naddy ret=$?
746 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
747 92410079 2021-10-16 stsp echo "got send command failed unexpectedly" >&2
748 92410079 2021-10-16 stsp test_done "$testroot" "$ret"
749 92410079 2021-10-16 stsp return 1
750 92410079 2021-10-16 stsp fi
751 5e91dae4 2022-08-30 stsp
752 92410079 2021-10-16 stsp echo -n > $testroot/stdout.expected
753 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
754 49c543a6 2022-03-31 naddy ret=$?
755 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
756 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
758 f8a36e22 2021-08-26 stsp return 1
759 f8a36e22 2021-08-26 stsp fi
760 f8a36e22 2021-08-26 stsp
761 f8a36e22 2021-08-26 stsp # Overwriting an existing tag 'got send -f'.
762 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null
763 f8a36e22 2021-08-26 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
764 f8a36e22 2021-08-26 stsp tag_id3=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
765 f8a36e22 2021-08-26 stsp | tr -d ' ' | cut -d: -f2`
766 f8a36e22 2021-08-26 stsp
767 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout \
768 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
769 49c543a6 2022-03-31 naddy ret=$?
770 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
771 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
772 a19f439c 2022-06-03 op test_done "$testroot" 1
773 f8a36e22 2021-08-26 stsp return 1
774 f8a36e22 2021-08-26 stsp fi
775 f8a36e22 2021-08-26 stsp
776 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
777 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
778 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
779 49c543a6 2022-03-31 naddy ret=$?
780 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
781 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
782 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
783 f8a36e22 2021-08-26 stsp return 1
784 f8a36e22 2021-08-26 stsp fi
785 f8a36e22 2021-08-26 stsp
786 f8a36e22 2021-08-26 stsp # attempting the same with -T should fail, too
787 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -T > $testroot/stdout \
788 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
789 49c543a6 2022-03-31 naddy ret=$?
790 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
791 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
792 a19f439c 2022-06-03 op test_done "$testroot" 1
793 f8a36e22 2021-08-26 stsp return 1
794 f8a36e22 2021-08-26 stsp fi
795 f8a36e22 2021-08-26 stsp
796 f8a36e22 2021-08-26 stsp echo "got: refs/tags/1.0: tag already exists on server" \
797 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
798 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
799 49c543a6 2022-03-31 naddy ret=$?
800 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
801 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
802 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
803 f8a36e22 2021-08-26 stsp return 1
804 f8a36e22 2021-08-26 stsp fi
805 f8a36e22 2021-08-26 stsp
806 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
807 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
808 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
809 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
810 49c543a6 2022-03-31 naddy ret=$?
811 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
812 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
814 f8a36e22 2021-08-26 stsp return 1
815 f8a36e22 2021-08-26 stsp fi
816 5e91dae4 2022-08-30 stsp
817 f8a36e22 2021-08-26 stsp # overwrite the 1.0 tag only
818 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo -t 1.0 -f > $testroot/stdout \
819 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
820 49c543a6 2022-03-31 naddy ret=$?
821 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
822 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
823 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
824 f8a36e22 2021-08-26 stsp return 1
825 f8a36e22 2021-08-26 stsp fi
826 5e91dae4 2022-08-30 stsp
827 f8a36e22 2021-08-26 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
828 f8a36e22 2021-08-26 stsp echo "tag 1.0 $tag_id3" > $testroot/stdout.expected
829 f8a36e22 2021-08-26 stsp echo "tag 2.0 $tag_id2" >> $testroot/stdout.expected
830 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
831 49c543a6 2022-03-31 naddy ret=$?
832 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
833 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
834 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
835 c2105d00 2021-09-14 stsp return 1
836 f8a36e22 2021-08-26 stsp fi
837 c2105d00 2021-09-14 stsp
838 c2105d00 2021-09-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
839 c2105d00 2021-09-14 stsp echo 'new line in file alpha' >> $testroot/wt/alpha
840 c2105d00 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
841 c2105d00 2021-09-14 stsp
842 c2105d00 2021-09-14 stsp # Send the new commit in isolation.
843 c2105d00 2021-09-14 stsp got send -q -r $testroot/repo > $testroot/stdout \
844 c2105d00 2021-09-14 stsp 2> $testroot/stderr
845 49c543a6 2022-03-31 naddy ret=$?
846 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
847 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
848 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
849 c2105d00 2021-09-14 stsp return 1
850 c2105d00 2021-09-14 stsp fi
851 c2105d00 2021-09-14 stsp
852 c2105d00 2021-09-14 stsp # Now tag it and send the tag.
853 c2105d00 2021-09-14 stsp # Verify that just the new tag object gets sent.
854 c2105d00 2021-09-14 stsp got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null
855 c2105d00 2021-09-14 stsp tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
856 c2105d00 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
857 c2105d00 2021-09-14 stsp
858 c2105d00 2021-09-14 stsp got send -r $testroot/repo -t 3.0 > $testroot/stdout.raw \
859 c2105d00 2021-09-14 stsp 2> $testroot/stderr
860 49c543a6 2022-03-31 naddy ret=$?
861 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
862 c2105d00 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
863 c2105d00 2021-09-14 stsp test_done "$testroot" "$ret"
864 c2105d00 2021-09-14 stsp return 1
865 c2105d00 2021-09-14 stsp fi
866 c2105d00 2021-09-14 stsp tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
867 c2105d00 2021-09-14 stsp if ! grep -q "packing 2 references; 1 object; deltify: 100%" \
868 c2105d00 2021-09-14 stsp $testroot/stdout; then
869 c2105d00 2021-09-14 stsp echo "got send did apparently pack too many objects:" >&2
870 c2105d00 2021-09-14 stsp cat $testroot/stdout.raw >&2
871 c2105d00 2021-09-14 stsp test_done "$testroot" "1"
872 c2105d00 2021-09-14 stsp return 1
873 c2105d00 2021-09-14 stsp fi
874 f0fd0aaf 2021-09-14 stsp
875 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
876 49c543a6 2022-03-31 naddy ret=$?
877 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
878 f8a36e22 2021-08-26 stsp }
879 f8a36e22 2021-08-26 stsp
880 26960ff7 2021-09-14 stsp test_send_tag_of_deleted_branch() {
881 26960ff7 2021-09-14 stsp local testroot=`test_init send_tag_of_deleted_branch`
882 26960ff7 2021-09-14 stsp local testurl=ssh://127.0.0.1/$testroot
883 26960ff7 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
884 26960ff7 2021-09-14 stsp
885 26960ff7 2021-09-14 stsp got clone -q $testurl/repo $testroot/repo-clone
886 49c543a6 2022-03-31 naddy ret=$?
887 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
888 26960ff7 2021-09-14 stsp echo "got clone command failed unexpectedly" >&2
889 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
890 26960ff7 2021-09-14 stsp return 1
891 26960ff7 2021-09-14 stsp fi
892 26960ff7 2021-09-14 stsp cat > $testroot/repo/.git/got.conf <<EOF
893 26960ff7 2021-09-14 stsp remote "origin" {
894 26960ff7 2021-09-14 stsp protocol ssh
895 26960ff7 2021-09-14 stsp server 127.0.0.1
896 26960ff7 2021-09-14 stsp repository "$testroot/repo-clone"
897 26960ff7 2021-09-14 stsp }
898 26960ff7 2021-09-14 stsp EOF
899 26960ff7 2021-09-14 stsp got branch -r $testroot/repo foo
900 26960ff7 2021-09-14 stsp
901 ce2bf7b7 2022-05-29 stsp # modify beta on branch foo
902 26960ff7 2021-09-14 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
903 26960ff7 2021-09-14 stsp echo boo >> $testroot/wt/beta
904 26960ff7 2021-09-14 stsp (cd $testroot/wt && got commit -m 'changed beta on branch foo' \
905 ce2bf7b7 2022-05-29 stsp > /dev/null)
906 ce2bf7b7 2022-05-29 stsp echo buu >> $testroot/wt/beta
907 ce2bf7b7 2022-05-29 stsp (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
908 26960ff7 2021-09-14 stsp > /dev/null)
909 ce2bf7b7 2022-05-29 stsp echo baa >> $testroot/wt/beta
910 ce2bf7b7 2022-05-29 stsp (cd $testroot/wt && got commit -m 'changed beta again on branch foo' \
911 ce2bf7b7 2022-05-29 stsp > /dev/null)
912 26960ff7 2021-09-14 stsp local commit_id2=`git_show_branch_head $testroot/repo foo`
913 26960ff7 2021-09-14 stsp
914 26960ff7 2021-09-14 stsp # tag HEAD commit of branch foo
915 26960ff7 2021-09-14 stsp got tag -r $testroot/repo -c foo -m '1.0' 1.0 > /dev/null
916 26960ff7 2021-09-14 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
917 26960ff7 2021-09-14 stsp | tr -d ' ' | cut -d: -f2`
918 26960ff7 2021-09-14 stsp
919 26960ff7 2021-09-14 stsp # delete the branch; commit is now only reachable via tags/1.0
920 26960ff7 2021-09-14 stsp got branch -r $testroot/repo -d foo > /dev/null
921 26960ff7 2021-09-14 stsp
922 26960ff7 2021-09-14 stsp # unrelated change on master branch, then try sending this branch
923 26960ff7 2021-09-14 stsp # and the tag
924 26960ff7 2021-09-14 stsp echo "modified alpha" > $testroot/repo/alpha
925 26960ff7 2021-09-14 stsp git_commit $testroot/repo -m "modified alpha"
926 26960ff7 2021-09-14 stsp local commit_id3=`git_show_head $testroot/repo`
927 26960ff7 2021-09-14 stsp
928 26960ff7 2021-09-14 stsp got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
929 49c543a6 2022-03-31 naddy ret=$?
930 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
931 26960ff7 2021-09-14 stsp echo "got send command failed unexpectedly" >&2
932 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
933 26960ff7 2021-09-14 stsp return 1
934 26960ff7 2021-09-14 stsp fi
935 5e91dae4 2022-08-30 stsp
936 26960ff7 2021-09-14 stsp echo -n > $testroot/stdout.expected
937 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
938 49c543a6 2022-03-31 naddy ret=$?
939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
940 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
942 26960ff7 2021-09-14 stsp return 1
943 26960ff7 2021-09-14 stsp fi
944 26960ff7 2021-09-14 stsp
945 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo > $testroot/stdout
946 84246752 2022-06-03 op ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
949 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
950 26960ff7 2021-09-14 stsp return 1
951 26960ff7 2021-09-14 stsp fi
952 26960ff7 2021-09-14 stsp
953 26960ff7 2021-09-14 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
954 26960ff7 2021-09-14 stsp cut -d ':' -f 2 | tr -d ' ')`
955 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
956 26960ff7 2021-09-14 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
957 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
958 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
959 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id3" \
960 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
961 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
962 26960ff7 2021-09-14 stsp
963 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
964 49c543a6 2022-03-31 naddy ret=$?
965 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
966 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
967 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
968 26960ff7 2021-09-14 stsp return 1
969 26960ff7 2021-09-14 stsp fi
970 26960ff7 2021-09-14 stsp
971 26960ff7 2021-09-14 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
972 84246752 2022-06-03 op ret=$?
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 26960ff7 2021-09-14 stsp echo "got ref command failed unexpectedly" >&2
975 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
976 26960ff7 2021-09-14 stsp return 1
977 26960ff7 2021-09-14 stsp fi
978 26960ff7 2021-09-14 stsp
979 26960ff7 2021-09-14 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
980 26960ff7 2021-09-14 stsp echo "refs/heads/master: $commit_id3" >> $testroot/stdout.expected
981 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
982 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
983 26960ff7 2021-09-14 stsp echo "refs/remotes/origin/master: $commit_id" \
984 26960ff7 2021-09-14 stsp >> $testroot/stdout.expected
985 26960ff7 2021-09-14 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
986 26960ff7 2021-09-14 stsp
987 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
988 49c543a6 2022-03-31 naddy ret=$?
989 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
990 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
991 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
992 26960ff7 2021-09-14 stsp return 1
993 26960ff7 2021-09-14 stsp fi
994 26960ff7 2021-09-14 stsp
995 26960ff7 2021-09-14 stsp got tag -l -r $testroot/repo-clone | grep ^tag | sort > $testroot/stdout
996 26960ff7 2021-09-14 stsp echo "tag 1.0 $tag_id" > $testroot/stdout.expected
997 26960ff7 2021-09-14 stsp
998 26960ff7 2021-09-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
999 49c543a6 2022-03-31 naddy ret=$?
1000 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1001 26960ff7 2021-09-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1003 f0fd0aaf 2021-09-14 stsp return 1
1004 26960ff7 2021-09-14 stsp fi
1005 f0fd0aaf 2021-09-14 stsp
1006 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1007 49c543a6 2022-03-31 naddy ret=$?
1008 26960ff7 2021-09-14 stsp test_done "$testroot" "$ret"
1009 26960ff7 2021-09-14 stsp }
1010 26960ff7 2021-09-14 stsp
1011 f8a36e22 2021-08-26 stsp test_send_new_branch() {
1012 f8a36e22 2021-08-26 stsp local testroot=`test_init send_new_branch`
1013 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1014 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1015 f8a36e22 2021-08-26 stsp
1016 f73bf5bd 2023-10-01 naddy git -C $testroot/repo config receive.denyCurrentBranch ignore
1017 f8a36e22 2021-08-26 stsp
1018 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1019 49c543a6 2022-03-31 naddy ret=$?
1020 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1021 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1022 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1023 f8a36e22 2021-08-26 stsp return 1
1024 f8a36e22 2021-08-26 stsp fi
1025 f8a36e22 2021-08-26 stsp
1026 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1027 f8a36e22 2021-08-26 stsp got checkout -b foo $testroot/repo-clone $testroot/wt >/dev/null
1028 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1029 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1030 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
1031 f8a36e22 2021-08-26 stsp
1032 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
1033 49c543a6 2022-03-31 naddy ret=$?
1034 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1035 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1036 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1037 f8a36e22 2021-08-26 stsp return 1
1038 f8a36e22 2021-08-26 stsp fi
1039 5e91dae4 2022-08-30 stsp
1040 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1041 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1042 49c543a6 2022-03-31 naddy ret=$?
1043 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1044 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1045 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1046 f8a36e22 2021-08-26 stsp return 1
1047 f8a36e22 2021-08-26 stsp fi
1048 f8a36e22 2021-08-26 stsp
1049 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1050 84246752 2022-06-03 op ret=$?
1051 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1052 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1053 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1054 f8a36e22 2021-08-26 stsp return 1
1055 f8a36e22 2021-08-26 stsp fi
1056 f8a36e22 2021-08-26 stsp
1057 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1058 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1059 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1060 f8a36e22 2021-08-26 stsp
1061 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1062 49c543a6 2022-03-31 naddy ret=$?
1063 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1064 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 ref -l -r $testroot/repo-clone > $testroot/stdout
1070 84246752 2022-06-03 op ret=$?
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1073 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1074 f8a36e22 2021-08-26 stsp return 1
1075 f8a36e22 2021-08-26 stsp fi
1076 f8a36e22 2021-08-26 stsp
1077 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1078 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1079 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1080 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id2" \
1081 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1082 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
1083 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1084 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1085 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1086 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id2" \
1087 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1088 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id" \
1089 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1090 f8a36e22 2021-08-26 stsp
1091 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1092 49c543a6 2022-03-31 naddy ret=$?
1093 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1094 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1095 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1096 f0fd0aaf 2021-09-14 stsp return 1
1097 f8a36e22 2021-08-26 stsp fi
1098 f0fd0aaf 2021-09-14 stsp
1099 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1100 49c543a6 2022-03-31 naddy ret=$?
1101 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1102 f8a36e22 2021-08-26 stsp }
1103 f8a36e22 2021-08-26 stsp
1104 f8a36e22 2021-08-26 stsp test_send_all_branches() {
1105 f8a36e22 2021-08-26 stsp local testroot=`test_init send_all_branches`
1106 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1107 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1108 f8a36e22 2021-08-26 stsp
1109 f73bf5bd 2023-10-01 naddy git -C $testroot/repo config receive.denyCurrentBranch ignore
1110 f8a36e22 2021-08-26 stsp
1111 f8a36e22 2021-08-26 stsp got clone -q $testurl/repo $testroot/repo-clone
1112 49c543a6 2022-03-31 naddy ret=$?
1113 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1114 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1115 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1116 f8a36e22 2021-08-26 stsp return 1
1117 f8a36e22 2021-08-26 stsp fi
1118 f8a36e22 2021-08-26 stsp
1119 f8a36e22 2021-08-26 stsp got checkout $testroot/repo-clone $testroot/wt >/dev/null
1120 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/wt/alpha
1121 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
1122 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo-clone`
1123 f8a36e22 2021-08-26 stsp
1124 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone foo >/dev/null
1125 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b foo >/dev/null)
1126 f8a36e22 2021-08-26 stsp echo "modified beta on new branch foo" > $testroot/wt/beta
1127 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1128 f8a36e22 2021-08-26 stsp local commit_id3=`git_show_branch_head $testroot/repo-clone foo`
1129 f8a36e22 2021-08-26 stsp
1130 f8a36e22 2021-08-26 stsp got branch -r $testroot/repo-clone bar >/dev/null
1131 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got update -b bar >/dev/null)
1132 f8a36e22 2021-08-26 stsp echo "modified beta again on new branch bar" > $testroot/wt/beta
1133 f8a36e22 2021-08-26 stsp (cd $testroot/wt && got commit -m "modified beta" >/dev/null)
1134 f8a36e22 2021-08-26 stsp local commit_id4=`git_show_branch_head $testroot/repo-clone bar`
1135 f8a36e22 2021-08-26 stsp
1136 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1137 84246752 2022-06-03 op ret=$?
1138 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1139 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
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 echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1145 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1146 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1147 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1148 f8a36e22 2021-08-26 stsp
1149 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone -b master > $testroot/stdout \
1150 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1151 49c543a6 2022-03-31 naddy ret=$?
1152 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1153 f8a36e22 2021-08-26 stsp echo "got send command succeeded unexpectedly" >&2
1154 a19f439c 2022-06-03 op test_done "$testroot" 1
1155 f8a36e22 2021-08-26 stsp return 1
1156 f8a36e22 2021-08-26 stsp fi
1157 f8a36e22 2021-08-26 stsp echo "got: -a and -b options are mutually exclusive" \
1158 f8a36e22 2021-08-26 stsp > $testroot/stderr.expected
1159 f8a36e22 2021-08-26 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1160 49c543a6 2022-03-31 naddy ret=$?
1161 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1162 f8a36e22 2021-08-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
1163 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1164 f8a36e22 2021-08-26 stsp return 1
1165 f8a36e22 2021-08-26 stsp fi
1166 f8a36e22 2021-08-26 stsp
1167 f8a36e22 2021-08-26 stsp got send -a -q -r $testroot/repo-clone > $testroot/stdout \
1168 f8a36e22 2021-08-26 stsp 2> $testroot/stderr
1169 49c543a6 2022-03-31 naddy ret=$?
1170 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 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 got ref -l -r $testroot/repo > $testroot/stdout
1186 84246752 2022-06-03 op ret=$?
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1189 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1190 f8a36e22 2021-08-26 stsp return 1
1191 f8a36e22 2021-08-26 stsp fi
1192 f8a36e22 2021-08-26 stsp
1193 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1194 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1195 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1196 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1197 f8a36e22 2021-08-26 stsp
1198 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1199 49c543a6 2022-03-31 naddy ret=$?
1200 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1201 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1202 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1203 f8a36e22 2021-08-26 stsp return 1
1204 f8a36e22 2021-08-26 stsp fi
1205 f8a36e22 2021-08-26 stsp
1206 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1207 84246752 2022-06-03 op ret=$?
1208 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1209 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1210 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1211 f8a36e22 2021-08-26 stsp return 1
1212 f8a36e22 2021-08-26 stsp fi
1213 f8a36e22 2021-08-26 stsp
1214 f8a36e22 2021-08-26 stsp wt_uuid=`(cd $testroot/wt && got info | grep 'UUID:' | \
1215 f8a36e22 2021-08-26 stsp cut -d ':' -f 2 | tr -d ' ')`
1216 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1217 f8a36e22 2021-08-26 stsp echo "refs/got/worktree/base-$wt_uuid: $commit_id4" \
1218 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1219 f8a36e22 2021-08-26 stsp echo "refs/heads/bar: $commit_id4" >> $testroot/stdout.expected
1220 f8a36e22 2021-08-26 stsp echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
1221 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1222 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1223 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1224 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/bar: $commit_id4" \
1225 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1226 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/foo: $commit_id3" \
1227 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1228 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1229 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1230 f8a36e22 2021-08-26 stsp
1231 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1232 49c543a6 2022-03-31 naddy ret=$?
1233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1234 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1236 f0fd0aaf 2021-09-14 stsp return 1
1237 f8a36e22 2021-08-26 stsp fi
1238 f0fd0aaf 2021-09-14 stsp
1239 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1240 49c543a6 2022-03-31 naddy ret=$?
1241 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1242 f8a36e22 2021-08-26 stsp }
1243 f8a36e22 2021-08-26 stsp
1244 f8a36e22 2021-08-26 stsp test_send_to_empty_repo() {
1245 f8a36e22 2021-08-26 stsp local testroot=`test_init send_to_empty_repo`
1246 f8a36e22 2021-08-26 stsp local testurl=ssh://127.0.0.1/$testroot
1247 f8a36e22 2021-08-26 stsp local commit_id=`git_show_head $testroot/repo`
1248 f8a36e22 2021-08-26 stsp
1249 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo2
1250 f8a36e22 2021-08-26 stsp
1251 49c543a6 2022-03-31 naddy ret=$?
1252 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1253 f8a36e22 2021-08-26 stsp echo "got clone command failed unexpectedly" >&2
1254 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1255 f8a36e22 2021-08-26 stsp return 1
1256 f8a36e22 2021-08-26 stsp fi
1257 f8a36e22 2021-08-26 stsp cat > $testroot/repo/.git/got.conf <<EOF
1258 f8a36e22 2021-08-26 stsp remote "origin" {
1259 f8a36e22 2021-08-26 stsp protocol ssh
1260 f8a36e22 2021-08-26 stsp server 127.0.0.1
1261 f8a36e22 2021-08-26 stsp repository "$testroot/repo2"
1262 f8a36e22 2021-08-26 stsp }
1263 f8a36e22 2021-08-26 stsp EOF
1264 f8a36e22 2021-08-26 stsp echo "modified alpha" > $testroot/repo/alpha
1265 f8a36e22 2021-08-26 stsp git_commit $testroot/repo -m "modified alpha"
1266 f8a36e22 2021-08-26 stsp local commit_id2=`git_show_head $testroot/repo`
1267 f8a36e22 2021-08-26 stsp
1268 f8a36e22 2021-08-26 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1269 49c543a6 2022-03-31 naddy ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1272 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1273 f8a36e22 2021-08-26 stsp return 1
1274 f8a36e22 2021-08-26 stsp fi
1275 5e91dae4 2022-08-30 stsp
1276 f8a36e22 2021-08-26 stsp echo -n > $testroot/stdout.expected
1277 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1278 49c543a6 2022-03-31 naddy ret=$?
1279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1280 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1281 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1282 f8a36e22 2021-08-26 stsp return 1
1283 f8a36e22 2021-08-26 stsp fi
1284 f8a36e22 2021-08-26 stsp
1285 02a5c5d0 2022-07-04 stsp # XXX Workaround: We cannot give the target for HEAD to 'gotadmin init'
1286 f8a36e22 2021-08-26 stsp got ref -r $testroot/repo2 -s refs/heads/master HEAD
1287 f8a36e22 2021-08-26 stsp
1288 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo > $testroot/stdout
1289 84246752 2022-06-03 op ret=$?
1290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1291 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1292 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1293 f8a36e22 2021-08-26 stsp return 1
1294 f8a36e22 2021-08-26 stsp fi
1295 f8a36e22 2021-08-26 stsp
1296 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1297 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1298 f8a36e22 2021-08-26 stsp echo "refs/remotes/origin/master: $commit_id2" \
1299 f8a36e22 2021-08-26 stsp >> $testroot/stdout.expected
1300 f8a36e22 2021-08-26 stsp
1301 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1302 49c543a6 2022-03-31 naddy ret=$?
1303 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1304 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1305 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1306 f8a36e22 2021-08-26 stsp return 1
1307 f8a36e22 2021-08-26 stsp fi
1308 f8a36e22 2021-08-26 stsp
1309 f8a36e22 2021-08-26 stsp got ref -l -r $testroot/repo2 > $testroot/stdout
1310 84246752 2022-06-03 op ret=$?
1311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1312 f8a36e22 2021-08-26 stsp echo "got ref command failed unexpectedly" >&2
1313 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1314 f8a36e22 2021-08-26 stsp return 1
1315 f8a36e22 2021-08-26 stsp fi
1316 f8a36e22 2021-08-26 stsp
1317 f8a36e22 2021-08-26 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1318 f8a36e22 2021-08-26 stsp echo "refs/heads/master: $commit_id2" >> $testroot/stdout.expected
1319 f8a36e22 2021-08-26 stsp
1320 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1321 49c543a6 2022-03-31 naddy ret=$?
1322 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1323 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1324 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1325 f8a36e22 2021-08-26 stsp return 1
1326 f8a36e22 2021-08-26 stsp fi
1327 f8a36e22 2021-08-26 stsp
1328 f8a36e22 2021-08-26 stsp got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1329 49c543a6 2022-03-31 naddy ret=$?
1330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1331 f8a36e22 2021-08-26 stsp echo "got send command failed unexpectedly" >&2
1332 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1333 f8a36e22 2021-08-26 stsp return 1
1334 f8a36e22 2021-08-26 stsp fi
1335 5e91dae4 2022-08-30 stsp
1336 0deb9607 2022-11-18 op echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo2" \
1337 0deb9607 2022-11-18 op > $testroot/stdout.expected
1338 f8a36e22 2021-08-26 stsp echo "Already up-to-date" >> $testroot/stdout.expected
1339 f8a36e22 2021-08-26 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1340 49c543a6 2022-03-31 naddy ret=$?
1341 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1342 f8a36e22 2021-08-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1343 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1344 f0fd0aaf 2021-09-14 stsp return 1
1345 f8a36e22 2021-08-26 stsp fi
1346 f0fd0aaf 2021-09-14 stsp
1347 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo2"
1348 49c543a6 2022-03-31 naddy ret=$?
1349 f8a36e22 2021-08-26 stsp test_done "$testroot" "$ret"
1350 6480c871 2021-08-30 stsp }
1351 6480c871 2021-08-30 stsp
1352 6480c871 2021-08-30 stsp test_send_and_fetch_config() {
1353 6480c871 2021-08-30 stsp local testroot=`test_init send_fetch_conf`
1354 6480c871 2021-08-30 stsp local testurl=ssh://127.0.0.1/$testroot
1355 6480c871 2021-08-30 stsp local commit_id=`git_show_head $testroot/repo`
1356 6480c871 2021-08-30 stsp
1357 6480c871 2021-08-30 stsp got clone -q $testurl/repo $testroot/repo-clone
1358 49c543a6 2022-03-31 naddy ret=$?
1359 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1360 6480c871 2021-08-30 stsp echo "got clone command failed unexpectedly" >&2
1361 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1362 6480c871 2021-08-30 stsp return 1
1363 6480c871 2021-08-30 stsp fi
1364 6480c871 2021-08-30 stsp
1365 6480c871 2021-08-30 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1366 6480c871 2021-08-30 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1367 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1368 6480c871 2021-08-30 stsp
1369 6480c871 2021-08-30 stsp cp -R $testroot/repo-clone $testroot/repo-clone2
1370 6480c871 2021-08-30 stsp got tag -r $testroot/repo-clone2 -m '2.0' 2.0 >/dev/null
1371 6480c871 2021-08-30 stsp tag_id2=`got ref -r $testroot/repo-clone2 -l | grep "^refs/tags/2.0" \
1372 6480c871 2021-08-30 stsp | tr -d ' ' | cut -d: -f2`
1373 6480c871 2021-08-30 stsp
1374 6480c871 2021-08-30 stsp cat > $testroot/repo/.git/got.conf <<EOF
1375 6480c871 2021-08-30 stsp remote "origin" {
1376 6480c871 2021-08-30 stsp protocol ssh
1377 6480c871 2021-08-30 stsp server 127.0.0.1
1378 6480c871 2021-08-30 stsp send {
1379 6480c871 2021-08-30 stsp repository "$testroot/repo-clone"
1380 6480c871 2021-08-30 stsp }
1381 6480c871 2021-08-30 stsp fetch {
1382 6480c871 2021-08-30 stsp repository "$testroot/repo-clone2"
1383 6480c871 2021-08-30 stsp }
1384 f8a36e22 2021-08-26 stsp }
1385 6480c871 2021-08-30 stsp EOF
1386 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1387 84246752 2022-06-03 op ret=$?
1388 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1389 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1390 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1391 6480c871 2021-08-30 stsp return 1
1392 6480c871 2021-08-30 stsp fi
1393 f8a36e22 2021-08-26 stsp
1394 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1395 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1396 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1397 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1398 49c543a6 2022-03-31 naddy ret=$?
1399 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1400 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1401 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1402 6480c871 2021-08-30 stsp return 1
1403 6480c871 2021-08-30 stsp fi
1404 f8a36e22 2021-08-26 stsp
1405 6480c871 2021-08-30 stsp # fetch tag 2.0 from repo-clone2
1406 6480c871 2021-08-30 stsp got fetch -q -r $testroot/repo > $testroot/stdout
1407 49c543a6 2022-03-31 naddy ret=$?
1408 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1409 6480c871 2021-08-30 stsp echo "got fetch command failed unexpectedly" >&2
1410 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1411 6480c871 2021-08-30 stsp return 1
1412 6480c871 2021-08-30 stsp fi
1413 6480c871 2021-08-30 stsp
1414 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo > $testroot/stdout
1415 84246752 2022-06-03 op ret=$?
1416 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1417 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1418 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1419 6480c871 2021-08-30 stsp return 1
1420 6480c871 2021-08-30 stsp fi
1421 6480c871 2021-08-30 stsp
1422 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1423 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1424 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1425 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1426 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1427 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1428 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1429 6480c871 2021-08-30 stsp echo "refs/tags/2.0: $tag_id2" >> $testroot/stdout.expected
1430 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1431 49c543a6 2022-03-31 naddy ret=$?
1432 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1433 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1434 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1435 6480c871 2021-08-30 stsp return 1
1436 6480c871 2021-08-30 stsp fi
1437 6480c871 2021-08-30 stsp
1438 6480c871 2021-08-30 stsp # send tag 1.0 to repo-clone
1439 6480c871 2021-08-30 stsp got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
1440 49c543a6 2022-03-31 naddy ret=$?
1441 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1442 6480c871 2021-08-30 stsp echo "got send command failed unexpectedly" >&2
1443 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1444 6480c871 2021-08-30 stsp return 1
1445 6480c871 2021-08-30 stsp fi
1446 84246752 2022-06-03 op
1447 6480c871 2021-08-30 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1448 84246752 2022-06-03 op ret=$?
1449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1450 6480c871 2021-08-30 stsp echo "got ref command failed unexpectedly" >&2
1451 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1452 6480c871 2021-08-30 stsp return 1
1453 6480c871 2021-08-30 stsp fi
1454 6480c871 2021-08-30 stsp
1455 6480c871 2021-08-30 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1456 6480c871 2021-08-30 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1457 6480c871 2021-08-30 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1458 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1459 6480c871 2021-08-30 stsp echo "refs/remotes/origin/master: $commit_id" \
1460 6480c871 2021-08-30 stsp >> $testroot/stdout.expected
1461 6480c871 2021-08-30 stsp echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
1462 6480c871 2021-08-30 stsp
1463 6480c871 2021-08-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1464 49c543a6 2022-03-31 naddy ret=$?
1465 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1466 6480c871 2021-08-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
1467 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1468 f0fd0aaf 2021-09-14 stsp return 1
1469 6480c871 2021-08-30 stsp fi
1470 6480c871 2021-08-30 stsp
1471 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1472 49c543a6 2022-03-31 naddy ret=$?
1473 6480c871 2021-08-30 stsp test_done "$testroot" "$ret"
1474 eac1df47 2021-09-01 stsp }
1475 eac1df47 2021-09-01 stsp
1476 eac1df47 2021-09-01 stsp test_send_config() {
1477 fa9997e7 2023-09-13 stsp local testroot=`test_init send_config`
1478 eac1df47 2021-09-01 stsp local testurl=ssh://127.0.0.1/$testroot
1479 eac1df47 2021-09-01 stsp local commit_id=`git_show_head $testroot/repo`
1480 eac1df47 2021-09-01 stsp
1481 eac1df47 2021-09-01 stsp got clone -q $testurl/repo $testroot/repo-clone
1482 49c543a6 2022-03-31 naddy ret=$?
1483 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1484 eac1df47 2021-09-01 stsp echo "got clone command failed unexpectedly" >&2
1485 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1486 eac1df47 2021-09-01 stsp return 1
1487 eac1df47 2021-09-01 stsp fi
1488 eac1df47 2021-09-01 stsp
1489 eac1df47 2021-09-01 stsp cat > $testroot/repo/.git/got.conf <<EOF
1490 eac1df47 2021-09-01 stsp remote "origin" {
1491 eac1df47 2021-09-01 stsp protocol ssh
1492 eac1df47 2021-09-01 stsp server 127.0.0.1
1493 eac1df47 2021-09-01 stsp branch foo
1494 eac1df47 2021-09-01 stsp repository "$testroot/repo-clone"
1495 6480c871 2021-08-30 stsp }
1496 eac1df47 2021-09-01 stsp EOF
1497 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1498 84246752 2022-06-03 op ret=$?
1499 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1500 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1501 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1502 eac1df47 2021-09-01 stsp return 1
1503 eac1df47 2021-09-01 stsp fi
1504 6480c871 2021-08-30 stsp
1505 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1506 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1507 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1508 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1509 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1510 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1511 eac1df47 2021-09-01 stsp
1512 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1513 49c543a6 2022-03-31 naddy ret=$?
1514 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1515 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1516 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1517 eac1df47 2021-09-01 stsp return 1
1518 eac1df47 2021-09-01 stsp fi
1519 5e91dae4 2022-08-30 stsp
1520 eac1df47 2021-09-01 stsp got branch -r $testroot/repo foo
1521 eac1df47 2021-09-01 stsp
1522 eac1df47 2021-09-01 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1523 49c543a6 2022-03-31 naddy ret=$?
1524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1525 eac1df47 2021-09-01 stsp echo "got send command failed unexpectedly" >&2
1526 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1527 eac1df47 2021-09-01 stsp return 1
1528 eac1df47 2021-09-01 stsp fi
1529 eac1df47 2021-09-01 stsp
1530 eac1df47 2021-09-01 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1531 84246752 2022-06-03 op ret=$?
1532 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1533 eac1df47 2021-09-01 stsp echo "got ref command failed unexpectedly" >&2
1534 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1535 eac1df47 2021-09-01 stsp return 1
1536 eac1df47 2021-09-01 stsp fi
1537 eac1df47 2021-09-01 stsp
1538 eac1df47 2021-09-01 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1539 eac1df47 2021-09-01 stsp echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
1540 eac1df47 2021-09-01 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1541 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1542 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1543 eac1df47 2021-09-01 stsp echo "refs/remotes/origin/master: $commit_id" \
1544 eac1df47 2021-09-01 stsp >> $testroot/stdout.expected
1545 eac1df47 2021-09-01 stsp
1546 eac1df47 2021-09-01 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1547 49c543a6 2022-03-31 naddy ret=$?
1548 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1549 eac1df47 2021-09-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1550 f0fd0aaf 2021-09-14 stsp test_done "$testroot" "$ret"
1551 f0fd0aaf 2021-09-14 stsp return 1
1552 eac1df47 2021-09-01 stsp fi
1553 f0fd0aaf 2021-09-14 stsp
1554 f0fd0aaf 2021-09-14 stsp git_fsck "$testroot" "$testroot/repo-clone"
1555 49c543a6 2022-03-31 naddy ret=$?
1556 eac1df47 2021-09-01 stsp test_done "$testroot" "$ret"
1557 6242c45b 2022-11-14 op }
1558 6242c45b 2022-11-14 op
1559 b624328e 2024-01-25 falsifian test_send_gitconfig() {
1560 b624328e 2024-01-25 falsifian local testroot=`test_init send_config`
1561 b624328e 2024-01-25 falsifian local testurl=ssh://127.0.0.1/$testroot
1562 b624328e 2024-01-25 falsifian local commit_id=`git_show_head $testroot/repo`
1563 b624328e 2024-01-25 falsifian
1564 b624328e 2024-01-25 falsifian git init -q --bare $testroot/upstream-repo
1565 b624328e 2024-01-25 falsifian ret=$?
1566 b624328e 2024-01-25 falsifian if [ $ret -ne 0 ]; then
1567 b624328e 2024-01-25 falsifian echo "git init failed unexpectedly" >&2
1568 b624328e 2024-01-25 falsifian test_done "$testroot" "$ret"
1569 b624328e 2024-01-25 falsifian return 1
1570 b624328e 2024-01-25 falsifian fi
1571 b624328e 2024-01-25 falsifian
1572 b624328e 2024-01-25 falsifian cat >> $testroot/repo/.git/config <<EOF
1573 b624328e 2024-01-25 falsifian [remote "hasnourl"]
1574 b624328e 2024-01-25 falsifian unrelated = setting
1575 b624328e 2024-01-25 falsifian [remote "foo"]
1576 b624328e 2024-01-25 falsifian url = $testurl/upstream-repo
1577 b624328e 2024-01-25 falsifian [remote "another"]
1578 b624328e 2024-01-25 falsifian url = $testurl/some-other-repo
1579 b624328e 2024-01-25 falsifian EOF
1580 b624328e 2024-01-25 falsifian
1581 b624328e 2024-01-25 falsifian # unset in a subshell to avoid affecting our environment
1582 b624328e 2024-01-25 falsifian (unset GOT_IGNORE_GITCONFIG && got send -q -r $testroot/repo foo)
1583 b624328e 2024-01-25 falsifian ret=$?
1584 b624328e 2024-01-25 falsifian if [ $ret -ne 0 ]; then
1585 b624328e 2024-01-25 falsifian echo "got send command failed unexpectedly" >&2
1586 b624328e 2024-01-25 falsifian test_done "$testroot" "$ret"
1587 b624328e 2024-01-25 falsifian return 1
1588 b624328e 2024-01-25 falsifian fi
1589 b624328e 2024-01-25 falsifian
1590 b624328e 2024-01-25 falsifian got ref -l -r $testroot/upstream-repo > $testroot/stdout
1591 b624328e 2024-01-25 falsifian
1592 b624328e 2024-01-25 falsifian cat > $testroot/stdout.expected <<-EOF
1593 b624328e 2024-01-25 falsifian HEAD: refs/heads/master
1594 b624328e 2024-01-25 falsifian refs/heads/master: $commit_id
1595 b624328e 2024-01-25 falsifian EOF
1596 b624328e 2024-01-25 falsifian
1597 b624328e 2024-01-25 falsifian cmp -s $testroot/stdout $testroot/stdout.expected
1598 b624328e 2024-01-25 falsifian ret=$?
1599 b624328e 2024-01-25 falsifian if [ $ret -ne 0 ]; then
1600 b624328e 2024-01-25 falsifian diff -u $testroot/stdout.expected $testroot/stdout
1601 b624328e 2024-01-25 falsifian fi
1602 b624328e 2024-01-25 falsifian test_done "$testroot" "$ret"
1603 b624328e 2024-01-25 falsifian }
1604 b624328e 2024-01-25 falsifian
1605 6242c45b 2022-11-14 op test_send_rejected() {
1606 6242c45b 2022-11-14 op local testroot=`test_init send_rejected`
1607 6242c45b 2022-11-14 op local testurl=ssh://127.0.0.1/$testroot
1608 6242c45b 2022-11-14 op local commit_id=`git_show_head $testroot/repo`
1609 6242c45b 2022-11-14 op
1610 6242c45b 2022-11-14 op if ! got clone -q "$testurl/repo" "$testroot/repo-clone"; then
1611 6242c45b 2022-11-14 op echo "got clone command failed unexpectedly" >&2
1612 6242c45b 2022-11-14 op test_done "$testroot" 1
1613 6242c45b 2022-11-14 op return 1
1614 6242c45b 2022-11-14 op fi
1615 6242c45b 2022-11-14 op
1616 6242c45b 2022-11-14 op mkdir "$testroot/repo-clone/hooks"
1617 6242c45b 2022-11-14 op cat <<'EOF' >$testroot/repo-clone/hooks/update
1618 6242c45b 2022-11-14 op case "$1" in
1619 6242c45b 2022-11-14 op *master*)
1620 6242c45b 2022-11-14 op echo "rejecting push on master branch"
1621 6242c45b 2022-11-14 op exit 1
1622 6242c45b 2022-11-14 op ;;
1623 6242c45b 2022-11-14 op esac
1624 6242c45b 2022-11-14 op exit 0
1625 6242c45b 2022-11-14 op EOF
1626 6242c45b 2022-11-14 op chmod +x "$testroot/repo-clone/hooks/update"
1627 6242c45b 2022-11-14 op
1628 6242c45b 2022-11-14 op cat > $testroot/repo/.git/got.conf <<EOF
1629 6242c45b 2022-11-14 op remote "origin" {
1630 6242c45b 2022-11-14 op protocol ssh
1631 6242c45b 2022-11-14 op server 127.0.0.1
1632 6242c45b 2022-11-14 op repository "$testroot/repo-clone"
1633 6242c45b 2022-11-14 op }
1634 6242c45b 2022-11-14 op EOF
1635 6242c45b 2022-11-14 op
1636 6242c45b 2022-11-14 op echo "modified alpha" >$testroot/repo/alpha
1637 6242c45b 2022-11-14 op git_commit "$testroot/repo" -m "modified alpha"
1638 6242c45b 2022-11-14 op
1639 6242c45b 2022-11-14 op got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
1640 6242c45b 2022-11-14 op ret=$?
1641 6242c45b 2022-11-14 op if [ $ret -ne 0 ]; then
1642 6242c45b 2022-11-14 op echo "got send command failed unexpectedly" >&2
1643 6242c45b 2022-11-14 op test_done "$testroot" $ret
1644 6242c45b 2022-11-14 op return 1
1645 6242c45b 2022-11-14 op fi
1646 6242c45b 2022-11-14 op
1647 6242c45b 2022-11-14 op touch "$testroot/stdout.expected"
1648 6242c45b 2022-11-14 op if ! cmp -s "$testroot/stdout.expected" "$testroot/stdout"; then
1649 6242c45b 2022-11-14 op diff -u "$testroot/stdout.expected" "$testroot/stdout"
1650 6242c45b 2022-11-14 op test_done "$testroot" 1
1651 6242c45b 2022-11-14 op return 1
1652 6242c45b 2022-11-14 op fi
1653 6242c45b 2022-11-14 op
1654 6242c45b 2022-11-14 op cat <<EOF >$testroot/stderr.expected
1655 6242c45b 2022-11-14 op rejecting push on master branch
1656 6242c45b 2022-11-14 op error: hook declined to update refs/heads/master
1657 6242c45b 2022-11-14 op EOF
1658 6242c45b 2022-11-14 op
1659 6242c45b 2022-11-14 op if ! cmp -s "$testroot/stderr.expected" "$testroot/stderr"; then
1660 6242c45b 2022-11-14 op diff -u "$testroot/stderr.expected" "$testroot/stderr"
1661 6242c45b 2022-11-14 op test_done "$testroot" 1
1662 6242c45b 2022-11-14 op return 1
1663 6242c45b 2022-11-14 op fi
1664 6242c45b 2022-11-14 op
1665 6242c45b 2022-11-14 op test_done "$testroot" 0
1666 3c7a8227 2024-04-17 stsp }
1667 3c7a8227 2024-04-17 stsp
1668 3c7a8227 2024-04-17 stsp test_send_basic_http() {
1669 3c7a8227 2024-04-17 stsp local testroot=`test_init send_basic_http`
1670 3c7a8227 2024-04-17 stsp local testurl=http://127.0.0.1:$GOT_TEST_HTTP_PORT
1671 3c7a8227 2024-04-17 stsp local commit_id=`git_show_head $testroot/repo`
1672 3c7a8227 2024-04-17 stsp
1673 3c7a8227 2024-04-17 stsp timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
1674 3c7a8227 2024-04-17 stsp > $testroot/http-server.log &
1675 c2a5e1d8 2024-04-17 stsp trap "kill %1" HUP INT QUIT PIPE TERM
1676 3c7a8227 2024-04-17 stsp
1677 3c7a8227 2024-04-17 stsp sleep 1 # server starts up
1678 3c7a8227 2024-04-17 stsp
1679 3c7a8227 2024-04-17 stsp got clone -q $testurl/repo $testroot/repo-clone
1680 3c7a8227 2024-04-17 stsp ret=$?
1681 3c7a8227 2024-04-17 stsp if [ $ret -ne 0 ]; then
1682 3c7a8227 2024-04-17 stsp echo "got clone command failed unexpectedly" >&2
1683 3c7a8227 2024-04-17 stsp test_done "$testroot" "$ret"
1684 3c7a8227 2024-04-17 stsp return 1
1685 3c7a8227 2024-04-17 stsp fi
1686 3c7a8227 2024-04-17 stsp cat > $testroot/repo/.git/got.conf <<EOF
1687 3c7a8227 2024-04-17 stsp remote "origin" {
1688 3c7a8227 2024-04-17 stsp protocol http
1689 3c7a8227 2024-04-17 stsp server 127.0.0.1
1690 3c7a8227 2024-04-17 stsp port $GOT_TEST_HTTP_PORT
1691 3c7a8227 2024-04-17 stsp repository "/repo-clone"
1692 3c7a8227 2024-04-17 stsp }
1693 3c7a8227 2024-04-17 stsp EOF
1694 3c7a8227 2024-04-17 stsp got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
1695 3c7a8227 2024-04-17 stsp tag_id=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \
1696 3c7a8227 2024-04-17 stsp | tr -d ' ' | cut -d: -f2`
1697 3c7a8227 2024-04-17 stsp
1698 3c7a8227 2024-04-17 stsp echo "modified alpha" > $testroot/repo/alpha
1699 3c7a8227 2024-04-17 stsp git -C $testroot/repo rm -q beta
1700 3c7a8227 2024-04-17 stsp (cd $testroot/repo && ln -s epsilon/zeta symlink)
1701 3c7a8227 2024-04-17 stsp git -C $testroot/repo add symlink
1702 3c7a8227 2024-04-17 stsp echo "new file alpha" > $testroot/repo/new
1703 3c7a8227 2024-04-17 stsp git -C $testroot/repo add new
1704 3c7a8227 2024-04-17 stsp git_commit $testroot/repo -m "modified alpha"
1705 3c7a8227 2024-04-17 stsp local commit_id2=`git_show_head $testroot/repo`
1706 3c7a8227 2024-04-17 stsp
1707 3c7a8227 2024-04-17 stsp got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
1708 3c7a8227 2024-04-17 stsp ret=$?
1709 3c7a8227 2024-04-17 stsp if [ $ret -eq 0 ]; then
1710 3c7a8227 2024-04-17 stsp echo "got send command succeeded unexpectedly" >&2
1711 3c7a8227 2024-04-17 stsp test_done "$testroot" "$ret"
1712 3c7a8227 2024-04-17 stsp return 1
1713 3c7a8227 2024-04-17 stsp fi
1714 3c7a8227 2024-04-17 stsp
1715 3c7a8227 2024-04-17 stsp kill %1
1716 3c7a8227 2024-04-17 stsp wait %1 # wait for http-server
1717 3c7a8227 2024-04-17 stsp
1718 3c7a8227 2024-04-17 stsp echo "got: http: feature not implemented" > $testroot/stderr.expected
1719 3c7a8227 2024-04-17 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1720 3c7a8227 2024-04-17 stsp ret=$?
1721 3c7a8227 2024-04-17 stsp if [ $ret -ne 0 ]; then
1722 3c7a8227 2024-04-17 stsp diff -u $testroot/stderr.expected $testroot/stderr
1723 3c7a8227 2024-04-17 stsp fi
1724 3c7a8227 2024-04-17 stsp test_done "$testroot" "$ret"
1725 3c7a8227 2024-04-17 stsp
1726 eac1df47 2021-09-01 stsp }
1727 eac1df47 2021-09-01 stsp
1728 f8a36e22 2021-08-26 stsp test_parseargs "$@"
1729 f8a36e22 2021-08-26 stsp run_test test_send_basic
1730 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required
1731 f8a36e22 2021-08-26 stsp run_test test_send_rebase_required_overwrite
1732 e166551f 2023-04-17 stsp run_test test_send_merge_commit
1733 f8a36e22 2021-08-26 stsp run_test test_send_delete
1734 f8a36e22 2021-08-26 stsp run_test test_send_clone_and_send
1735 f8a36e22 2021-08-26 stsp run_test test_send_tags
1736 26960ff7 2021-09-14 stsp run_test test_send_tag_of_deleted_branch
1737 f8a36e22 2021-08-26 stsp run_test test_send_new_branch
1738 f8a36e22 2021-08-26 stsp run_test test_send_all_branches
1739 f8a36e22 2021-08-26 stsp run_test test_send_to_empty_repo
1740 6480c871 2021-08-30 stsp run_test test_send_and_fetch_config
1741 eac1df47 2021-09-01 stsp run_test test_send_config
1742 b624328e 2024-01-25 falsifian run_test test_send_gitconfig
1743 6242c45b 2022-11-14 op run_test test_send_rejected
1744 3c7a8227 2024-04-17 stsp run_test test_send_basic_http