fix: special paths are pruned away below the second level - #1202
Open
VXNCXNX wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
special_pathsentry withsum: "never"is honored at the tree root and itsfirst level, then silently ignored deeper. Directory sizes include paths the user
asked to leave out.
Config
special_paths: { "node_modules": { sum: "never" } }, and a tree wherenode_modulessits three levels down, so only the worker threads ever see it(40 dirs, each with a 4M
node_modules/bigand a 1Mkeep):42M is the 40
keepfiles, which is the right answer.Cause
SpecialPaths::reduceprunes the set handed to the deep-summing threads using:A relative conf entry is not stored verbatim.
GlobConf::to_globturns anythingnot starting with
/or~into**/<name>:So the test becomes
"**/node_modules".starts_with("/home/dys/dev"), which isfalse for every directory except the ones that happen to prefix-match the literal
pattern text. The entry is dropped from the reduced set and the special handling
never applies below. An absolute pattern containing a wildcard, such as
/home/*/.cargo, fails the same way once you descend past the fixed part.The fix
Compare against the part of the pattern before the first glob metacharacter,
which every matching path must start with, and treat the presence of a wildcard
as permission to match deeper:
fixedis at least as long as the directory: keep it iffixedstarts with thedirectory, the old test, restricted to the fixed part.
fixedis shorter: keep it only if the pattern has a wildcard and the directorystarts with
fixed.When the path is not valid UTF-8 it now returns true rather than false. That is
the deliberate direction: a false positive costs a few glob matchings, a false
negative silently returns a wrong size.
The cost is real and worth stating: every relative conf entry now stays in the
reduced set at every depth, because
**/xgenuinely can match anywhere. Pruningfor those patterns is weaker than before. The documentation already notes that
"defining a lot of paths will impact the overall speed"; the previous behaviour
was faster only because it was skipping work it should have done.
Verification
test_can_have_matches_incovers the relative case at depth and at root, anabsolute pattern inside and outside its own branch, and an absolute pattern with
a wildcard.
Restoring the old body fails it:
The absolute-pattern assertions pass under that mutation too, which is the point:
they pin the pruning that already worked, so the fix cannot quietly disable it.
cargo testis 60 + 7 passed, 0 failed. Clippy reports nothing on the changedfile.
Disclosure: written with AI assistance (Claude Code). The before and after above come from running two binaries in a real terminal under tmux, not from reading the code, and I ran the mutation check myself.