Fossil SCM
Add pathname unicode tests, including NFD/NFC for handling case collisions on many different filesystems.
Commit
ea810b6f00dd3602d6fc208879a4b3f1a1b452c6c9ec556d61af1abfe562c1f6
Parent
970df5d58b756cb…
1 file changed
+283
+283
| --- a/test/unicode-pathnames.test | ||
| +++ b/test/unicode-pathnames.test | ||
| @@ -0,0 +1,283 @@ | ||
| 1 | +# | |
| 2 | +# Copyright (c) 2026 D. Richard Hipp | |
| 3 | +# | |
| 4 | +# This program is free software; you can redistribute it and/or | |
| 5 | +# modify it under the terms of the Simplified BSD License (also | |
| 6 | +# known as the "2-Clause License" or "FreeBSD License".) | |
| 7 | +# | |
| 8 | +# This program is distributed in the hope that it will be useful, | |
| 9 | +# but without any warranty; without even the implied warranty of | |
| 10 | +# merchantability or fitness for a particular purpose. | |
| 11 | +# | |
| 12 | +# Author contact information: | |
| 13 | +# [email protected] | |
| 14 | +# http://www.hwaci.com/drh/ | |
| 15 | +# | |
| 16 | +############################################################################ | |
| 17 | +# | |
| 18 | +# Pathnames that differ in letter case, or that write the same | |
| 19 | +# characters with different code points: the Unicode normalization | |
| 20 | +# forms NFC, with one code point for an accented letter, and NFD, with | |
| 21 | +# the letter followed by a combining mark. | |
| 22 | +# | |
| 23 | +# With the case-sensitive setting on, fossil compares pathnames byte | |
| 24 | +# for byte, so each spelling is a different file. With the setting | |
| 25 | +# off, two pathnames are the same file when they are a canonical | |
| 26 | +# caseless match (the Unicode Standard, section 3.13, definition D145): | |
| 27 | +# equal after canonical decomposition and case folding. A file system | |
| 28 | +# that ignores case and normalization has one file for both names. | |
| 29 | +# | |
| 30 | +# With the setting off, fossil folds the ASCII letters and compares | |
| 31 | +# every other byte as written, so the tests of names outside ASCII are | |
| 32 | +# marked knownBug. Fossil also checks out, updates to and commits a | |
| 33 | +# version that has two names for one file, so those tests are marked | |
| 34 | +# knownBug for ASCII names too. | |
| 35 | +# | |
| 36 | +# Case folding maps both the sharp s, U+00DF, and the capital sharp s, | |
| 37 | +# U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and | |
| 38 | +# the same name with "ss" are one file. ext4 with case folding folds | |
| 39 | +# each sharp s to "ss" and has one file for the two names. NTFS and | |
| 40 | +# HFS+ convert each character to one character, and have two files. | |
| 41 | +# The sharp-s tests expect one file, because a check-out of both names | |
| 42 | +# loses a file on a file system that has one file for them. | |
| 43 | +# | |
| 44 | + | |
| 45 | +require_no_open_checkout | |
| 46 | + | |
| 47 | +# Fossil reads the pathnames on its command line, and Tcl reads | |
| 48 | +# fossil's output, in the system encoding. | |
| 49 | +# | |
| 50 | +set upSavedEncoding [encoding system] | |
| 51 | +encoding system utf-8 | |
| 52 | + | |
| 53 | +# Returns NAME with each character outside ASCII written as a Tcl | |
| 54 | +# escape, so that two spellings that look the same can be told apart. | |
| 55 | +# | |
| 56 | +proc up_escape {name} { | |
| 57 | + set escaped "" | |
| 58 | + foreach char [split $name ""] { | |
| 59 | + scan $char %c code | |
| 60 | + if {$code > 126} { | |
| 61 | + append escaped [format {\u%04x} $code] | |
| 62 | + } else { | |
| 63 | + append escaped $char | |
| 64 | + } | |
| 65 | + } | |
| 66 | + return $escaped | |
| 67 | +} | |
| 68 | + | |
| 69 | +# Prints the two spellings of the pair LABEL before the tests of that | |
| 70 | +# pair, each unescaped and with escapes. | |
| 71 | +# | |
| 72 | +proc up_show {label a b} { | |
| 73 | + protOut "unicode-pathnames $label: $a ([up_escape $a]) and\ | |
| 74 | + $b ([up_escape $b])" | |
| 75 | +} | |
| 76 | + | |
| 77 | +# Returns the hash of the check-in that the last "fossil commit" made. | |
| 78 | +# | |
| 79 | +proc up_new_version {} { | |
| 80 | + regexp {New_Version: ([0-9a-f]+)} $::RESULT -> hash | |
| 81 | + return $hash | |
| 82 | +} | |
| 83 | + | |
| 84 | +# Each row is a label, the pathname that is checked in, another | |
| 85 | +# spelling of it, and the constraint for the tests that need fossil to | |
| 86 | +# treat the two as one name. | |
| 87 | +# | |
| 88 | +set upSame [list \ | |
| 89 | + ascii readme.txt README.TXT "" \ | |
| 90 | + ascii-dir dir/notes.txt DIR/Notes.TXT "" \ | |
| 91 | + latin "\u00e4rger.txt" "\u00c4RGER.TXT" knownBug \ | |
| 92 | + greek "\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.txt" \ | |
| 93 | + "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" knownBug \ | |
| 94 | + cyrillic "\u0444\u0430\u0439\u043b.txt" \ | |
| 95 | + "\u0424\u0410\u0419\u041b.TXT" knownBug \ | |
| 96 | + sigma "\u03bf\u03b4\u03cc\u03c2.txt" \ | |
| 97 | + "\u039f\u0394\u038c\u03a3.TXT" knownBug \ | |
| 98 | + nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" knownBug \ | |
| 99 | + nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" knownBug \ | |
| 100 | + marks "\u1ead.txt" "a\u0302\u0323.txt" knownBug \ | |
| 101 | + angstrom "\u00e5.txt" "\u212b.TXT" knownBug \ | |
| 102 | + hangul "\ud55c\uae00.txt" \ | |
| 103 | + "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" knownBug \ | |
| 104 | + nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" knownBug \ | |
| 105 | + sharp-s "stra\u00dfe.txt" "STRASSE.TXT" knownBug \ | |
| 106 | + capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" knownBug \ | |
| 107 | + han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" "" \ | |
| 108 | + han-compat "\u8c48.txt" "\uf900.txt" knownBug \ | |
| 109 | + kana "\u30ac\u30d1.txt" \ | |
| 110 | + "\u30ab\u3099\u30cf\u309a.txt" knownBug \ | |
| 111 | + fullwidth "\uff46\uff49\uff4c\uff45.txt" \ | |
| 112 | + "\uff26\uff29\uff2c\uff25.TXT" knownBug \ | |
| 113 | + arabic "\u0623\u062d\u0645\u062f.txt" \ | |
| 114 | + "\u0627\u0654\u062d\u0645\u062f.txt" knownBug \ | |
| 115 | + devanagari "\u0915\u093c.txt" "\u0958.txt" knownBug \ | |
| 116 | +] | |
| 117 | + | |
| 118 | +# Each row is a label, the pathname that is checked in, and a pathname | |
| 119 | +# that is a different file with the setting on or off: a letter without | |
| 120 | +# its accent, a letter with another accent, a digit in place of its | |
| 121 | +# superscript form, a simplified Chinese character in place of the | |
| 122 | +# traditional one, katakana in place of hiragana, and ASCII letters in | |
| 123 | +# place of fullwidth ones. | |
| 124 | +# | |
| 125 | +set upDifferent [list \ | |
| 126 | + accent "expos\u00e9.txt" expose.txt \ | |
| 127 | + other-mark "\u00e5ngstr.txt" "\u00e4ngstr.txt" \ | |
| 128 | + superscript "x\u00b2.txt" x2.txt \ | |
| 129 | + han-variant "\u6a94\u6848.txt" "\u6863\u6848.txt" \ | |
| 130 | + kana-script "\u304b\u306a.txt" "\u30ab\u30ca.txt" \ | |
| 131 | + fullwidth-ascii "\uff41\uff42.txt" ab.txt \ | |
| 132 | +] | |
| 133 | + | |
| 134 | +############################################################################### | |
| 135 | +# | |
| 136 | +# One spelling of each pathname is checked in and on disk. Fossil is | |
| 137 | +# then given the other spelling. | |
| 138 | +# | |
| 139 | +test_setup | |
| 140 | +fossil settings case-sensitive 1 | |
| 141 | + | |
| 142 | +set upNames [list] | |
| 143 | +foreach {label a b constraint} $upSame { | |
| 144 | + file mkdir [file dirname $a] | |
| 145 | + write_file $a "$label\n" | |
| 146 | + lappend upNames $a | |
| 147 | +} | |
| 148 | +foreach {label a b} $upDifferent { | |
| 149 | + write_file $a "$label\n" | |
| 150 | + lappend upNames $a | |
| 151 | +} | |
| 152 | +fossil add {*}$upNames | |
| 153 | +fossil commit -m "one spelling of each pathname" | |
| 154 | + | |
| 155 | +fossil ls | |
| 156 | +test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \ | |
| 157 | + [lsort $upNames] | |
| 158 | + | |
| 159 | +# With the setting on, the other spelling is not a file under | |
| 160 | +# management. | |
| 161 | +# | |
| 162 | +foreach {label a b constraint} $upSame { | |
| 163 | + up_show $label $a $b | |
| 164 | + fossil ls $b | |
| 165 | + test_eq unicode-pathnames-on-$label-ls [normalize_result] "" | |
| 166 | + fossil cat $b -expectError | |
| 167 | + test_eq unicode-pathnames-on-$label-cat $CODE 1 | |
| 168 | +} | |
| 169 | + | |
| 170 | +# With the setting off, "fossil ls", "fossil cat" and "fossil rm" find | |
| 171 | +# the file by its other spelling. | |
| 172 | +# | |
| 173 | +fossil settings case-sensitive 0 | |
| 174 | + | |
| 175 | +foreach {label a b constraint} $upSame { | |
| 176 | + up_show $label $a $b | |
| 177 | + fossil ls $b | |
| 178 | + test_eq unicode-pathnames-off-$label-ls [normalize_result] $a $constraint | |
| 179 | + fossil cat $b {*}[expr {$constraint eq "" ? "" : "-$constraint"}] | |
| 180 | + test_eq unicode-pathnames-off-$label-cat [normalize_result] $label \ | |
| 181 | + $constraint | |
| 182 | + fossil rm --soft -n $b | |
| 183 | + test_eq unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a" \ | |
| 184 | + $constraint | |
| 185 | +} | |
| 186 | + | |
| 187 | +foreach {label a b} $upDifferent { | |
| 188 | + up_show $label $a $b | |
| 189 | + fossil ls $b | |
| 190 | + test_eq unicode-pathnames-off-$label-ls [normalize_result] "" | |
| 191 | + fossil cat $b -expectError | |
| 192 | + test_eq unicode-pathnames-off-$label-cat $CODE 1 | |
| 193 | + fossil rm --soft -n $b | |
| 194 | + test_eq unicode-pathnames-off-$label-rm [normalize_result] "" | |
| 195 | +} | |
| 196 | + | |
| 197 | +# A file on disk under the other spelling is not an extra file, and | |
| 198 | +# "fossil add" does not add it. These tests need a file system that | |
| 199 | +# has two files for the two spellings. | |
| 200 | +# | |
| 201 | +set upOneFile [list] | |
| 202 | +foreach {label a b constraint} $upSame { | |
| 203 | + up_show $label $a $b | |
| 204 | + if {[file exists $b]} { | |
| 205 | + lappend upOneFile $label | |
| 206 | + continue | |
| 207 | + } | |
| 208 | + file mkdir [file dirname $b] | |
| 209 | + write_file $b "other spelling\n" | |
| 210 | + fossil extras | |
| 211 | + test_eq unicode-pathnames-off-$label-extras [normalize_result] "" \ | |
| 212 | + $constraint | |
| 213 | + fossil add $b | |
| 214 | + fossil changes | |
| 215 | + test_eq unicode-pathnames-off-$label-add [normalize_result] "" $constraint | |
| 216 | + fossil revert | |
| 217 | + file delete $b | |
| 218 | + if {[file dirname $b] ne "."} { | |
| 219 | + file delete [file dirname $b] | |
| 220 | + } | |
| 221 | +} | |
| 222 | +if {[llength $upOneFile] > 0} { | |
| 223 | + test_skip_part "extras and add tests of [join $upOneFile {, }]:\ | |
| 224 | + the file system has one file for both spellings" | |
| 225 | +} | |
| 226 | + | |
| 227 | +############################################################################### | |
| 228 | +# | |
| 229 | +# A version made with the setting on has both spellings of a pathname. | |
| 230 | +# With the setting off, fossil does not commit from a check-out of that | |
| 231 | +# version and does not update to it, because a file system that has one | |
| 232 | +# file for both names would give both the same content. | |
| 233 | +# | |
| 234 | +set upCollide [list \ | |
| 235 | + ascii readme.txt README.TXT \ | |
| 236 | + latin "\u00e4rger.txt" "\u00c4RGER.TXT" \ | |
| 237 | + nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \ | |
| 238 | + nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \ | |
| 239 | + sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \ | |
| 240 | +] | |
| 241 | + | |
| 242 | +set upOneFile [list] | |
| 243 | +foreach {label a b} $upCollide { | |
| 244 | + up_show $label $a $b | |
| 245 | + test_setup | |
| 246 | + fossil settings case-sensitive 1 | |
| 247 | + write_file $a "first spelling\n" | |
| 248 | + write_file plain.txt "plain\n" | |
| 249 | + fossil add $a plain.txt | |
| 250 | + fossil commit -m "first spelling" | |
| 251 | + set upFirst [up_new_version] | |
| 252 | + if {[file exists $b]} { | |
| 253 | + lappend upOneFile $label | |
| 254 | + continue | |
| 255 | + } | |
| 256 | + write_file $b "second spelling\n" | |
| 257 | + fossil add $b | |
| 258 | + fossil commit -m "second spelling" | |
| 259 | + set upBoth [up_new_version] | |
| 260 | + | |
| 261 | + fossil settings case-sensitive 0 | |
| 262 | + write_file plain.txt "edited\n" | |
| 263 | + fossil commit -m "edit plain.txt" -expectError -knownBug | |
| 264 | + test_eq unicode-pathnames-collide-$label-commit $CODE 1 knownBug | |
| 265 | + | |
| 266 | + fossil settings case-sensitive 1 | |
| 267 | + fossil revert | |
| 268 | + fossil update $upFirst | |
| 269 | + fossil settings case-sensitive 0 | |
| 270 | + fossil update $upBoth -expectError -knownBug | |
| 271 | + test_eq unicode-pathnames-collide-$label-update $CODE 1 knownBug | |
| 272 | + test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \ | |
| 273 | + knownBug | |
| 274 | +} | |
| 275 | +if {[llength $upOneFile] > 0} { | |
| 276 | + test_skip_part "commit and update tests of [join $upOneFile {, }]:\ | |
| 277 | + the file system has one file for both spellings" | |
| 278 | +} | |
| 279 | + | |
| 280 | +############################################################################### | |
| 281 | + | |
| 282 | +encoding system $upSavedEncoding | |
| 283 | +test_cleanup |
| --- a/test/unicode-pathnames.test | |
| +++ b/test/unicode-pathnames.test | |
| @@ -0,0 +1,283 @@ | |
| --- a/test/unicode-pathnames.test | |
| +++ b/test/unicode-pathnames.test | |
| @@ -0,0 +1,283 @@ | |
| 1 | # |
| 2 | # Copyright (c) 2026 D. Richard Hipp |
| 3 | # |
| 4 | # This program is free software; you can redistribute it and/or |
| 5 | # modify it under the terms of the Simplified BSD License (also |
| 6 | # known as the "2-Clause License" or "FreeBSD License".) |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but without any warranty; without even the implied warranty of |
| 10 | # merchantability or fitness for a particular purpose. |
| 11 | # |
| 12 | # Author contact information: |
| 13 | # [email protected] |
| 14 | # http://www.hwaci.com/drh/ |
| 15 | # |
| 16 | ############################################################################ |
| 17 | # |
| 18 | # Pathnames that differ in letter case, or that write the same |
| 19 | # characters with different code points: the Unicode normalization |
| 20 | # forms NFC, with one code point for an accented letter, and NFD, with |
| 21 | # the letter followed by a combining mark. |
| 22 | # |
| 23 | # With the case-sensitive setting on, fossil compares pathnames byte |
| 24 | # for byte, so each spelling is a different file. With the setting |
| 25 | # off, two pathnames are the same file when they are a canonical |
| 26 | # caseless match (the Unicode Standard, section 3.13, definition D145): |
| 27 | # equal after canonical decomposition and case folding. A file system |
| 28 | # that ignores case and normalization has one file for both names. |
| 29 | # |
| 30 | # With the setting off, fossil folds the ASCII letters and compares |
| 31 | # every other byte as written, so the tests of names outside ASCII are |
| 32 | # marked knownBug. Fossil also checks out, updates to and commits a |
| 33 | # version that has two names for one file, so those tests are marked |
| 34 | # knownBug for ASCII names too. |
| 35 | # |
| 36 | # Case folding maps both the sharp s, U+00DF, and the capital sharp s, |
| 37 | # U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and |
| 38 | # the same name with "ss" are one file. ext4 with case folding folds |
| 39 | # each sharp s to "ss" and has one file for the two names. NTFS and |
| 40 | # HFS+ convert each character to one character, and have two files. |
| 41 | # The sharp-s tests expect one file, because a check-out of both names |
| 42 | # loses a file on a file system that has one file for them. |
| 43 | # |
| 44 | |
| 45 | require_no_open_checkout |
| 46 | |
| 47 | # Fossil reads the pathnames on its command line, and Tcl reads |
| 48 | # fossil's output, in the system encoding. |
| 49 | # |
| 50 | set upSavedEncoding [encoding system] |
| 51 | encoding system utf-8 |
| 52 | |
| 53 | # Returns NAME with each character outside ASCII written as a Tcl |
| 54 | # escape, so that two spellings that look the same can be told apart. |
| 55 | # |
| 56 | proc up_escape {name} { |
| 57 | set escaped "" |
| 58 | foreach char [split $name ""] { |
| 59 | scan $char %c code |
| 60 | if {$code > 126} { |
| 61 | append escaped [format {\u%04x} $code] |
| 62 | } else { |
| 63 | append escaped $char |
| 64 | } |
| 65 | } |
| 66 | return $escaped |
| 67 | } |
| 68 | |
| 69 | # Prints the two spellings of the pair LABEL before the tests of that |
| 70 | # pair, each unescaped and with escapes. |
| 71 | # |
| 72 | proc up_show {label a b} { |
| 73 | protOut "unicode-pathnames $label: $a ([up_escape $a]) and\ |
| 74 | $b ([up_escape $b])" |
| 75 | } |
| 76 | |
| 77 | # Returns the hash of the check-in that the last "fossil commit" made. |
| 78 | # |
| 79 | proc up_new_version {} { |
| 80 | regexp {New_Version: ([0-9a-f]+)} $::RESULT -> hash |
| 81 | return $hash |
| 82 | } |
| 83 | |
| 84 | # Each row is a label, the pathname that is checked in, another |
| 85 | # spelling of it, and the constraint for the tests that need fossil to |
| 86 | # treat the two as one name. |
| 87 | # |
| 88 | set upSame [list \ |
| 89 | ascii readme.txt README.TXT "" \ |
| 90 | ascii-dir dir/notes.txt DIR/Notes.TXT "" \ |
| 91 | latin "\u00e4rger.txt" "\u00c4RGER.TXT" knownBug \ |
| 92 | greek "\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.txt" \ |
| 93 | "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" knownBug \ |
| 94 | cyrillic "\u0444\u0430\u0439\u043b.txt" \ |
| 95 | "\u0424\u0410\u0419\u041b.TXT" knownBug \ |
| 96 | sigma "\u03bf\u03b4\u03cc\u03c2.txt" \ |
| 97 | "\u039f\u0394\u038c\u03a3.TXT" knownBug \ |
| 98 | nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" knownBug \ |
| 99 | nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" knownBug \ |
| 100 | marks "\u1ead.txt" "a\u0302\u0323.txt" knownBug \ |
| 101 | angstrom "\u00e5.txt" "\u212b.TXT" knownBug \ |
| 102 | hangul "\ud55c\uae00.txt" \ |
| 103 | "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" knownBug \ |
| 104 | nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" knownBug \ |
| 105 | sharp-s "stra\u00dfe.txt" "STRASSE.TXT" knownBug \ |
| 106 | capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" knownBug \ |
| 107 | han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" "" \ |
| 108 | han-compat "\u8c48.txt" "\uf900.txt" knownBug \ |
| 109 | kana "\u30ac\u30d1.txt" \ |
| 110 | "\u30ab\u3099\u30cf\u309a.txt" knownBug \ |
| 111 | fullwidth "\uff46\uff49\uff4c\uff45.txt" \ |
| 112 | "\uff26\uff29\uff2c\uff25.TXT" knownBug \ |
| 113 | arabic "\u0623\u062d\u0645\u062f.txt" \ |
| 114 | "\u0627\u0654\u062d\u0645\u062f.txt" knownBug \ |
| 115 | devanagari "\u0915\u093c.txt" "\u0958.txt" knownBug \ |
| 116 | ] |
| 117 | |
| 118 | # Each row is a label, the pathname that is checked in, and a pathname |
| 119 | # that is a different file with the setting on or off: a letter without |
| 120 | # its accent, a letter with another accent, a digit in place of its |
| 121 | # superscript form, a simplified Chinese character in place of the |
| 122 | # traditional one, katakana in place of hiragana, and ASCII letters in |
| 123 | # place of fullwidth ones. |
| 124 | # |
| 125 | set upDifferent [list \ |
| 126 | accent "expos\u00e9.txt" expose.txt \ |
| 127 | other-mark "\u00e5ngstr.txt" "\u00e4ngstr.txt" \ |
| 128 | superscript "x\u00b2.txt" x2.txt \ |
| 129 | han-variant "\u6a94\u6848.txt" "\u6863\u6848.txt" \ |
| 130 | kana-script "\u304b\u306a.txt" "\u30ab\u30ca.txt" \ |
| 131 | fullwidth-ascii "\uff41\uff42.txt" ab.txt \ |
| 132 | ] |
| 133 | |
| 134 | ############################################################################### |
| 135 | # |
| 136 | # One spelling of each pathname is checked in and on disk. Fossil is |
| 137 | # then given the other spelling. |
| 138 | # |
| 139 | test_setup |
| 140 | fossil settings case-sensitive 1 |
| 141 | |
| 142 | set upNames [list] |
| 143 | foreach {label a b constraint} $upSame { |
| 144 | file mkdir [file dirname $a] |
| 145 | write_file $a "$label\n" |
| 146 | lappend upNames $a |
| 147 | } |
| 148 | foreach {label a b} $upDifferent { |
| 149 | write_file $a "$label\n" |
| 150 | lappend upNames $a |
| 151 | } |
| 152 | fossil add {*}$upNames |
| 153 | fossil commit -m "one spelling of each pathname" |
| 154 | |
| 155 | fossil ls |
| 156 | test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \ |
| 157 | [lsort $upNames] |
| 158 | |
| 159 | # With the setting on, the other spelling is not a file under |
| 160 | # management. |
| 161 | # |
| 162 | foreach {label a b constraint} $upSame { |
| 163 | up_show $label $a $b |
| 164 | fossil ls $b |
| 165 | test_eq unicode-pathnames-on-$label-ls [normalize_result] "" |
| 166 | fossil cat $b -expectError |
| 167 | test_eq unicode-pathnames-on-$label-cat $CODE 1 |
| 168 | } |
| 169 | |
| 170 | # With the setting off, "fossil ls", "fossil cat" and "fossil rm" find |
| 171 | # the file by its other spelling. |
| 172 | # |
| 173 | fossil settings case-sensitive 0 |
| 174 | |
| 175 | foreach {label a b constraint} $upSame { |
| 176 | up_show $label $a $b |
| 177 | fossil ls $b |
| 178 | test_eq unicode-pathnames-off-$label-ls [normalize_result] $a $constraint |
| 179 | fossil cat $b {*}[expr {$constraint eq "" ? "" : "-$constraint"}] |
| 180 | test_eq unicode-pathnames-off-$label-cat [normalize_result] $label \ |
| 181 | $constraint |
| 182 | fossil rm --soft -n $b |
| 183 | test_eq unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a" \ |
| 184 | $constraint |
| 185 | } |
| 186 | |
| 187 | foreach {label a b} $upDifferent { |
| 188 | up_show $label $a $b |
| 189 | fossil ls $b |
| 190 | test_eq unicode-pathnames-off-$label-ls [normalize_result] "" |
| 191 | fossil cat $b -expectError |
| 192 | test_eq unicode-pathnames-off-$label-cat $CODE 1 |
| 193 | fossil rm --soft -n $b |
| 194 | test_eq unicode-pathnames-off-$label-rm [normalize_result] "" |
| 195 | } |
| 196 | |
| 197 | # A file on disk under the other spelling is not an extra file, and |
| 198 | # "fossil add" does not add it. These tests need a file system that |
| 199 | # has two files for the two spellings. |
| 200 | # |
| 201 | set upOneFile [list] |
| 202 | foreach {label a b constraint} $upSame { |
| 203 | up_show $label $a $b |
| 204 | if {[file exists $b]} { |
| 205 | lappend upOneFile $label |
| 206 | continue |
| 207 | } |
| 208 | file mkdir [file dirname $b] |
| 209 | write_file $b "other spelling\n" |
| 210 | fossil extras |
| 211 | test_eq unicode-pathnames-off-$label-extras [normalize_result] "" \ |
| 212 | $constraint |
| 213 | fossil add $b |
| 214 | fossil changes |
| 215 | test_eq unicode-pathnames-off-$label-add [normalize_result] "" $constraint |
| 216 | fossil revert |
| 217 | file delete $b |
| 218 | if {[file dirname $b] ne "."} { |
| 219 | file delete [file dirname $b] |
| 220 | } |
| 221 | } |
| 222 | if {[llength $upOneFile] > 0} { |
| 223 | test_skip_part "extras and add tests of [join $upOneFile {, }]:\ |
| 224 | the file system has one file for both spellings" |
| 225 | } |
| 226 | |
| 227 | ############################################################################### |
| 228 | # |
| 229 | # A version made with the setting on has both spellings of a pathname. |
| 230 | # With the setting off, fossil does not commit from a check-out of that |
| 231 | # version and does not update to it, because a file system that has one |
| 232 | # file for both names would give both the same content. |
| 233 | # |
| 234 | set upCollide [list \ |
| 235 | ascii readme.txt README.TXT \ |
| 236 | latin "\u00e4rger.txt" "\u00c4RGER.TXT" \ |
| 237 | nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \ |
| 238 | nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \ |
| 239 | sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \ |
| 240 | ] |
| 241 | |
| 242 | set upOneFile [list] |
| 243 | foreach {label a b} $upCollide { |
| 244 | up_show $label $a $b |
| 245 | test_setup |
| 246 | fossil settings case-sensitive 1 |
| 247 | write_file $a "first spelling\n" |
| 248 | write_file plain.txt "plain\n" |
| 249 | fossil add $a plain.txt |
| 250 | fossil commit -m "first spelling" |
| 251 | set upFirst [up_new_version] |
| 252 | if {[file exists $b]} { |
| 253 | lappend upOneFile $label |
| 254 | continue |
| 255 | } |
| 256 | write_file $b "second spelling\n" |
| 257 | fossil add $b |
| 258 | fossil commit -m "second spelling" |
| 259 | set upBoth [up_new_version] |
| 260 | |
| 261 | fossil settings case-sensitive 0 |
| 262 | write_file plain.txt "edited\n" |
| 263 | fossil commit -m "edit plain.txt" -expectError -knownBug |
| 264 | test_eq unicode-pathnames-collide-$label-commit $CODE 1 knownBug |
| 265 | |
| 266 | fossil settings case-sensitive 1 |
| 267 | fossil revert |
| 268 | fossil update $upFirst |
| 269 | fossil settings case-sensitive 0 |
| 270 | fossil update $upBoth -expectError -knownBug |
| 271 | test_eq unicode-pathnames-collide-$label-update $CODE 1 knownBug |
| 272 | test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \ |
| 273 | knownBug |
| 274 | } |
| 275 | if {[llength $upOneFile] > 0} { |
| 276 | test_skip_part "commit and update tests of [join $upOneFile {, }]:\ |
| 277 | the file system has one file for both spellings" |
| 278 | } |
| 279 | |
| 280 | ############################################################################### |
| 281 | |
| 282 | encoding system $upSavedEncoding |
| 283 | test_cleanup |