df9498b7d0793fd116c69de2b83c89f767d80351
   1#!/bin/sh
   2
   3test_description='Various filesystem issues'
   4
   5. ./test-lib.sh
   6
   7auml=$(printf '\303\244')
   8aumlcdiar=$(printf '\141\314\210')
   9
  10unibad=
  11no_symlinks=
  12test_expect_success 'see what we expect' '
  13
  14        test_unicode=test_expect_success &&
  15        mkdir junk &&
  16        >junk/"$auml" &&
  17        case "$(cd junk && echo *)" in
  18        "$aumlcdiar")
  19                test_unicode=test_expect_failure &&
  20                unibad=t
  21                ;;
  22        *)      ;;
  23        esac &&
  24        rm -fr junk &&
  25        {
  26                ln -s x y 2> /dev/null &&
  27                test -h y 2> /dev/null ||
  28                no_symlinks=1 &&
  29                rm -f y
  30        }
  31'
  32
  33if test_have_prereq CASE_INSENSITIVE_FS
  34then
  35        say "will test on a case insensitive filesystem"
  36        test_case=test_expect_failure
  37else
  38        test_case=test_expect_success
  39fi
  40
  41test "$unibad" &&
  42        say "will test on a unicode corrupting filesystem"
  43test "$no_symlinks" &&
  44        say "will test on a filesystem lacking symbolic links"
  45
  46if test_have_prereq CASE_INSENSITIVE_FS
  47then
  48test_expect_success "detection of case insensitive filesystem during repo init" '
  49
  50        test $(git config --bool core.ignorecase) = true
  51'
  52else
  53test_expect_success "detection of case insensitive filesystem during repo init" '
  54
  55        test_must_fail git config --bool core.ignorecase >/dev/null ||
  56        test $(git config --bool core.ignorecase) = false
  57'
  58fi
  59
  60if test "$no_symlinks"
  61then
  62test_expect_success "detection of filesystem w/o symlink support during repo init" '
  63
  64        v=$(git config --bool core.symlinks) &&
  65        test "$v" = false
  66'
  67else
  68test_expect_success "detection of filesystem w/o symlink support during repo init" '
  69
  70        test_must_fail git config --bool core.symlinks ||
  71        test "$(git config --bool core.symlinks)" = true
  72'
  73fi
  74
  75test_expect_success "setup case tests" '
  76
  77        git config core.ignorecase true &&
  78        touch camelcase &&
  79        git add camelcase &&
  80        git commit -m "initial" &&
  81        git tag initial &&
  82        git checkout -b topic &&
  83        git mv camelcase tmp &&
  84        git mv tmp CamelCase &&
  85        git commit -m "rename" &&
  86        git checkout -f master
  87
  88'
  89
  90$test_case 'rename (case change)' '
  91
  92        git mv camelcase CamelCase &&
  93        git commit -m "rename"
  94
  95'
  96
  97$test_case 'merge (case change)' '
  98
  99        rm -f CamelCase &&
 100        rm -f camelcase &&
 101        git reset --hard initial &&
 102        git merge topic
 103
 104'
 105
 106
 107
 108test_expect_failure 'add (with different case)' '
 109
 110        git reset --hard initial &&
 111        rm camelcase &&
 112        echo 1 >CamelCase &&
 113        git add CamelCase &&
 114        camel=$(git ls-files | grep -i camelcase) &&
 115        test $(echo "$camel" | wc -l) = 1 &&
 116        test "z$(git cat-file blob :$camel)" = z1
 117
 118'
 119
 120test_expect_success "setup unicode normalization tests" '
 121
 122  test_create_repo unicode &&
 123  cd unicode &&
 124  touch "$aumlcdiar" &&
 125  git add "$aumlcdiar" &&
 126  git commit -m initial &&
 127  git tag initial &&
 128  git checkout -b topic &&
 129  git mv $aumlcdiar tmp &&
 130  git mv tmp "$auml" &&
 131  git commit -m rename &&
 132  git checkout -f master
 133
 134'
 135
 136$test_unicode 'rename (silent unicode normalization)' '
 137
 138 git mv "$aumlcdiar" "$auml" &&
 139 git commit -m rename
 140
 141'
 142
 143$test_unicode 'merge (silent unicode normalization)' '
 144
 145 git reset --hard initial &&
 146 git merge topic
 147
 148'
 149
 150test_done