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