Merge commit 'junio/next' into next
[git/platforms/storm.git] / t / t1301-shared-repo.sh
blob4001fed970818b2fa907a3e9c642c7e0d24f3d6d
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes Schindelin
6 test_description='Test shared repository initialization'
8 . ./test-lib.sh
10 # User must have read permissions to the repo -> failure on --shared=0400
11 test_expect_success 'shared = 0400 (faulty permission u-w)' '
12 mkdir sub && (
13 cd sub && git init --shared=0400
15 ret="$?"
16 rm -rf sub
17 test $ret != "0"
20 test_expect_success 'shared=all' '
21 mkdir sub &&
22 cd sub &&
23 git init --shared=all &&
24 test 2 = $(git config core.sharedrepository)
27 say "update-server-info not supported - skipping tests"
28 test_done
29 exit 0
31 test_expect_success 'update-server-info honors core.sharedRepository' '
32 : > a1 &&
33 git add a1 &&
34 test_tick &&
35 git commit -m a1 &&
36 umask 0277 &&
37 git update-server-info &&
38 actual="$(ls -l .git/info/refs)" &&
39 case "$actual" in
40 -r--r--r--*)
41 : happy
44 echo Oops, .git/info/refs is not 0444
45 false
47 esac
50 for u in 0660:rw-rw---- \
51 0640:rw-r----- \
52 0600:rw------- \
53 0666:rw-rw-rw- \
54 0664:rw-rw-r--
56 x=$(expr "$u" : ".*:\([rw-]*\)") &&
57 y=$(echo "$x" | sed -e "s/w/-/g") &&
58 u=$(expr "$u" : "\([0-7]*\)") &&
59 git config core.sharedrepository "$u" &&
60 umask 0277 &&
62 test_expect_success "shared = $u ($y) ro" '
64 rm -f .git/info/refs &&
65 git update-server-info &&
66 actual="$(ls -l .git/info/refs)" &&
67 actual=${actual%% *} &&
68 test "x$actual" = "x-$y" || {
69 ls -lt .git/info
70 false
74 umask 077 &&
75 test_expect_success "shared = $u ($x) rw" '
77 rm -f .git/info/refs &&
78 git update-server-info &&
79 actual="$(ls -l .git/info/refs)" &&
80 actual=${actual%% *} &&
81 test "x$actual" = "x-$x" || {
82 ls -lt .git/info
83 false
88 done
90 test_done