i18n: grep: mark parseopt strings for translation
[git/jnareb-git.git] / t / t3910-mac-os-precompose.sh
blob88b7a20c112a523b9c6640d778ac2840ce9adeb4
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 Adiarnfc=`printf '\303\204'`
11 Adiarnfd=`printf 'A\314\210'`
13 # check if the feature is compiled in
14 mkdir junk &&
15 >junk/"$Adiarnfc" &&
16 case "$(cd junk && echo *)" in
17 "$Adiarnfd")
18 test_nfd=1
20 *) ;;
21 esac
22 rm -rf junk
25 if test "$test_nfd"
26 then
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" '
51 >x &&
52 git add x &&
53 git commit -m "1st commit" &&
54 git rm x &&
55 git commit -m "rm x"
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" '
68 mkdir d.$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" '
106 rm f.$Odiarnfc &&
107 git checkout f.$Odiarnfc
109 # Make it possible to checkout files with their NFD names
110 test_expect_success "git checkout file nfd" '
111 rm -f f.* &&
112 git checkout f.$Odiarnfd
114 # Make it possible to checkout links with their NFD names
115 test_expect_success "git checkout link nfd" '
116 rm l.* &&
117 git checkout l.$Odiarnfd
119 test_expect_success "setup case mac2" '
120 git checkout master &&
121 git reset --hard &&
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 &&
133 git reset --hard &&
134 git checkout -b mac_os_long_nfd_fn
136 test_expect_success "Add long decomposed filename" '
137 echo longd >$Alongd &&
138 git add * &&
139 git commit -m "Long filename"
141 test_expect_success "setup for long precomposed filename" '
142 git checkout master &&
143 git reset --hard &&
144 git checkout -b mac_os_long_nfc_fn
146 test_expect_success "Add long precomposed filename" '
147 echo longc >$Alongc &&
148 git add * &&
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 &&
155 rm -rf .git &&
156 git init &&
157 precomposeunicode=`git config core.precomposeunicode` &&
158 test "$precomposeunicode" = "true"
160 else
161 say "Skipping nfc/nfd tests"
164 test_done