3 # Copyright (c) 2022 Stefan Sperling <stsp@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.
17 . ../cmdline/common.sh
21 local testroot=`test_init clone_basic 1`
23 cp -r ${GOTD_TEST_REPO} $testroot/repo-copy
25 got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
27 if [ $ret -ne 0 ]; then
28 echo "got clone failed unexpectedly" >&2
29 test_done "$testroot" "1"
33 # Verify that the clone operation worked fine.
34 git_fsck "$testroot" "$testroot/repo-clone"
36 if [ $ret -ne 0 ]; then
37 test_done "$testroot" "1"
41 got tree -R -r "$testroot/repo-clone" > $testroot/stdout
42 cat > $testroot/stdout.expected <<EOF
50 cmp -s $testroot/stdout.expected $testroot/stdout
52 if [ $ret -ne 0 ]; then
53 diff -u $testroot/stdout.expected $testroot/stdout
54 test_done "$testroot" "$ret"
58 # cloning a repository should not result in modifications
59 diff -urN ${GOTD_TEST_REPO} $testroot/repo-copy \
61 echo -n > $testroot/stdout.expected
62 cmp -s $testroot/stdout.expected $testroot/stdout
64 if [ $ret -ne 0 ]; then
65 diff -u $testroot/stdout.expected $testroot/stdout
66 test_done "$testroot" "$ret"
70 test_done "$testroot" "$ret"
73 test_send_to_read_only_repo() {
74 local testroot=`test_init send_to_read_only_repo 1`
76 ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.before
78 got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
80 if [ $ret -ne 0 ]; then
81 echo "got clone failed unexpectedly" >&2
82 test_done "$testroot" "1"
86 got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
88 if [ $ret -ne 0 ]; then
89 echo "got checkout failed unexpectedly" >&2
90 test_done "$testroot" "1"
94 mkdir $testroot/wt/psi
95 echo "new" > $testroot/wt/psi/new
96 (cd $testroot/wt && got add psi/new > /dev/null)
97 echo "more alpha" >> $testroot/wt/alpha
98 (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
100 got send -q -r $testroot/repo-clone 2>$testroot/stderr.raw
102 if [ $ret -eq 0 ]; then
103 echo "got send succeeded unexpectedly" >&2
104 test_done "$testroot" "1"
107 grep -v ^gotsh: $testroot/stderr.raw > $testroot/stderr
109 echo 'got-send-pack: test-repo: Permission denied' \
110 > $testroot/stderr.expected
111 echo 'got: could not send pack file' >> $testroot/stderr.expected
112 cmp -s $testroot/stderr.expected $testroot/stderr
114 if [ $ret -ne 0 ]; then
115 diff -u $testroot/stderr.expected $testroot/stderr
117 test_done "$testroot" "$ret"
121 run_test test_clone_basic
122 run_test test_send_to_read_only_repo