t / t0050-filesystem.shon commit Merge branch 'dt/unpack-save-untracked-cache-extension' (fa0624f)
   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
  10if test_have_prereq CASE_INSENSITIVE_FS
  11then
  12        say "will test on a case insensitive filesystem"
  13        test_case=test_expect_failure
  14else
  15        test_case=test_expect_success
  16fi
  17
  18if test_have_prereq UTF8_NFD_TO_NFC
  19then
  20        say "will test on a unicode corrupting filesystem"
  21        test_unicode=test_expect_failure
  22else
  23        test_unicode=test_expect_success
  24fi
  25
  26test_have_prereq SYMLINKS ||
  27        say "will test on a filesystem lacking symbolic links"
  28
  29if test_have_prereq CASE_INSENSITIVE_FS
  30then
  31test_expect_success "detection of case insensitive filesystem during repo init" '
  32        test $(git config --bool core.ignorecase) = true
  33'
  34else
  35test_expect_success "detection of case insensitive filesystem during repo init" '
  36        {
  37                test_must_fail git config --bool core.ignorecase >/dev/null ||
  38                        test $(git config --bool core.ignorecase) = false
  39        }
  40'
  41fi
  42
  43if test_have_prereq SYMLINKS
  44then
  45test_expect_success "detection of filesystem w/o symlink support during repo init" '
  46        {
  47                test_must_fail git config --bool core.symlinks ||
  48                test "$(git config --bool core.symlinks)" = true
  49        }
  50'
  51else
  52test_expect_success "detection of filesystem w/o symlink support during repo init" '
  53        v=$(git config --bool core.symlinks) &&
  54        test "$v" = false
  55'
  56fi
  57
  58test_expect_success "setup case tests" '
  59        git config core.ignorecase true &&
  60        touch camelcase &&
  61        git add camelcase &&
  62        git commit -m "initial" &&
  63        git tag initial &&
  64        git checkout -b topic &&
  65        git mv camelcase tmp &&
  66        git mv tmp CamelCase &&
  67        git commit -m "rename" &&
  68        git checkout -f master
  69'
  70
  71test_expect_success 'rename (case change)' '
  72        git mv camelcase CamelCase &&
  73        git commit -m "rename"
  74'
  75
  76test_expect_success 'merge (case change)' '
  77        rm -f CamelCase &&
  78        rm -f camelcase &&
  79        git reset --hard initial &&
  80        git merge topic
  81'
  82
  83
  84
  85test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
  86        git reset --hard initial &&
  87        rm camelcase &&
  88        echo 1 >CamelCase &&
  89        git add CamelCase &&
  90        camel=$(git ls-files | grep -i camelcase) &&
  91        test $(echo "$camel" | wc -l) = 1 &&
  92        test "z$(git cat-file blob :$camel)" = z1
  93'
  94
  95test_expect_success "setup unicode normalization tests" '
  96        test_create_repo unicode &&
  97        cd unicode &&
  98        git config core.precomposeunicode false &&
  99        touch "$aumlcdiar" &&
 100        git add "$aumlcdiar" &&
 101        git commit -m initial &&
 102        git tag initial &&
 103        git checkout -b topic &&
 104        git mv $aumlcdiar tmp &&
 105        git mv tmp "$auml" &&
 106        git commit -m rename &&
 107        git checkout -f master
 108'
 109
 110$test_unicode 'rename (silent unicode normalization)' '
 111        git mv "$aumlcdiar" "$auml" &&
 112        git commit -m rename
 113'
 114
 115$test_unicode 'merge (silent unicode normalization)' '
 116        git reset --hard initial &&
 117        git merge topic
 118'
 119
 120test_done