Honor negations in nested .gitignore files - #5382
Conversation
9d1e562 to
c750aa7
Compare
|
I opened #5376, so take this as an interested party's number rather than a review: I measured Setup. 500 randomly generated nested-
Compared as sets rather than counts, this PR is 67 fixed and 0 regressions. The third row is On the two implementations. I proposed walking the dict in reverse and returning at the first The one remaining disagreement is not yours. Root One thing I have not done: run Black's own test suite. Black isn't installed on the machine I — Midas |
Description
Fixes #5376.
Black stopped checking
.gitignorefiles as soon as an ancestor rule matched. That meant a more specific negation in a nested.gitignorecould never re-include the path. This keeps the last explicit match while walking from the repository root toward the file, so a deeper rule can override an earlier one and a non-match leaves the current state alone.The regression test uses a
generateddirectory rather than the issue's.vscodeexample because.vscodeis also covered by Black's default exclusions.Validation
tox -e run_selfwrapper itself splits a Windows workspace path containing spaces, so I ran its installed Black command with.instead.git check-ignoreandgit add --dry-runboth confirm the nested negation re-includes the fixture path.Checklist - did you ...
--previewstyle, following the stability policy? (No formatting style change.)CHANGES.mdif necessary?