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 cf85a643 2024-04-09 thomas for i in `seq 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 619437c1 2023-11-29 thomas HEAD: $main_id
358 a9020bab 2023-01-28 thomas refs/heads/foo: $foo_id
359 a9020bab 2023-01-28 thomas refs/heads/main: $main_id
360 a9020bab 2023-01-28 thomas refs/heads/newbranch: $nb_id
361 a9020bab 2023-01-28 thomas refs/heads/newbranch2: $nb2_id
362 a9020bab 2023-01-28 thomas refs/tags/1.0: $tag_id
364 a9020bab 2023-01-28 thomas if ! cmp -s $testroot/refs.expected $testroot/refs; then
365 a9020bab 2023-01-28 thomas diff -u $testroot/refs.expected $testroot/refs
366 a9020bab 2023-01-28 thomas test_done "$testroot" 1
370 a9020bab 2023-01-28 thomas (cd $testroot/repo-clone && git push -d origin foo) >/dev/null 2>&1
372 49563dfb 2023-01-28 thomas if [ $ret -ne 0 ]; then
373 a9020bab 2023-01-28 thomas echo "git push -d failed unexpectedly" >&2
374 a9020bab 2023-01-28 thomas test_done "$testroot" 1
378 a9020bab 2023-01-28 thomas got fetch -q -r $testroot/repo-clone -l >$testroot/refs
379 a9020bab 2023-01-28 thomas cat <<EOF >$testroot/refs.expected
380 a9020bab 2023-01-28 thomas HEAD: refs/heads/main
381 619437c1 2023-11-29 thomas HEAD: $main_id
382 a9020bab 2023-01-28 thomas refs/heads/main: $main_id
383 a9020bab 2023-01-28 thomas refs/heads/newbranch: $nb_id
384 a9020bab 2023-01-28 thomas refs/heads/newbranch2: $nb2_id
385 a9020bab 2023-01-28 thomas refs/tags/1.0: $tag_id
387 a9020bab 2023-01-28 thomas if ! cmp -s $testroot/refs.expected $testroot/refs; then
388 a9020bab 2023-01-28 thomas diff -u $testroot/refs.expected $testroot/refs
389 49563dfb 2023-01-28 thomas test_done "$testroot" 1
393 a9020bab 2023-01-28 thomas # try to delete multiple branches in one go
394 a9020bab 2023-01-28 thomas got send -r $testroot/repo-clone -d newbranch -d newbranch2 \
395 a9020bab 2023-01-28 thomas >$testroot/stdout
397 a9020bab 2023-01-28 thomas if [ $ret -ne 0 ]; then
398 a9020bab 2023-01-28 thomas echo "got send with multiple -d failed unexpectedly" >&2
399 a9020bab 2023-01-28 thomas test_done "$testroot" 1
403 49563dfb 2023-01-28 thomas cat <<EOF >$testroot/stdout.expected
404 49563dfb 2023-01-28 thomas Connecting to "origin" ${GOTD_TEST_REPO_URL}
405 a9020bab 2023-01-28 thomas Server has deleted refs/heads/newbranch2
406 a9020bab 2023-01-28 thomas Server has deleted refs/heads/newbranch
408 49563dfb 2023-01-28 thomas if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
409 49563dfb 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
410 49563dfb 2023-01-28 thomas test_done "$testroot" 1
414 a9020bab 2023-01-28 thomas got fetch -q -r $testroot/repo-clone -l >$testroot/refs
415 a9020bab 2023-01-28 thomas cat <<EOF >$testroot/refs.expected
416 a9020bab 2023-01-28 thomas HEAD: refs/heads/main
417 619437c1 2023-11-29 thomas HEAD: $main_id
418 a9020bab 2023-01-28 thomas refs/heads/main: $main_id
419 a9020bab 2023-01-28 thomas refs/tags/1.0: $tag_id
421 a9020bab 2023-01-28 thomas if ! cmp -s $testroot/refs.expected $testroot/refs; then
422 a9020bab 2023-01-28 thomas diff -u $testroot/refs.expected $testroot/refs
423 a9020bab 2023-01-28 thomas test_done "$testroot" 1
427 49563dfb 2023-01-28 thomas # now try again but while also updating another branch
428 49563dfb 2023-01-28 thomas # other than deleting `foo'.
430 49563dfb 2023-01-28 thomas (cd $testroot/wt && got up -b main && \
431 49563dfb 2023-01-28 thomas echo 'more alpha' > alpha && \
432 49563dfb 2023-01-28 thomas got commit -m 'edit alpha on main' && \
433 49563dfb 2023-01-28 thomas got send -q -b foo) >/dev/null
434 a9020bab 2023-01-28 thomas main_id=`git_show_branch_head "$testroot/repo-clone" main`
436 49563dfb 2023-01-28 thomas got send -r $testroot/repo-clone -d foo -b main | \
437 49563dfb 2023-01-28 thomas grep '^Server has' >$testroot/stdout
439 49563dfb 2023-01-28 thomas if [ $ret -ne 0 ]; then
440 49563dfb 2023-01-28 thomas echo "got send -d foo -b main failed unexpectedly" >&2
441 49563dfb 2023-01-28 thomas test_done "$testroot" 1
445 49563dfb 2023-01-28 thomas cat <<EOF >$testroot/stdout.expected
446 49563dfb 2023-01-28 thomas Server has accepted refs/heads/main
447 49563dfb 2023-01-28 thomas Server has deleted refs/heads/foo
449 49563dfb 2023-01-28 thomas if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
450 49563dfb 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
451 49563dfb 2023-01-28 thomas test_done "$testroot" 1
455 a9020bab 2023-01-28 thomas got fetch -q -r $testroot/repo-clone -l >$testroot/refs
456 a9020bab 2023-01-28 thomas cat <<EOF >$testroot/refs.expected
457 a9020bab 2023-01-28 thomas HEAD: refs/heads/main
458 619437c1 2023-11-29 thomas HEAD: $main_id
459 a9020bab 2023-01-28 thomas refs/heads/main: $main_id
460 a9020bab 2023-01-28 thomas refs/tags/1.0: $tag_id
462 a9020bab 2023-01-28 thomas if ! cmp -s $testroot/refs.expected $testroot/refs; then
463 a9020bab 2023-01-28 thomas diff -u $testroot/refs.expected $testroot/refs
464 a9020bab 2023-01-28 thomas test_done "$testroot" 1
468 49563dfb 2023-01-28 thomas test_done "$testroot" 0
471 f9542c24 2023-04-14 thomas test_rewind_branch() {
472 f9542c24 2023-04-14 thomas local testroot=`test_init rewind_branch 1`
474 f9542c24 2023-04-14 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
476 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
477 f9542c24 2023-04-14 thomas echo "got clone failed unexpectedly" >&2
478 f9542c24 2023-04-14 thomas test_done "$testroot" 1
482 f9542c24 2023-04-14 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
484 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
485 f9542c24 2023-04-14 thomas echo "got checkout failed unexpectedly" >&2
486 f9542c24 2023-04-14 thomas test_done "$testroot" 1
490 f9542c24 2023-04-14 thomas (cd $testroot/wt && got branch foo) >/dev/null
492 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
493 f9542c24 2023-04-14 thomas echo "got branch failed unexpectedly" >&2
494 f9542c24 2023-04-14 thomas test_done "$testroot" 1
498 f9542c24 2023-04-14 thomas echo modified alpha > $testroot/wt/alpha
499 f9542c24 2023-04-14 thomas (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
501 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
502 f9542c24 2023-04-14 thomas echo "got commit failed unexpectedly" >&2
503 f9542c24 2023-04-14 thomas test_done "$testroot" 1
507 f9542c24 2023-04-14 thomas if ! got send -q -r $testroot/repo-clone -b foo; then
508 f9542c24 2023-04-14 thomas echo "got send failed unexpectedly" >&2
509 f9542c24 2023-04-14 thomas test_done "$testroot" 1
513 f9542c24 2023-04-14 thomas local foo_id=`git_show_branch_head "$testroot/repo-clone" foo`
514 f9542c24 2023-04-14 thomas local main_id=`git_show_branch_head "$testroot/repo-clone" main`
515 f9542c24 2023-04-14 thomas local tag_id=`got ref -r "$testroot/repo-clone" -l refs/tags/1.0 | \
516 f9542c24 2023-04-14 thomas awk '{print $2}'`
518 f9542c24 2023-04-14 thomas (cd $testroot/wt && got update -c $main_id) >/dev/null
520 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
521 f9542c24 2023-04-14 thomas echo "got update failed unexpectedly" >&2
522 f9542c24 2023-04-14 thomas test_done "$testroot" 1
526 f9542c24 2023-04-14 thomas (cd $testroot/wt && got histedit -d) >/dev/null
528 f9542c24 2023-04-14 thomas if [ $ret -ne 0 ]; then
529 f9542c24 2023-04-14 thomas echo "got histedit failed unexpectedly" >&2
530 f9542c24 2023-04-14 thomas test_done "$testroot" 1
534 f9542c24 2023-04-14 thomas if ! got send -q -r $testroot/repo-clone -f -b foo; then
535 f9542c24 2023-04-14 thomas echo "got send failed unexpectedly" >&2
536 f9542c24 2023-04-14 thomas test_done "$testroot" 1
540 f9542c24 2023-04-14 thomas got fetch -q -r $testroot/repo-clone -l >$testroot/refs
541 f9542c24 2023-04-14 thomas cat <<EOF >$testroot/refs.expected
542 f9542c24 2023-04-14 thomas HEAD: refs/heads/main
543 619437c1 2023-11-29 thomas HEAD: $main_id
544 f9542c24 2023-04-14 thomas refs/heads/foo: $main_id
545 f9542c24 2023-04-14 thomas refs/heads/main: $main_id
546 f9542c24 2023-04-14 thomas refs/tags/1.0: $tag_id
548 f9542c24 2023-04-14 thomas if ! cmp -s $testroot/refs.expected $testroot/refs; then
549 f9542c24 2023-04-14 thomas diff -u $testroot/refs.expected $testroot/refs
550 f9542c24 2023-04-14 thomas test_done "$testroot" 1
554 f9542c24 2023-04-14 thomas test_done "$testroot" 0
557 f2900386 2022-10-31 thomas test_parseargs "$@"
558 f2900386 2022-10-31 thomas run_test test_send_basic
559 6110f5ef 2023-01-19 thomas run_test test_fetch_more_history
560 d98779cd 2023-01-19 thomas run_test test_send_new_empty_branch
561 49563dfb 2023-01-28 thomas run_test test_delete_branch
562 f9542c24 2023-04-14 thomas run_test test_rewind_branch