]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0050-filesystem.sh
Sync with 2.36.3
[thirdparty/git.git] / t / t0050-filesystem.sh
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 CASE_INSENSITIVE_FS
14 then
15 say "will test on a case insensitive filesystem"
16 test_case=test_expect_failure
17 else
18 test_case=test_expect_success
19 fi
20
21 if test_have_prereq UTF8_NFD_TO_NFC
22 then
23 say "will test on a unicode corrupting filesystem"
24 test_unicode=test_expect_failure
25 else
26 test_unicode=test_expect_success
27 fi
28
29 test_have_prereq SYMLINKS ||
30 say "will test on a filesystem lacking symbolic links"
31
32 if test_have_prereq CASE_INSENSITIVE_FS
33 then
34 test_expect_success "detection of case insensitive filesystem during repo init" '
35 test $(git config --bool core.ignorecase) = true
36 '
37 else
38 test_expect_success "detection of case insensitive filesystem during repo init" '
39 {
40 test_must_fail git config --bool core.ignorecase >/dev/null ||
41 test $(git config --bool core.ignorecase) = false
42 }
43 '
44 fi
45
46 if test_have_prereq SYMLINKS
47 then
48 test_expect_success "detection of filesystem w/o symlink support during repo init" '
49 {
50 test_must_fail git config --bool core.symlinks ||
51 test "$(git config --bool core.symlinks)" = true
52 }
53 '
54 else
55 test_expect_success "detection of filesystem w/o symlink support during repo init" '
56 v=$(git config --bool core.symlinks) &&
57 test "$v" = false
58 '
59 fi
60
61 test_expect_success "setup case tests" '
62 git config core.ignorecase true &&
63 touch camelcase &&
64 git add camelcase &&
65 git commit -m "initial" &&
66 git tag initial &&
67 git checkout -b topic &&
68 git mv camelcase tmp &&
69 git mv tmp CamelCase &&
70 git commit -m "rename" &&
71 git checkout -f main
72 '
73
74 test_expect_success 'rename (case change)' '
75 git mv camelcase CamelCase &&
76 git commit -m "rename"
77 '
78
79 test_expect_success 'merge (case change)' '
80 rm -f CamelCase &&
81 rm -f camelcase &&
82 git reset --hard initial &&
83 git merge topic
84 '
85
86 test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
87 git reset --hard initial &&
88 mkdir -p dir1/dir2 &&
89 echo >dir1/dir2/a &&
90 echo >dir1/dir2/b &&
91 git add dir1/dir2/a &&
92 git add dir1/DIR2/b &&
93 git ls-files >actual &&
94 cat >expected <<-\EOF &&
95 camelcase
96 dir1/dir2/a
97 dir1/dir2/b
98 EOF
99 test_cmp expected actual
100 '
101
102 test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
103 git reset --hard initial &&
104 rm camelcase &&
105 echo 1 >CamelCase &&
106 git add CamelCase &&
107 git ls-files >tmp &&
108 camel=$(grep -i camelcase tmp) &&
109 test $(echo "$camel" | wc -l) = 1 &&
110 test "z$(git cat-file blob :$camel)" = z1
111 '
112
113 test_expect_success "setup unicode normalization tests" '
114 test_create_repo unicode &&
115 cd unicode &&
116 git config core.precomposeunicode false &&
117 touch "$aumlcdiar" &&
118 git add "$aumlcdiar" &&
119 git commit -m initial &&
120 git tag initial &&
121 git checkout -b topic &&
122 git mv $aumlcdiar tmp &&
123 git mv tmp "$auml" &&
124 git commit -m rename &&
125 git checkout -f main
126 '
127
128 $test_unicode 'rename (silent unicode normalization)' '
129 git mv "$aumlcdiar" "$auml" &&
130 git commit -m rename
131 '
132
133 $test_unicode 'merge (silent unicode normalization)' '
134 git reset --hard initial &&
135 git merge topic
136 '
137
138 test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
139 git init repo &&
140 (
141 cd repo &&
142
143 >Gitweb &&
144 git add Gitweb &&
145 git commit -m "add Gitweb" &&
146
147 git checkout --orphan todo &&
148 git reset --hard &&
149 mkdir -p gitweb/subdir &&
150 >gitweb/subdir/file &&
151 git add gitweb &&
152 git commit -m "add gitweb/subdir/file" &&
153
154 git checkout main
155 )
156 '
157
158 test_done