treewide: be explicit about dependence on oid-array.h
[alt-git.git] / t / t0050-filesystem.sh
blob325eb1c3cd0add75bcaf3b629c2692420c279f8a
1 #!/bin/sh
3 test_description='Various filesystem issues'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 auml=$(printf '\303\244')
12 aumlcdiar=$(printf '\141\314\210')
14 if test_have_prereq CASE_INSENSITIVE_FS
15 then
16 say "will test on a case insensitive filesystem"
17 test_case=test_expect_failure
18 else
19 test_case=test_expect_success
22 if test_have_prereq UTF8_NFD_TO_NFC
23 then
24 say "will test on a unicode corrupting filesystem"
25 test_unicode=test_expect_failure
26 else
27 test_unicode=test_expect_success
30 test_have_prereq SYMLINKS ||
31 say "will test on a filesystem lacking symbolic links"
33 if test_have_prereq CASE_INSENSITIVE_FS
34 then
35 test_expect_success "detection of case insensitive filesystem during repo init" '
36 test $(git config --bool core.ignorecase) = true
38 else
39 test_expect_success "detection of case insensitive filesystem during repo init" '
41 test_must_fail git config --bool core.ignorecase >/dev/null ||
42 test $(git config --bool core.ignorecase) = false
47 if test_have_prereq SYMLINKS
48 then
49 test_expect_success "detection of filesystem w/o symlink support during repo init" '
51 test_must_fail git config --bool core.symlinks ||
52 test "$(git config --bool core.symlinks)" = true
55 else
56 test_expect_success "detection of filesystem w/o symlink support during repo init" '
57 v=$(git config --bool core.symlinks) &&
58 test "$v" = false
62 test_expect_success "setup case tests" '
63 git config core.ignorecase true &&
64 touch camelcase &&
65 git add camelcase &&
66 git commit -m "initial" &&
67 git tag initial &&
68 git checkout -b topic &&
69 git mv camelcase tmp &&
70 git mv tmp CamelCase &&
71 git commit -m "rename" &&
72 git checkout -f main
75 test_expect_success 'rename (case change)' '
76 git mv camelcase CamelCase &&
77 git commit -m "rename"
80 test_expect_success 'merge (case change)' '
81 rm -f CamelCase &&
82 rm -f camelcase &&
83 git reset --hard initial &&
84 git merge topic
87 test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
88 git reset --hard initial &&
89 mkdir -p dir1/dir2 &&
90 echo >dir1/dir2/a &&
91 echo >dir1/dir2/b &&
92 git add dir1/dir2/a &&
93 git add dir1/DIR2/b &&
94 git ls-files >actual &&
95 cat >expected <<-\EOF &&
96 camelcase
97 dir1/dir2/a
98 dir1/dir2/b
99 EOF
100 test_cmp expected actual
103 test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
104 git reset --hard initial &&
105 rm camelcase &&
106 echo 1 >CamelCase &&
107 git add CamelCase &&
108 git ls-files >tmp &&
109 camel=$(grep -i camelcase tmp) &&
110 test $(echo "$camel" | wc -l) = 1 &&
111 test "z$(git cat-file blob :$camel)" = z1
114 test_expect_success "setup unicode normalization tests" '
115 test_create_repo unicode &&
116 cd unicode &&
117 git config core.precomposeunicode false &&
118 touch "$aumlcdiar" &&
119 git add "$aumlcdiar" &&
120 git commit -m initial &&
121 git tag initial &&
122 git checkout -b topic &&
123 git mv $aumlcdiar tmp &&
124 git mv tmp "$auml" &&
125 git commit -m rename &&
126 git checkout -f main
129 $test_unicode 'rename (silent unicode normalization)' '
130 git mv "$aumlcdiar" "$auml" &&
131 git commit -m rename
134 $test_unicode 'merge (silent unicode normalization)' '
135 git reset --hard initial &&
136 git merge topic
139 test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
140 git init repo &&
142 cd repo &&
144 >Gitweb &&
145 git add Gitweb &&
146 git commit -m "add Gitweb" &&
148 git checkout --orphan todo &&
149 git reset --hard &&
150 mkdir -p gitweb/subdir &&
151 >gitweb/subdir/file &&
152 git add gitweb &&
153 git commit -m "add gitweb/subdir/file" &&
155 git checkout main
159 test_done