| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Various filesystem issues' |
| 4 | |
| 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | auml=$(printf '\303\244') |
| 11 | aumlcdiar=$(printf '\141\314\210') |
| 12 | |
| 13 | if test_have_prereq UTF8_NFD_TO_NFC |
| 14 | then |
| 15 | test_unicode=test_expect_failure |
| 16 | else |
| 17 | test_unicode=test_expect_success |
| 18 | fi |
| 19 | |
| 20 | test_expect_success CASE_INSENSITIVE_FS "detection of case insensitive filesystem during repo init" ' |
| 21 | test $(git config --bool core.ignorecase) = true |
| 22 | ' |
| 23 | |
| 24 | test_expect_success !CASE_INSENSITIVE_FS "detection of case insensitive filesystem during repo init" ' |
| 25 | { |
| 26 | test_must_fail git config --bool core.ignorecase >/dev/null || |
| 27 | test $(git config --bool core.ignorecase) = false |
| 28 | } |
| 29 | ' |
| 30 | |
| 31 | test_expect_success SYMLINKS "detection of filesystem w/o symlink support during repo init" ' |
| 32 | { |
| 33 | test_must_fail git config --bool core.symlinks || |
| 34 | test "$(git config --bool core.symlinks)" = true |
| 35 | } |
| 36 | ' |
| 37 | |
| 38 | test_expect_success !SYMLINKS "detection of filesystem w/o symlink support during repo init" ' |
| 39 | v=$(git config --bool core.symlinks) && |
| 40 | test "$v" = false |
| 41 | ' |
| 42 | |
| 43 | test_expect_success "setup case tests" ' |
| 44 | git config core.ignorecase true && |
| 45 | touch camelcase && |
| 46 | git add camelcase && |
| 47 | git commit -m "initial" && |
| 48 | git tag initial && |
| 49 | git checkout -b topic && |
| 50 | git mv camelcase tmp && |
| 51 | git mv tmp CamelCase && |
| 52 | git commit -m "rename" && |
| 53 | git checkout -f main |
| 54 | ' |
| 55 | |
| 56 | test_expect_success 'rename (case change)' ' |
| 57 | git mv camelcase CamelCase && |
| 58 | git commit -m "rename" |
| 59 | ' |
| 60 | |
| 61 | test_expect_success 'merge (case change)' ' |
| 62 | rm -f CamelCase && |
| 63 | rm -f camelcase && |
| 64 | git reset --hard initial && |
| 65 | git merge topic |
| 66 | ' |
| 67 | |
| 68 | test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' ' |
| 69 | git reset --hard initial && |
| 70 | mkdir -p dir1/dir2 && |
| 71 | echo >dir1/dir2/a && |
| 72 | echo >dir1/dir2/b && |
| 73 | git add dir1/dir2/a && |
| 74 | git add dir1/DIR2/b && |
| 75 | git ls-files >actual && |
| 76 | cat >expected <<-\EOF && |
| 77 | camelcase |
| 78 | dir1/dir2/a |
| 79 | dir1/dir2/b |
| 80 | EOF |
| 81 | test_cmp expected actual |
| 82 | ' |
| 83 | |
| 84 | test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' ' |
| 85 | git reset --hard initial && |
| 86 | rm camelcase && |
| 87 | echo 1 >CamelCase && |
| 88 | git add CamelCase && |
| 89 | git ls-files >tmp && |
| 90 | camel=$(grep -i camelcase tmp) && |
| 91 | test $(echo "$camel" | wc -l) = 1 && |
| 92 | test "z$(git cat-file blob :$camel)" = z1 |
| 93 | ' |
| 94 | |
| 95 | test_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 main |
| 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 | |
| 120 | test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' ' |
| 121 | git init repo && |
| 122 | ( |
| 123 | cd repo && |
| 124 | |
| 125 | >Gitweb && |
| 126 | git add Gitweb && |
| 127 | git commit -m "add Gitweb" && |
| 128 | |
| 129 | git checkout --orphan todo && |
| 130 | git reset --hard && |
| 131 | mkdir -p gitweb/subdir && |
| 132 | >gitweb/subdir/file && |
| 133 | git add gitweb && |
| 134 | git commit -m "add gitweb/subdir/file" && |
| 135 | |
| 136 | git checkout main |
| 137 | ) |
| 138 | ' |
| 139 | |
| 140 | test_done |