t / t1301-shared-repo.shon commit Allow tracking branches to set up rebase by default. (c998ae9)
   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# User must have read permissions to the repo -> failure on --shared=0400
  11test_expect_success 'shared = 0400 (faulty permission u-w)' '
  12        mkdir sub && (
  13                cd sub && git init --shared=0400
  14        )
  15        ret="$?"
  16        rm -rf sub
  17        test $ret != "0"
  18'
  19
  20test_expect_success 'shared=all' '
  21        mkdir sub &&
  22        cd sub &&
  23        git init --shared=all &&
  24        test 2 = $(git config core.sharedrepository)
  25'
  26
  27test_expect_success 'update-server-info honors core.sharedRepository' '
  28        : > a1 &&
  29        git add a1 &&
  30        test_tick &&
  31        git commit -m a1 &&
  32        umask 0277 &&
  33        git update-server-info &&
  34        actual="$(ls -l .git/info/refs)" &&
  35        case "$actual" in
  36        -r--r--r--*)
  37                : happy
  38                ;;
  39        *)
  40                echo Oops, .git/info/refs is not 0444
  41                false
  42                ;;
  43        esac
  44'
  45
  46for u in        0660:rw-rw---- \
  47                0640:rw-r----- \
  48                0600:rw------- \
  49                0666:rw-rw-rw- \
  50                0664:rw-rw-r--
  51do
  52        x=$(expr "$u" : ".*:\([rw-]*\)") &&
  53        y=$(echo "$x" | sed -e "s/w/-/g") &&
  54        u=$(expr "$u" : "\([0-7]*\)") &&
  55        git config core.sharedrepository "$u" &&
  56        umask 0277 &&
  57
  58        test_expect_success "shared = $u ($y) ro" '
  59
  60                rm -f .git/info/refs &&
  61                git update-server-info &&
  62                actual="$(ls -l .git/info/refs)" &&
  63                actual=${actual%% *} &&
  64                test "x$actual" = "x-$y" || {
  65                        ls -lt .git/info
  66                        false
  67                }
  68        '
  69
  70        umask 077 &&
  71        test_expect_success "shared = $u ($x) rw" '
  72
  73                rm -f .git/info/refs &&
  74                git update-server-info &&
  75                actual="$(ls -l .git/info/refs)" &&
  76                actual=${actual%% *} &&
  77                test "x$actual" = "x-$x" || {
  78                        ls -lt .git/info
  79                        false
  80                }
  81
  82        '
  83
  84done
  85
  86test_done