French translation: copy -> copie.
[git/dscho.git] / t / t3910-mac-os-precompose.sh
blob5fe57c5438e72150639fd6b970471a1689d30911
1 #!/bin/sh
3 # Copyright (c) 2012 Torsten Bögershausen
6 test_description='utf-8 decomposed (nfd) converted to precomposed (nfc)'
8 . ./test-lib.sh
10 if ! test_have_prereq UTF8_NFD_TO_NFC
11 then
12 skip_all="filesystem does not corrupt utf-8"
13 test_done
16 # create utf-8 variables
17 Adiarnfc=`printf '\303\204'`
18 Adiarnfd=`printf 'A\314\210'`
20 Odiarnfc=`printf '\303\226'`
21 Odiarnfd=`printf 'O\314\210'`
22 AEligatu=`printf '\303\206'`
23 Invalidu=`printf '\303\377'`
26 #Create a string with 255 bytes (decomposed)
27 Alongd=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte
28 Alongd=$Alongd$Alongd$Alongd #63 Byte
29 Alongd=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte
31 #Create a string with 254 bytes (precomposed)
32 Alongc=$AEligatu$AEligatu$AEligatu$AEligatu$AEligatu #10 Byte
33 Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #50 Byte
34 Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte
35 Alongc=$Alongc$AEligatu$AEligatu #254 Byte
37 test_expect_success "detect if nfd needed" '
38 precomposeunicode=`git config core.precomposeunicode` &&
39 test "$precomposeunicode" = false &&
40 git config core.precomposeunicode true
42 test_expect_success "setup" '
43 >x &&
44 git add x &&
45 git commit -m "1st commit" &&
46 git rm x &&
47 git commit -m "rm x"
49 test_expect_success "setup case mac" '
50 git checkout -b mac_os
52 # This will test nfd2nfc in readdir()
53 test_expect_success "add file Adiarnfc" '
54 echo f.Adiarnfc >f.$Adiarnfc &&
55 git add f.$Adiarnfc &&
56 git commit -m "add f.$Adiarnfc"
58 # This will test nfd2nfc in git stage()
59 test_expect_success "stage file d.Adiarnfd/f.Adiarnfd" '
60 mkdir d.$Adiarnfd &&
61 echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd &&
62 git stage d.$Adiarnfd/f.$Adiarnfd &&
63 git commit -m "add d.$Adiarnfd/f.$Adiarnfd"
65 test_expect_success "add link Adiarnfc" '
66 ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc &&
67 git add l.$Adiarnfc &&
68 git commit -m "add l.Adiarnfc"
70 # This will test git log
71 test_expect_success "git log f.Adiar" '
72 git log f.$Adiarnfc > f.Adiarnfc.log &&
73 git log f.$Adiarnfd > f.Adiarnfd.log &&
74 test -s f.Adiarnfc.log &&
75 test -s f.Adiarnfd.log &&
76 test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
77 rm f.Adiarnfc.log f.Adiarnfd.log
79 # This will test git ls-files
80 test_expect_success "git lsfiles f.Adiar" '
81 git ls-files f.$Adiarnfc > f.Adiarnfc.log &&
82 git ls-files f.$Adiarnfd > f.Adiarnfd.log &&
83 test -s f.Adiarnfc.log &&
84 test -s f.Adiarnfd.log &&
85 test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
86 rm f.Adiarnfc.log f.Adiarnfd.log
88 # This will test git mv
89 test_expect_success "git mv" '
90 git mv f.$Adiarnfd f.$Odiarnfc &&
91 git mv d.$Adiarnfd d.$Odiarnfc &&
92 git mv l.$Adiarnfd l.$Odiarnfc &&
93 git commit -m "mv Adiarnfd Odiarnfc"
95 # Files can be checked out as nfc
96 # And the link has been corrected from nfd to nfc
97 test_expect_success "git checkout nfc" '
98 rm f.$Odiarnfc &&
99 git checkout f.$Odiarnfc
101 # Make it possible to checkout files with their NFD names
102 test_expect_success "git checkout file nfd" '
103 rm -f f.* &&
104 git checkout f.$Odiarnfd
106 # Make it possible to checkout links with their NFD names
107 test_expect_success "git checkout link nfd" '
108 rm l.* &&
109 git checkout l.$Odiarnfd
111 test_expect_success "setup case mac2" '
112 git checkout master &&
113 git reset --hard &&
114 git checkout -b mac_os_2
116 # This will test nfd2nfc in git commit
117 test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" '
118 mkdir d2.$Adiarnfd &&
119 echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd &&
120 git add d2.$Adiarnfd/f.$Adiarnfd &&
121 git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd
123 test_expect_success "setup for long decomposed filename" '
124 git checkout master &&
125 git reset --hard &&
126 git checkout -b mac_os_long_nfd_fn
128 test_expect_success "Add long decomposed filename" '
129 echo longd >$Alongd &&
130 git add * &&
131 git commit -m "Long filename"
133 test_expect_success "setup for long precomposed filename" '
134 git checkout master &&
135 git reset --hard &&
136 git checkout -b mac_os_long_nfc_fn
138 test_expect_success "Add long precomposed filename" '
139 echo longc >$Alongc &&
140 git add * &&
141 git commit -m "Long filename"
143 # Test if the global core.precomposeunicode stops autosensing
144 # Must be the last test case
145 test_expect_success "respect git config --global core.precomposeunicode" '
146 git config --global core.precomposeunicode true &&
147 rm -rf .git &&
148 git init &&
149 precomposeunicode=`git config core.precomposeunicode` &&
150 test "$precomposeunicode" = "true"
153 test_done