Merge branch 'tb/commit-graph-genv2-upgrade-fix' into maint
[git/debian.git] / t / t0050-filesystem.sh
blob5c9dc90d0b096d9f104caedeb035b50b919b6811
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-lib.sh
10 auml=$(printf '\303\244')
11 aumlcdiar=$(printf '\141\314\210')
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
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
29 test_have_prereq SYMLINKS ||
30 say "will test on a filesystem lacking symbolic links"
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
37 else
38 test_expect_success "detection of case insensitive filesystem during repo init" '
40 test_must_fail git config --bool core.ignorecase >/dev/null ||
41 test $(git config --bool core.ignorecase) = false
46 if test_have_prereq SYMLINKS
47 then
48 test_expect_success "detection of filesystem w/o symlink support during repo init" '
50 test_must_fail git config --bool core.symlinks ||
51 test "$(git config --bool core.symlinks)" = true
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
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
74 test_expect_success 'rename (case change)' '
75 git mv camelcase CamelCase &&
76 git commit -m "rename"
79 test_expect_success 'merge (case change)' '
80 rm -f CamelCase &&
81 rm -f camelcase &&
82 git reset --hard initial &&
83 git merge topic
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
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
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
128 $test_unicode 'rename (silent unicode normalization)' '
129 git mv "$aumlcdiar" "$auml" &&
130 git commit -m rename
133 $test_unicode 'merge (silent unicode normalization)' '
134 git reset --hard initial &&
135 git merge topic
138 test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
139 git init repo &&
141 cd repo &&
143 >Gitweb &&
144 git add Gitweb &&
145 git commit -m "add Gitweb" &&
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" &&
154 git checkout main
158 test_done