t / t1301-shared-repo.shon commit Merge branch 'ns/rebase-noverify' (ce6e5ff)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Johannes Schindelin
   4#
   5
   6test_description='Test shared repository initialization'
   7
   8. ./test-lib.sh
   9
  10# Remove a default ACL from the test dir if possible.
  11setfacl -k . 2>/dev/null
  12
  13# User must have read permissions to the repo -> failure on --shared=0400
  14test_expect_success 'shared = 0400 (faulty permission u-w)' '
  15        mkdir sub && (
  16                cd sub && git init --shared=0400
  17        )
  18        ret="$?"
  19        rm -rf sub
  20        test $ret != "0"
  21'
  22
  23for u in 002 022
  24do
  25        test_expect_success "shared=1 does not clear bits preset by umask $u" '
  26                mkdir sub && (
  27                        cd sub &&
  28                        umask $u &&
  29                        git init --shared=1 &&
  30                        test 1 = "$(git config core.sharedrepository)"
  31                ) &&
  32                actual=$(ls -l sub/.git/HEAD)
  33                case "$actual" in
  34                -rw-rw-r--*)
  35                        : happy
  36                        ;;
  37                *)
  38                        echo Oops, .git/HEAD is not 0664 but $actual
  39                        false
  40                        ;;
  41                esac
  42        '
  43        rm -rf sub
  44done
  45
  46test_expect_success 'shared=all' '
  47        mkdir sub &&
  48        cd sub &&
  49        git init --shared=all &&
  50        test 2 = $(git config core.sharedrepository)
  51'
  52
  53test_expect_success 'update-server-info honors core.sharedRepository' '
  54        : > a1 &&
  55        git add a1 &&
  56        test_tick &&
  57        git commit -m a1 &&
  58        umask 0277 &&
  59        git update-server-info &&
  60        actual="$(ls -l .git/info/refs)" &&
  61        case "$actual" in
  62        -r--r--r--*)
  63                : happy
  64                ;;
  65        *)
  66                echo Oops, .git/info/refs is not 0444
  67                false
  68                ;;
  69        esac
  70'
  71
  72for u in        0660:rw-rw---- \
  73                0640:rw-r----- \
  74                0600:rw------- \
  75                0666:rw-rw-rw- \
  76                0664:rw-rw-r--
  77do
  78        x=$(expr "$u" : ".*:\([rw-]*\)") &&
  79        y=$(echo "$x" | sed -e "s/w/-/g") &&
  80        u=$(expr "$u" : "\([0-7]*\)") &&
  81        git config core.sharedrepository "$u" &&
  82        umask 0277 &&
  83
  84        test_expect_success "shared = $u ($y) ro" '
  85
  86                rm -f .git/info/refs &&
  87                git update-server-info &&
  88                actual="$(ls -l .git/info/refs)" &&
  89                actual=${actual%% *} &&
  90                test "x$actual" = "x-$y" || {
  91                        ls -lt .git/info
  92                        false
  93                }
  94        '
  95
  96        umask 077 &&
  97        test_expect_success "shared = $u ($x) rw" '
  98
  99                rm -f .git/info/refs &&
 100                git update-server-info &&
 101                actual="$(ls -l .git/info/refs)" &&
 102                actual=${actual%% *} &&
 103                test "x$actual" = "x-$x" || {
 104                        ls -lt .git/info
 105                        false
 106                }
 107
 108        '
 109
 110done
 111
 112test_expect_success 'git reflog expire honors core.sharedRepository' '
 113        git config core.sharedRepository group &&
 114        git reflog expire --all &&
 115        actual="$(ls -l .git/logs/refs/heads/master)" &&
 116        case "$actual" in
 117        -rw-rw-*)
 118                : happy
 119                ;;
 120        *)
 121                echo Ooops, .git/logs/refs/heads/master is not 0662 [$actual]
 122                false
 123                ;;
 124        esac
 125'
 126
 127test_done