Repository navigation
Commit 5131bc0
easonLiangWorldedtech
fix: fold a lock key from the deepest existing ancestor, not the immediate parent
Two windows failures remained at 927636e and their names are the diagnosis: 'should create parent directory if it doesn't exist' and 'should handle multi-level directory creation', both 'Lock file is already being held'. They are the fallback itself. When a component of the target is missing, realpath of the immediate parent fails and the fallback can fold case but not a short (8.3) name - while resolveLockKey canonicalises through the highest ancestor it can reach. One file then yields two unequal keys, one .lock directory is asked for twice, and the second acquisition collides with the first.
_lockIdentityKey now walks up from the target and canonicalises the deepest EXISTING ancestor, appending the segments below it and folding case on Windows. The walk starts at the PARENT, not at the file: the lock is the entry <path>.lock beside the file, so the final component must never be resolved through a symlink - doing so folds a link and its referent into one key, and those are two different .lock entries, which is exactly the pair this unit takes on purpose. That distinction was earned, not assumed: the first version of this change started the walk at the file and three existing tests went red. Their mocks were right (realpath does resolve symlinks); the fold was over-folding.
Three win32 tests, one per situation: the whole path exists and is spelled short; the parent is missing and the two spellings differ by case; and the mixed case the CI runner hit - an existing ancestor spelled short with a tail that does not exist yet, which is every create into a directory about to be made. The mocks model the filesystem with one rule (the short spelling of an existing directory resolves to the real one, and nothing below it exists yet) rather than enumerating paths.
Negative controls discriminate the two foldings from each other: folding only the immediate parent turns the mixed test red and nothing else; comparing the two keys as exact strings turns all three red. Both mutants were restored byte-exact.
Ownership: git log --all -S linkPathLockKey shows this unit's b809020 (10:21:31) as the first commit to define the pair, ahead of U8's 84dd3a7 (10:42:48), and each commit is contained only in its own branch. The fold therefore lands here and ports to U8, where the same defect shows as four safeWriteJson.test.ts failures; the port is not byte-identical because U8 folds with a case-only comparison in a different shape.
Verification: 122 passed / 6 skipped across the safeWriteJson, file-safety and ApplyPatchTool specs; prettier --write then --check with the repo config clean; tsc --noEmit with the local paths override 0 errors; eslint . --ext=ts --max-warnings=0 exits 0; eslint-suppressions.json unchanged.1 parent 927636e commit 5131bc0
2 files changed
Lines changed: 90 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
307 | 365 | | |
308 | 366 | | |
309 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
176 | 176 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
182 | 185 | | |
183 | 186 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
191 | 206 | | |
192 | | - | |
193 | | - | |
194 | 207 | | |
195 | 208 | | |
196 | 209 | | |
| |||
0 commit comments