Skip to content

Commit b560707

Browse files
sprohaskagitster
authored andcommitted
Add tests for filesystem challenges (case and unicode normalization)
Git has difficulties on file systems that do not properly distinguish case or modify filenames in unexpected ways. The two major examples are Windows and Mac OS X. Both systems preserve case of file names but do not distinguish between filenames that differ only by case. Simple operations such as "git mv" or "git merge" can fail unexpectedly. In addition, Mac OS X normalizes unicode, which make git's life even harder. This commit adds tests that currently fail but should pass if file system as decribed above are fully supported. The test need to be run on Windows and Mac X as they already pass on Linux. Mitch Tishmack is the original author of the tests for unicode normalization. [jc: fixed-up so that it will use test_expect_success to test on sanely behaving filesystems.] Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 99d8ea2 commit b560707

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

t/t0050-filesystem.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/sh
2+
3+
test_description='Various filesystem issues'
4+
5+
. ./test-lib.sh
6+
7+
auml=`perl -CO -e 'print pack("U",0x00E4)'`
8+
aumlcdiar=`perl -CO -e 'print pack("U",0x0061).pack("U",0x0308)'`
9+
10+
test_expect_success 'see if we expect ' '
11+
12+
test_case=test_expect_success
13+
test_unicode=test_expect_success
14+
mkdir junk &&
15+
echo good >junk/CamelCase &&
16+
echo bad >junk/camelcase &&
17+
if test "$(cat junk/CamelCase)" != good
18+
then
19+
test_case=test_expect_failure
20+
say "will test on a case insensitive filesystem"
21+
fi &&
22+
rm -fr junk &&
23+
mkdir junk &&
24+
>junk/"$auml" &&
25+
case "$(cd junk && echo *)" in
26+
"$aumlcdiar")
27+
test_unicode=test_expect_failure
28+
say "will test on a unicode corrupting filesystem"
29+
;;
30+
*) ;;
31+
esac &&
32+
rm -fr junk
33+
'
34+
35+
test_expect_success "setup case tests" '
36+
37+
touch camelcase &&
38+
git add camelcase &&
39+
git commit -m "initial" &&
40+
git tag initial &&
41+
git checkout -b topic &&
42+
git mv camelcase tmp &&
43+
git mv tmp CamelCase &&
44+
git commit -m "rename" &&
45+
git checkout -f master
46+
47+
'
48+
49+
$test_case 'rename (case change)' '
50+
51+
git mv camelcase CamelCase &&
52+
git commit -m "rename"
53+
54+
'
55+
56+
$test_case 'merge (case change)' '
57+
58+
git reset --hard initial &&
59+
git merge topic
60+
61+
'
62+
63+
test_expect_success "setup unicode normalization tests" '
64+
65+
test_create_repo unicode &&
66+
cd unicode &&
67+
touch "$aumlcdiar" &&
68+
git add "$aumlcdiar" &&
69+
git commit -m initial
70+
git tag initial &&
71+
git checkout -b topic &&
72+
git mv $aumlcdiar tmp &&
73+
git mv tmp "$auml" &&
74+
git commit -m rename &&
75+
git checkout -f master
76+
77+
'
78+
79+
$test_unicode 'rename (silent unicode normalization)' '
80+
81+
git mv "$aumlcdiar" "$auml" &&
82+
git commit -m rename
83+
84+
'
85+
86+
$test_unicode 'merge (silent unicode normalization)' '
87+
88+
git reset --hard initial &&
89+
git merge topic
90+
91+
'
92+
93+
test_done

0 commit comments

Comments
 (0)