]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0050-filesystem.sh
The third batch
[thirdparty/git.git] / t / t0050-filesystem.sh
CommitLineData
b560707a
SP
1#!/bin/sh
2
3test_description='Various filesystem issues'
4
06d53148 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
3e3b9321 8TEST_PASSES_SANITIZE_LEAK=true
b560707a
SP
9. ./test-lib.sh
10
77e57265
JN
11auml=$(printf '\303\244')
12aumlcdiar=$(printf '\141\314\210')
b560707a 13
9a3658b9
MG
14if test_have_prereq CASE_INSENSITIVE_FS
15then
5b46a428 16 say "will test on a case insensitive filesystem"
9a3658b9
MG
17 test_case=test_expect_failure
18else
19 test_case=test_expect_success
20fi
21
5b0b5dd4
MG
22if test_have_prereq UTF8_NFD_TO_NFC
23then
5b46a428 24 say "will test on a unicode corrupting filesystem"
5b0b5dd4
MG
25 test_unicode=test_expect_failure
26else
27 test_unicode=test_expect_success
28fi
29
2b71b522 30test_have_prereq SYMLINKS ||
64e61f2d 31 say "will test on a filesystem lacking symbolic links"
5b46a428 32
9a3658b9 33if test_have_prereq CASE_INSENSITIVE_FS
1c51c7d7
SP
34then
35test_expect_success "detection of case insensitive filesystem during repo init" '
1c51c7d7
SP
36 test $(git config --bool core.ignorecase) = true
37'
38else
39test_expect_success "detection of case insensitive filesystem during repo init" '
bfe998fc
JK
40 {
41 test_must_fail git config --bool core.ignorecase >/dev/null ||
42 test $(git config --bool core.ignorecase) = false
43 }
1c51c7d7
SP
44'
45fi
46
2b71b522 47if test_have_prereq SYMLINKS
64e61f2d
JS
48then
49test_expect_success "detection of filesystem w/o symlink support during repo init" '
bfe998fc
JK
50 {
51 test_must_fail git config --bool core.symlinks ||
52 test "$(git config --bool core.symlinks)" = true
53 }
64e61f2d
JS
54'
55else
56test_expect_success "detection of filesystem w/o symlink support during repo init" '
2b71b522
MG
57 v=$(git config --bool core.symlinks) &&
58 test "$v" = false
64e61f2d
JS
59'
60fi
61
b560707a 62test_expect_success "setup case tests" '
b4a299d8 63 git config core.ignorecase true &&
b560707a
SP
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" &&
06d53148 72 git checkout -f main
b560707a
SP
73'
74
decd3c0c 75test_expect_success 'rename (case change)' '
b560707a
SP
76 git mv camelcase CamelCase &&
77 git commit -m "rename"
b560707a
SP
78'
79
004c0be7 80test_expect_success 'merge (case change)' '
0047dd2f
SP
81 rm -f CamelCase &&
82 rm -f camelcase &&
b560707a
SP
83 git reset --hard initial &&
84 git merge topic
b560707a
SP
85'
86
c95525e9
BP
87test_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
101'
0d7c2430 102
4084475b 103test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
8a19aaab
SP
104 git reset --hard initial &&
105 rm camelcase &&
106 echo 1 >CamelCase &&
107 git add CamelCase &&
eed36fce
SM
108 git ls-files >tmp &&
109 camel=$(grep -i camelcase tmp) &&
0d7c2430
JH
110 test $(echo "$camel" | wc -l) = 1 &&
111 test "z$(git cat-file blob :$camel)" = z1
8a19aaab
SP
112'
113
b560707a 114test_expect_success "setup unicode normalization tests" '
336e2e27
TB
115 test_create_repo unicode &&
116 cd unicode &&
92b0c8be 117 git config core.precomposeunicode false &&
336e2e27
TB
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 &&
06d53148 126 git checkout -f main
b560707a
SP
127'
128
129$test_unicode 'rename (silent unicode normalization)' '
336e2e27
TB
130 git mv "$aumlcdiar" "$auml" &&
131 git commit -m rename
b560707a
SP
132'
133
134$test_unicode 'merge (silent unicode normalization)' '
336e2e27
TB
135 git reset --hard initial &&
136 git merge topic
b560707a
SP
137'
138
69f272b9
EN
139test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
140 git init repo &&
141 (
142 cd repo &&
143
144 >Gitweb &&
145 git add Gitweb &&
146 git commit -m "add Gitweb" &&
147
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" &&
154
06d53148 155 git checkout main
69f272b9
EN
156 )
157'
158
b560707a 159test_done