3 # Copyright (c) 2012 Torsten Bögershausen
6 test_description
='utf-8 decomposed (nfd) converted to precomposed (nfc)'
10 Adiarnfc
=`printf '\303\204'`
11 Adiarnfd
=`printf 'A\314\210'`
13 # check if the feature is compiled in
16 case "$(cd junk && echo *)" in
27 # create more utf-8 variables
28 Odiarnfc
=`printf '\303\226'`
29 Odiarnfd
=`printf 'O\314\210'`
30 AEligatu
=`printf '\303\206'`
31 Invalidu
=`printf '\303\377'`
34 #Create a string with 255 bytes (decomposed)
35 Alongd
=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte
36 Alongd
=$Alongd$Alongd$Alongd #63 Byte
37 Alongd
=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte
39 #Create a string with 254 bytes (precomposed)
40 Alongc
=$AEligatu$AEligatu$AEligatu$AEligatu$AEligatu #10 Byte
41 Alongc
=$Alongc$Alongc$Alongc$Alongc$Alongc #50 Byte
42 Alongc
=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte
43 Alongc
=$Alongc$AEligatu$AEligatu #254 Byte
45 test_expect_success
"detect if nfd needed" '
46 precomposeunicode=`git config core.precomposeunicode` &&
47 test "$precomposeunicode" = false &&
48 git config core.precomposeunicode true
50 test_expect_success
"setup" '
53 git commit -m "1st commit" &&
57 test_expect_success
"setup case mac" '
58 git checkout -b mac_os
60 # This will test nfd2nfc in readdir()
61 test_expect_success
"add file Adiarnfc" '
62 echo f.Adiarnfc >f.$Adiarnfc &&
63 git add f.$Adiarnfc &&
64 git commit -m "add f.$Adiarnfc"
66 # This will test nfd2nfc in git stage()
67 test_expect_success
"stage file d.Adiarnfd/f.Adiarnfd" '
69 echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd &&
70 git stage d.$Adiarnfd/f.$Adiarnfd &&
71 git commit -m "add d.$Adiarnfd/f.$Adiarnfd"
73 test_expect_success
"add link Adiarnfc" '
74 ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc &&
75 git add l.$Adiarnfc &&
76 git commit -m "add l.Adiarnfc"
78 # This will test git log
79 test_expect_success
"git log f.Adiar" '
80 git log f.$Adiarnfc > f.Adiarnfc.log &&
81 git log f.$Adiarnfd > f.Adiarnfd.log &&
82 test -s f.Adiarnfc.log &&
83 test -s f.Adiarnfd.log &&
84 test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
85 rm f.Adiarnfc.log f.Adiarnfd.log
87 # This will test git ls-files
88 test_expect_success
"git lsfiles f.Adiar" '
89 git ls-files f.$Adiarnfc > f.Adiarnfc.log &&
90 git ls-files f.$Adiarnfd > f.Adiarnfd.log &&
91 test -s f.Adiarnfc.log &&
92 test -s f.Adiarnfd.log &&
93 test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
94 rm f.Adiarnfc.log f.Adiarnfd.log
96 # This will test git mv
97 test_expect_success
"git mv" '
98 git mv f.$Adiarnfd f.$Odiarnfc &&
99 git mv d.$Adiarnfd d.$Odiarnfc &&
100 git mv l.$Adiarnfd l.$Odiarnfc &&
101 git commit -m "mv Adiarnfd Odiarnfc"
103 # Files can be checked out as nfc
104 # And the link has been corrected from nfd to nfc
105 test_expect_success
"git checkout nfc" '
107 git checkout f.$Odiarnfc
109 # Make it possible to checkout files with their NFD names
110 test_expect_success
"git checkout file nfd" '
112 git checkout f.$Odiarnfd
114 # Make it possible to checkout links with their NFD names
115 test_expect_success
"git checkout link nfd" '
117 git checkout l.$Odiarnfd
119 test_expect_success
"setup case mac2" '
120 git checkout master &&
122 git checkout -b mac_os_2
124 # This will test nfd2nfc in git commit
125 test_expect_success
"commit file d2.Adiarnfd/f.Adiarnfd" '
126 mkdir d2.$Adiarnfd &&
127 echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd &&
128 git add d2.$Adiarnfd/f.$Adiarnfd &&
129 git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd
131 test_expect_success
"setup for long decomposed filename" '
132 git checkout master &&
134 git checkout -b mac_os_long_nfd_fn
136 test_expect_success
"Add long decomposed filename" '
137 echo longd >$Alongd &&
139 git commit -m "Long filename"
141 test_expect_success
"setup for long precomposed filename" '
142 git checkout master &&
144 git checkout -b mac_os_long_nfc_fn
146 test_expect_success
"Add long precomposed filename" '
147 echo longc >$Alongc &&
149 git commit -m "Long filename"
151 # Test if the global core.precomposeunicode stops autosensing
152 # Must be the last test case
153 test_expect_success
"respect git config --global core.precomposeunicode" '
154 git config --global core.precomposeunicode true &&
157 precomposeunicode=`git config core.precomposeunicode` &&
158 test "$precomposeunicode" = "true"
161 say
"Skipping nfc/nfd tests"