3 6ae16afd 2022-10-31 stsp # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
5 6ae16afd 2022-10-31 stsp # Permission to use, copy, modify, and distribute this software for any
6 6ae16afd 2022-10-31 stsp # purpose with or without fee is hereby granted, provided that the above
7 6ae16afd 2022-10-31 stsp # copyright notice and this permission notice appear in all copies.
9 6ae16afd 2022-10-31 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 6ae16afd 2022-10-31 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 6ae16afd 2022-10-31 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 6ae16afd 2022-10-31 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 6ae16afd 2022-10-31 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 6ae16afd 2022-10-31 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 6ae16afd 2022-10-31 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 6ae16afd 2022-10-31 stsp . ../cmdline/common.sh
18 6ae16afd 2022-10-31 stsp . ./common.sh
20 6ae16afd 2022-10-31 stsp test_send_basic() {
21 6ae16afd 2022-10-31 stsp local testroot=`test_init send_basic 1`
23 6da1c69c 2023-01-18 stsp ls -R ${GOTD_TEST_REPO}/objects/pack > $testroot/repo-list.before
25 6ae16afd 2022-10-31 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
27 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
28 6ae16afd 2022-10-31 stsp echo "got clone failed unexpectedly" >&2
29 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
33 5dd8d22b 2023-01-09 stsp # create a second clone to test an incremental fetch with later
34 5dd8d22b 2023-01-09 stsp got clone -q -m ${GOTD_TEST_REPO_URL} $testroot/repo-clone2
36 5dd8d22b 2023-01-09 stsp if [ $ret -ne 0 ]; then
37 5dd8d22b 2023-01-09 stsp echo "got clone failed unexpectedly" >&2
38 5dd8d22b 2023-01-09 stsp test_done "$testroot" "1"
41 6da1c69c 2023-01-18 stsp # same for Git
42 6da1c69c 2023-01-18 stsp git clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone3 \
43 6da1c69c 2023-01-18 stsp >$testroot/stdout 2>$testroot/stderr
45 6da1c69c 2023-01-18 stsp if [ $ret -ne 0 ]; then
46 6da1c69c 2023-01-18 stsp echo "git clone failed unexpectedly" >&2
47 6da1c69c 2023-01-18 stsp test_done "$testroot" "1"
51 6ae16afd 2022-10-31 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
53 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
54 6ae16afd 2022-10-31 stsp echo "got checkout failed unexpectedly" >&2
55 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
59 6ae16afd 2022-10-31 stsp mkdir $testroot/wt/psi
60 6ae16afd 2022-10-31 stsp echo "new" > $testroot/wt/psi/new
61 6ae16afd 2022-10-31 stsp (cd $testroot/wt && got add psi/new > /dev/null)
62 6ae16afd 2022-10-31 stsp echo "more alpha" >> $testroot/wt/alpha
63 6ae16afd 2022-10-31 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
64 6da1c69c 2023-01-18 stsp (cd $testroot/wt && got branch newbranch >/dev/null)
65 6da1c69c 2023-01-18 stsp echo "even more alpha" >> $testroot/wt/alpha
66 6da1c69c 2023-01-18 stsp (cd $testroot/wt && got commit -m 'more changes' > /dev/null)
67 6da1c69c 2023-01-18 stsp got tag -r $testroot/repo-clone -m "tagging 1.0" 1.0 >/dev/null
69 6da1c69c 2023-01-18 stsp got send -b main -b newbranch -q -r $testroot/repo-clone -t 1.0
71 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
72 6ae16afd 2022-10-31 stsp echo "got send failed unexpectedly" >&2
73 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
77 6ae16afd 2022-10-31 stsp # Verify that the send operation worked fine.
78 5dd8d22b 2023-01-09 stsp got fetch -q -r $testroot/repo-clone2
80 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
81 5dd8d22b 2023-01-09 stsp echo "got fetch failed unexpectedly" >&2
82 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
86 6ae16afd 2022-10-31 stsp got tree -R -r $testroot/repo-clone2 > $testroot/stdout
87 6ae16afd 2022-10-31 stsp cat > $testroot/stdout.expected <<EOF
91 6ae16afd 2022-10-31 stsp epsilon/zeta
97 6ae16afd 2022-10-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
99 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
100 6ae16afd 2022-10-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
101 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
105 6da1c69c 2023-01-18 stsp # Verify that git pull works, too
106 6da1c69c 2023-01-18 stsp (cd $testroot/repo-clone3 && git pull -q > $testroot/stdout \
107 6da1c69c 2023-01-18 stsp 2> $testroot/stderr)
109 6da1c69c 2023-01-18 stsp if [ $ret -ne 0 ]; then
110 6da1c69c 2023-01-18 stsp echo "git pull failed unexpectedly" >&2
111 baaae615 2023-06-07 stsp test_done "$testroot" "1"
115 baaae615 2023-06-07 stsp # Verify that git push reports no changes to send and no error.
116 baaae615 2023-06-07 stsp (cd $testroot/repo-clone3 && git push -q > $testroot/stdout \
117 baaae615 2023-06-07 stsp 2> $testroot/stderr)
119 baaae615 2023-06-07 stsp if [ $ret -ne 0 ]; then
120 baaae615 2023-06-07 stsp echo "git push failed unexpectedly" >&2
121 6da1c69c 2023-01-18 stsp test_done "$testroot" "1"
125 6ae16afd 2022-10-31 stsp # sending to a repository should result in a new pack file
126 6da1c69c 2023-01-18 stsp ls -R ${GOTD_TEST_REPO}/objects/pack > $testroot/repo-list.after
127 6ae16afd 2022-10-31 stsp diff -u $testroot/repo-list.before $testroot/repo-list.after \
128 6ae16afd 2022-10-31 stsp > $testroot/repo-list.diff
129 6ae16afd 2022-10-31 stsp grep '^+[^+]' < $testroot/repo-list.diff > $testroot/repo-list.newlines
130 6ae16afd 2022-10-31 stsp nplus=`wc -l < $testroot/repo-list.newlines | tr -d ' '`
131 6ae16afd 2022-10-31 stsp if [ "$nplus" != "2" ]; then
132 6da1c69c 2023-01-18 stsp echo "$nplus new files created:"
133 6da1c69c 2023-01-18 stsp cat $testroot/repo-list.diff
134 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
137 6ae16afd 2022-10-31 stsp egrep -q '\+pack-[a-f0-9]{40}.pack' $testroot/repo-list.newlines
139 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
140 6ae16afd 2022-10-31 stsp echo "new pack file not found in ${GOTD_TEST_REPO}"
141 6ae16afd 2022-10-31 stsp cat $testroot/repo-list.newlines
142 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
145 6ae16afd 2022-10-31 stsp egrep -q '\+pack-[a-f0-9]{40}.idx' $testroot/repo-list.newlines
147 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
148 6ae16afd 2022-10-31 stsp echo "new pack index not found in ${GOTD_TEST_REPO}"
149 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
153 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
156 f9550d47 2023-01-18 stsp test_fetch_more_history() {
157 f9550d47 2023-01-18 stsp local testroot=`test_init fetch_more_history 1`
159 f9550d47 2023-01-18 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
161 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
162 f9550d47 2023-01-18 stsp echo "got clone failed unexpectedly" >&2
163 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
167 f9550d47 2023-01-18 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
169 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
170 f9550d47 2023-01-18 stsp echo "got checkout failed unexpectedly" >&2
171 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
175 f9550d47 2023-01-18 stsp # Create some more commit history on the main branch.
176 f9550d47 2023-01-18 stsp # History needs to be deep enough to trick 'git pull' into sending
177 f9550d47 2023-01-18 stsp # a lot of 'have' lines, which triggered a bug in gotd.
178 f9550d47 2023-01-18 stsp for i in `jot 50`; do
179 f9550d47 2023-01-18 stsp echo "more alpha" >> $testroot/wt/alpha
180 f9550d47 2023-01-18 stsp (cd $testroot/wt && got commit -m 'more changes' > /dev/null)
182 f9550d47 2023-01-18 stsp got send -b main -q -r $testroot/repo-clone
184 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
185 f9550d47 2023-01-18 stsp echo "got send failed unexpectedly" >&2
186 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
190 f9550d47 2023-01-18 stsp # create a second clone to test an incremental fetch with later
191 f9550d47 2023-01-18 stsp got clone -q -m ${GOTD_TEST_REPO_URL} $testroot/repo-clone2
193 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
194 f9550d47 2023-01-18 stsp echo "got clone failed unexpectedly" >&2
195 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
198 f9550d47 2023-01-18 stsp # same for Git, which used to fail:
199 f9550d47 2023-01-18 stsp # fetch-pack: protocol error: bad band #69
200 f9550d47 2023-01-18 stsp # fatal: protocol error: bad pack header
201 f9550d47 2023-01-18 stsp # gotsh: unexpected 'have' packet
202 f9550d47 2023-01-18 stsp git clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone3 \
203 f9550d47 2023-01-18 stsp >$testroot/stdout 2>$testroot/stderr
205 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
206 f9550d47 2023-01-18 stsp echo "git clone failed unexpectedly" >&2
207 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
211 f9550d47 2023-01-18 stsp # Create more commit history on the main branch
212 f9550d47 2023-01-18 stsp echo "more alpha" >> $testroot/wt/alpha
213 f9550d47 2023-01-18 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
214 f9550d47 2023-01-18 stsp echo "more beta" >> $testroot/wt/beta
215 f9550d47 2023-01-18 stsp (cd $testroot/wt && got commit -m 'more changes' > /dev/null)
216 f9550d47 2023-01-18 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
217 f9550d47 2023-01-18 stsp (cd $testroot/wt && got commit -m 'rm epsilon/zeta' > /dev/null)
218 f9550d47 2023-01-18 stsp got send -b main -q -r $testroot/repo-clone
220 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
221 f9550d47 2023-01-18 stsp echo "got send failed unexpectedly" >&2
222 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
226 f9550d47 2023-01-18 stsp # Verify that the new changes can be fetched
227 f9550d47 2023-01-18 stsp got fetch -q -r $testroot/repo-clone2
229 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
230 f9550d47 2023-01-18 stsp echo "got fetch failed unexpectedly" >&2
231 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
235 f9550d47 2023-01-18 stsp got tree -R -r $testroot/repo-clone2 > $testroot/stdout
236 f9550d47 2023-01-18 stsp cat > $testroot/stdout.expected <<EOF
240 f9550d47 2023-01-18 stsp gamma/delta
244 f9550d47 2023-01-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
246 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
247 f9550d47 2023-01-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
248 f9550d47 2023-01-18 stsp test_done "$testroot" "$ret"
252 f9550d47 2023-01-18 stsp # Verify that git pull works, too
253 f9550d47 2023-01-18 stsp (cd $testroot/repo-clone3 && git pull -q > $testroot/stdout \
254 f9550d47 2023-01-18 stsp 2> $testroot/stderr)
256 f9550d47 2023-01-18 stsp if [ $ret -ne 0 ]; then
257 f9550d47 2023-01-18 stsp echo "git pull failed unexpectedly" >&2
258 f9550d47 2023-01-18 stsp test_done "$testroot" "1"
262 f9550d47 2023-01-18 stsp test_done "$testroot" "$ret"
265 0ff2c315 2023-01-18 stsp test_send_new_empty_branch() {
266 0ff2c315 2023-01-18 stsp local testroot=`test_init send_new_empty_branch 1`
268 0ff2c315 2023-01-18 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
270 0ff2c315 2023-01-18 stsp if [ $ret -ne 0 ]; then
271 0ff2c315 2023-01-18 stsp echo "got clone failed unexpectedly" >&2
272 0ff2c315 2023-01-18 stsp test_done "$testroot" "1"
275 0ff2c315 2023-01-18 stsp local commit_id=`git_show_head $testroot/repo-clone`
277 0ff2c315 2023-01-18 stsp got branch -r $testroot/repo-clone -c main newbranch2 >/dev/null
278 0ff2c315 2023-01-18 stsp got send -b newbranch2 -q -r $testroot/repo-clone
280 0ff2c315 2023-01-18 stsp if [ $ret -ne 0 ]; then
281 0ff2c315 2023-01-18 stsp echo "got send failed unexpectedly" >&2
282 0ff2c315 2023-01-18 stsp test_done "$testroot" "1"
286 0ff2c315 2023-01-18 stsp # Verify that the send operation worked fine.
287 0ff2c315 2023-01-18 stsp got clone -l ${GOTD_TEST_REPO_URL} | grep newbranch2 > $testroot/stdout
289 0ff2c315 2023-01-18 stsp if [ $ret -ne 0 ]; then
290 0ff2c315 2023-01-18 stsp echo "got clone -l failed unexpectedly" >&2
291 0ff2c315 2023-01-18 stsp test_done "$testroot" "1"
295 0ff2c315 2023-01-18 stsp echo "refs/heads/newbranch2: $commit_id" > $testroot/stdout.expected
296 0ff2c315 2023-01-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
298 0ff2c315 2023-01-18 stsp if [ $ret -ne 0 ]; then
299 0ff2c315 2023-01-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
302 0ff2c315 2023-01-18 stsp test_done "$testroot" "$ret"
305 9a8e357c 2023-01-28 op test_delete_branch() {
306 9a8e357c 2023-01-28 op local testroot=`test_init delete_branch 1`
308 5760205b 2023-01-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
310 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
311 9a8e357c 2023-01-28 op echo "got clone failed unexpectedly" >&2
312 9a8e357c 2023-01-28 op test_done "$testroot" 1
316 9a8e357c 2023-01-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
318 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
319 9a8e357c 2023-01-28 op echo "got checkout failed unexpectedly" >&2
320 9a8e357c 2023-01-28 op test_done "$testroot" 1
324 9a8e357c 2023-01-28 op (cd $testroot/wt && got branch foo) >/dev/null
326 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
327 9a8e357c 2023-01-28 op echo "got branch failed unexpectedly" >&2
328 9a8e357c 2023-01-28 op test_done "$testroot" 1
332 9a8e357c 2023-01-28 op echo modified alpha > $testroot/wt/alpha
333 9a8e357c 2023-01-28 op (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
335 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
336 9a8e357c 2023-01-28 op echo "got commit failed unexpectedly" >&2
337 9a8e357c 2023-01-28 op test_done "$testroot" 1
341 5760205b 2023-01-28 op local foo_id=`git_show_branch_head "$testroot/repo-clone" foo`
342 5760205b 2023-01-28 op local main_id=`git_show_branch_head "$testroot/repo-clone" main`
343 5760205b 2023-01-28 op local nb_id=`git_show_branch_head "$testroot/repo-clone" newbranch`
344 5760205b 2023-01-28 op local nb2_id=`git_show_branch_head "$testroot/repo-clone" newbranch2`
345 5760205b 2023-01-28 op local tag_id=`got ref -r "$testroot/repo-clone" -l refs/tags/1.0 | \
346 5760205b 2023-01-28 op awk '{print $2}'`
348 9a8e357c 2023-01-28 op if ! got send -q -r $testroot/repo-clone -b foo; then
349 9a8e357c 2023-01-28 op echo "got send failed unexpectedly" >&2
350 9a8e357c 2023-01-28 op test_done "$testroot" 1
354 5760205b 2023-01-28 op got fetch -q -r $testroot/repo-clone -l >$testroot/refs
355 5760205b 2023-01-28 op cat <<EOF >$testroot/refs.expected
356 5760205b 2023-01-28 op HEAD: refs/heads/main
357 5760205b 2023-01-28 op refs/heads/foo: $foo_id
358 5760205b 2023-01-28 op refs/heads/main: $main_id
359 5760205b 2023-01-28 op refs/heads/newbranch: $nb_id
360 5760205b 2023-01-28 op refs/heads/newbranch2: $nb2_id
361 5760205b 2023-01-28 op refs/tags/1.0: $tag_id
363 5760205b 2023-01-28 op if ! cmp -s $testroot/refs.expected $testroot/refs; then
364 5760205b 2023-01-28 op diff -u $testroot/refs.expected $testroot/refs
365 5760205b 2023-01-28 op test_done "$testroot" 1
369 5760205b 2023-01-28 op (cd $testroot/repo-clone && git push -d origin foo) >/dev/null 2>&1
371 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
372 5760205b 2023-01-28 op echo "git push -d failed unexpectedly" >&2
373 5760205b 2023-01-28 op test_done "$testroot" 1
377 5760205b 2023-01-28 op got fetch -q -r $testroot/repo-clone -l >$testroot/refs
378 5760205b 2023-01-28 op cat <<EOF >$testroot/refs.expected
379 5760205b 2023-01-28 op HEAD: refs/heads/main
380 5760205b 2023-01-28 op refs/heads/main: $main_id
381 5760205b 2023-01-28 op refs/heads/newbranch: $nb_id
382 5760205b 2023-01-28 op refs/heads/newbranch2: $nb2_id
383 5760205b 2023-01-28 op refs/tags/1.0: $tag_id
385 5760205b 2023-01-28 op if ! cmp -s $testroot/refs.expected $testroot/refs; then
386 5760205b 2023-01-28 op diff -u $testroot/refs.expected $testroot/refs
387 9a8e357c 2023-01-28 op test_done "$testroot" 1
391 5760205b 2023-01-28 op # try to delete multiple branches in one go
392 5760205b 2023-01-28 op got send -r $testroot/repo-clone -d newbranch -d newbranch2 \
393 5760205b 2023-01-28 op >$testroot/stdout
395 5760205b 2023-01-28 op if [ $ret -ne 0 ]; then
396 5760205b 2023-01-28 op echo "got send with multiple -d failed unexpectedly" >&2
397 5760205b 2023-01-28 op test_done "$testroot" 1
401 9a8e357c 2023-01-28 op cat <<EOF >$testroot/stdout.expected
402 9a8e357c 2023-01-28 op Connecting to "origin" ${GOTD_TEST_REPO_URL}
403 5760205b 2023-01-28 op Server has deleted refs/heads/newbranch2
404 5760205b 2023-01-28 op Server has deleted refs/heads/newbranch
406 9a8e357c 2023-01-28 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
407 9a8e357c 2023-01-28 op diff -u $testroot/stdout.expected $testroot/stdout
408 9a8e357c 2023-01-28 op test_done "$testroot" 1
412 5760205b 2023-01-28 op got fetch -q -r $testroot/repo-clone -l >$testroot/refs
413 5760205b 2023-01-28 op cat <<EOF >$testroot/refs.expected
414 5760205b 2023-01-28 op HEAD: refs/heads/main
415 5760205b 2023-01-28 op refs/heads/main: $main_id
416 5760205b 2023-01-28 op refs/tags/1.0: $tag_id
418 5760205b 2023-01-28 op if ! cmp -s $testroot/refs.expected $testroot/refs; then
419 5760205b 2023-01-28 op diff -u $testroot/refs.expected $testroot/refs
420 5760205b 2023-01-28 op test_done "$testroot" 1
424 9a8e357c 2023-01-28 op # now try again but while also updating another branch
425 9a8e357c 2023-01-28 op # other than deleting `foo'.
427 9a8e357c 2023-01-28 op (cd $testroot/wt && got up -b main && \
428 9a8e357c 2023-01-28 op echo 'more alpha' > alpha && \
429 9a8e357c 2023-01-28 op got commit -m 'edit alpha on main' && \
430 9a8e357c 2023-01-28 op got send -q -b foo) >/dev/null
431 5760205b 2023-01-28 op main_id=`git_show_branch_head "$testroot/repo-clone" main`
433 9a8e357c 2023-01-28 op got send -r $testroot/repo-clone -d foo -b main | \
434 9a8e357c 2023-01-28 op grep '^Server has' >$testroot/stdout
436 9a8e357c 2023-01-28 op if [ $ret -ne 0 ]; then
437 9a8e357c 2023-01-28 op echo "got send -d foo -b main failed unexpectedly" >&2
438 9a8e357c 2023-01-28 op test_done "$testroot" 1
442 9a8e357c 2023-01-28 op cat <<EOF >$testroot/stdout.expected
443 9a8e357c 2023-01-28 op Server has accepted refs/heads/main
444 9a8e357c 2023-01-28 op Server has deleted refs/heads/foo
446 9a8e357c 2023-01-28 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
447 9a8e357c 2023-01-28 op diff -u $testroot/stdout.expected $testroot/stdout
448 9a8e357c 2023-01-28 op test_done "$testroot" 1
452 5760205b 2023-01-28 op got fetch -q -r $testroot/repo-clone -l >$testroot/refs
453 5760205b 2023-01-28 op cat <<EOF >$testroot/refs.expected
454 5760205b 2023-01-28 op HEAD: refs/heads/main
455 5760205b 2023-01-28 op refs/heads/main: $main_id
456 5760205b 2023-01-28 op refs/tags/1.0: $tag_id
458 5760205b 2023-01-28 op if ! cmp -s $testroot/refs.expected $testroot/refs; then
459 5760205b 2023-01-28 op diff -u $testroot/refs.expected $testroot/refs
460 5760205b 2023-01-28 op test_done "$testroot" 1
464 9a8e357c 2023-01-28 op test_done "$testroot" 0
467 cc88020e 2023-04-11 stsp test_rewind_branch() {
468 cc88020e 2023-04-11 stsp local testroot=`test_init rewind_branch 1`
470 cc88020e 2023-04-11 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
472 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
473 cc88020e 2023-04-11 stsp echo "got clone failed unexpectedly" >&2
474 cc88020e 2023-04-11 stsp test_done "$testroot" 1
478 cc88020e 2023-04-11 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
480 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
481 cc88020e 2023-04-11 stsp echo "got checkout failed unexpectedly" >&2
482 cc88020e 2023-04-11 stsp test_done "$testroot" 1
486 cc88020e 2023-04-11 stsp (cd $testroot/wt && got branch foo) >/dev/null
488 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
489 cc88020e 2023-04-11 stsp echo "got branch failed unexpectedly" >&2
490 cc88020e 2023-04-11 stsp test_done "$testroot" 1
494 cc88020e 2023-04-11 stsp echo modified alpha > $testroot/wt/alpha
495 cc88020e 2023-04-11 stsp (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
497 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
498 cc88020e 2023-04-11 stsp echo "got commit failed unexpectedly" >&2
499 cc88020e 2023-04-11 stsp test_done "$testroot" 1
503 cc88020e 2023-04-11 stsp if ! got send -q -r $testroot/repo-clone -b foo; then
504 cc88020e 2023-04-11 stsp echo "got send failed unexpectedly" >&2
505 cc88020e 2023-04-11 stsp test_done "$testroot" 1
509 cc88020e 2023-04-11 stsp local foo_id=`git_show_branch_head "$testroot/repo-clone" foo`
510 cc88020e 2023-04-11 stsp local main_id=`git_show_branch_head "$testroot/repo-clone" main`
511 cc88020e 2023-04-11 stsp local tag_id=`got ref -r "$testroot/repo-clone" -l refs/tags/1.0 | \
512 cc88020e 2023-04-11 stsp awk '{print $2}'`
514 cc88020e 2023-04-11 stsp (cd $testroot/wt && got update -c $main_id) >/dev/null
516 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
517 cc88020e 2023-04-11 stsp echo "got update failed unexpectedly" >&2
518 cc88020e 2023-04-11 stsp test_done "$testroot" 1
522 cc88020e 2023-04-11 stsp (cd $testroot/wt && got histedit -d) >/dev/null
524 cc88020e 2023-04-11 stsp if [ $ret -ne 0 ]; then
525 cc88020e 2023-04-11 stsp echo "got histedit failed unexpectedly" >&2
526 cc88020e 2023-04-11 stsp test_done "$testroot" 1
530 cc88020e 2023-04-11 stsp if ! got send -q -r $testroot/repo-clone -f -b foo; then
531 cc88020e 2023-04-11 stsp echo "got send failed unexpectedly" >&2
532 cc88020e 2023-04-11 stsp test_done "$testroot" 1
536 cc88020e 2023-04-11 stsp got fetch -q -r $testroot/repo-clone -l >$testroot/refs
537 cc88020e 2023-04-11 stsp cat <<EOF >$testroot/refs.expected
538 cc88020e 2023-04-11 stsp HEAD: refs/heads/main
539 cc88020e 2023-04-11 stsp refs/heads/foo: $main_id
540 cc88020e 2023-04-11 stsp refs/heads/main: $main_id
541 cc88020e 2023-04-11 stsp refs/tags/1.0: $tag_id
543 cc88020e 2023-04-11 stsp if ! cmp -s $testroot/refs.expected $testroot/refs; then
544 cc88020e 2023-04-11 stsp diff -u $testroot/refs.expected $testroot/refs
545 cc88020e 2023-04-11 stsp test_done "$testroot" 1
549 cc88020e 2023-04-11 stsp test_done "$testroot" 0
552 6ae16afd 2022-10-31 stsp test_parseargs "$@"
553 6ae16afd 2022-10-31 stsp run_test test_send_basic
554 f9550d47 2023-01-18 stsp run_test test_fetch_more_history
555 0ff2c315 2023-01-18 stsp run_test test_send_new_empty_branch
556 9a8e357c 2023-01-28 op run_test test_delete_branch
557 cc88020e 2023-04-11 stsp run_test test_rewind_branch