Quiet make: do not leave Windows behind
[git/platforms.git] / t / t1301-shared-repo.sh
blobbc7055933be9439c38d5ed18f750b3db80d220a9
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes Schindelin
6 test_description='Test shared repository initialization'
8 . ./test-lib.sh
10 # Remove a default ACL from the test dir if possible.
11 setfacl -k . 2>/dev/null
13 # User must have read permissions to the repo -> failure on --shared=0400
14 test_expect_success 'shared = 0400 (faulty permission u-w)' '
15 mkdir sub && (
16 cd sub && git init --shared=0400
18 ret="$?"
19 rm -rf sub
20 test $ret != "0"
23 modebits () {
24 ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
27 for u in 002 022
29 test_expect_success "shared=1 does not clear bits preset by umask $u" '
30 mkdir sub && (
31 cd sub &&
32 umask $u &&
33 git init --shared=1 &&
34 test 1 = "$(git config core.sharedrepository)"
35 ) &&
36 actual=$(ls -l sub/.git/HEAD)
37 case "$actual" in
38 -rw-rw-r--*)
39 : happy
42 echo Oops, .git/HEAD is not 0664 but $actual
43 false
45 esac
47 rm -rf sub
48 done
50 test_expect_success 'shared=all' '
51 mkdir sub &&
52 cd sub &&
53 git init --shared=all &&
54 test 2 = $(git config core.sharedrepository)
57 say "update-server-info not supported - skipping tests"
58 test_done
59 exit 0
61 test_expect_success 'update-server-info honors core.sharedRepository' '
62 : > a1 &&
63 git add a1 &&
64 test_tick &&
65 git commit -m a1 &&
66 umask 0277 &&
67 git update-server-info &&
68 actual="$(ls -l .git/info/refs)" &&
69 case "$actual" in
70 -r--r--r--*)
71 : happy
74 echo Oops, .git/info/refs is not 0444
75 false
77 esac
80 for u in 0660:rw-rw---- \
81 0640:rw-r----- \
82 0600:rw------- \
83 0666:rw-rw-rw- \
84 0664:rw-rw-r--
86 x=$(expr "$u" : ".*:\([rw-]*\)") &&
87 y=$(echo "$x" | sed -e "s/w/-/g") &&
88 u=$(expr "$u" : "\([0-7]*\)") &&
89 git config core.sharedrepository "$u" &&
90 umask 0277 &&
92 test_expect_success "shared = $u ($y) ro" '
94 rm -f .git/info/refs &&
95 git update-server-info &&
96 actual="$(modebits .git/info/refs)" &&
97 test "x$actual" = "x-$y" || {
98 ls -lt .git/info
99 false
103 umask 077 &&
104 test_expect_success "shared = $u ($x) rw" '
106 rm -f .git/info/refs &&
107 git update-server-info &&
108 actual="$(modebits .git/info/refs)" &&
109 test "x$actual" = "x-$x" || {
110 ls -lt .git/info
111 false
116 done
118 test_expect_success 'git reflog expire honors core.sharedRepository' '
119 git config core.sharedRepository group &&
120 git reflog expire --all &&
121 actual="$(ls -l .git/logs/refs/heads/master)" &&
122 case "$actual" in
123 -rw-rw-*)
124 : happy
127 echo Ooops, .git/logs/refs/heads/master is not 0662 [$actual]
128 false
130 esac
133 test_done