3 # Copyright (c) 2023 Omar Polo <op@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot
=`test_init test_dump_bundle`
22 # add a fake reference so that `got log' appears the same in
23 # the cloned repository
24 (cd "$testroot/repo" && got branch
-n origin
/master
)
26 (cd "$testroot/repo" && got log
-p >$testroot/repo.log
)
28 (cd "$testroot/repo" && gotadmin dump
-q master
>$testroot/r.bundle
)
30 echo "gotadmin dump failed unexpectedly" >&2
31 test_done
"$testroot" 1
35 if ! git
-C "$testroot" clone
-b master
-q r.bundle
; then
36 echo "failed to git clone from the generated bundle" >&2
37 test_done
"$testroot" 1
41 if ! (cd "$testroot/r" && got log
-p >$testroot/r.log
); then
42 echo "got log failed unexpectedly" >&2
43 test_done
"$testroot" 1
47 if ! cmp -s "$testroot/repo.log" "$testroot/r.log"; then
48 echo "history differs after clone" >&2
49 diff -u "$testroot/repo.log" "$testroot/r.log"
50 test_done
"$testroot" 1
54 git
-C "$testroot/repo" checkout
-q -b newbranch
56 # commit some changes in the repo
58 echo "alpha edit #$i" > $testroot/repo
/alpha
59 git_commit
"$testroot/repo" -m "edit alpha"
62 (cd "$testroot/repo" && \
63 gotadmin dump
-q -x master newbranch
>$testroot/r.bundle
)
65 echo "gotadmin dump failed unexpectedly" >&2
66 test_done
"$testroot" 1
70 git
-C "$testroot/r" checkout
-q -b newbranch
&& \
71 git
-C "$testroot/r" pull
-q "$testroot/r.bundle" newbranch
73 echo "git pull failed unexpectedly" >&2
74 test_done
"$testroot" 1
78 (cd "$testroot/repo" && got log
-p >$testroot/repo.log
)
80 if ! (cd "$testroot/r" && got log
-p >$testroot/r.log
); then
81 echo "got log failed unexpectedly" >&2
82 test_done
"$testroot" 1
86 if ! cmp -s "$testroot/repo.log" "$testroot/r.log"; then
87 echo "history differs after pull" >&2
88 diff -u "$testroot/repo.log" "$testroot/r.log"
89 test_done
"$testroot" 1
93 test_done
"$testroot" 0
97 run_test test_dump_bundle