1#!/bin/sh
2
3test_description='Various filesystem issues'
4
5. ./test-lib.sh
6
7auml=`printf '\xc3\xa4'`
8aumlcdiar=`printf '\x61\xcc\x88'`
9
10case_insensitive=
11unibad=
12test_expect_success 'see if we expect ' '
13
14 test_case=test_expect_success
15 test_unicode=test_expect_success
16 mkdir junk &&
17 echo good >junk/CamelCase &&
18 echo bad >junk/camelcase &&
19 if test "$(cat junk/CamelCase)" != good
20 then
21 test_case=test_expect_failure
22 case_insensitive=t
23 fi &&
24 rm -fr junk &&
25 mkdir junk &&
26 >junk/"$auml" &&
27 case "$(cd junk && echo *)" in
28 "$aumlcdiar")
29 test_unicode=test_expect_failure
30 unibad=t
31 ;;
32 *) ;;
33 esac &&
34 rm -fr junk
35'
36
37test "$case_insensitive" &&
38 say "will test on a case insensitive filesystem"
39test "$unibad" &&
40 say "will test on a unicode corrupting filesystem"
41
42if test "$case_insensitive"
43then
44test_expect_success "detection of case insensitive filesystem during repo init" '
45
46 test $(git config --bool core.ignorecase) = true
47'
48else
49test_expect_success "detection of case insensitive filesystem during repo init" '
50
51 test_must_fail git config --bool core.ignorecase >/dev/null ||
52 test $(git config --bool core.ignorecase) = false
53'
54fi
55
56test_expect_success "setup case tests" '
57
58 git config core.ignorecase true &&
59 touch camelcase &&
60 git add camelcase &&
61 git commit -m "initial" &&
62 git tag initial &&
63 git checkout -b topic &&
64 git mv camelcase tmp &&
65 git mv tmp CamelCase &&
66 git commit -m "rename" &&
67 git checkout -f master
68
69'
70
71$test_case 'rename (case change)' '
72
73 git mv camelcase CamelCase &&
74 git commit -m "rename"
75
76'
77
78$test_case 'merge (case change)' '
79
80 rm -f CamelCase &&
81 rm -f camelcase &&
82 git reset --hard initial &&
83 git merge topic
84
85'
86
87$test_case 'add (with different case)' '
88
89 git reset --hard initial &&
90 rm camelcase &&
91 echo 1 >CamelCase &&
92 git add CamelCase &&
93 test $(git ls-files | grep -i camelcase | wc -l) = 1
94
95'
96
97test_expect_success "setup unicode normalization tests" '
98
99 test_create_repo unicode &&
100 cd unicode &&
101 touch "$aumlcdiar" &&
102 git add "$aumlcdiar" &&
103 git commit -m initial
104 git tag initial &&
105 git checkout -b topic &&
106 git mv $aumlcdiar tmp &&
107 git mv tmp "$auml" &&
108 git commit -m rename &&
109 git checkout -f master
110
111'
112
113$test_unicode 'rename (silent unicode normalization)' '
114
115 git mv "$aumlcdiar" "$auml" &&
116 git commit -m rename
117
118'
119
120$test_unicode 'merge (silent unicode normalization)' '
121
122 git reset --hard initial &&
123 git merge topic
124
125'
126
127test_done