fix: do not list hidden files negated in .gitignore without --hidden - #2097
fix: do not list hidden files negated in .gitignore without --hidden#2097SomSamantray wants to merge 4 commits into
Conversation
tmccombs
left a comment
There was a problem hiding this comment.
The current behavior is intentional.
Hidden files are not supposed to be shown unless --hidden is used. Negation in ignore files is intended to negate the ignore mechanism, not force the file to be shown even if it otherwise wouldn't be.
There was a problem hiding this comment.
This file should not be checked in
|
Oh, I'm sorry, I misread the description. However, I still think this needs work. I'll reopen and submit a needs-work review. |
tmccombs
left a comment
There was a problem hiding this comment.
First of all, I think it would be better if this was fixed in the ignore crate itself, or at least if the ignore create provided an option to do this. See BurntSushi/ripgrep#3514. Although if that is unlikely to happen, or would take to long, I'm fine with something like this.
Secondly, I think we should do this in a way that works for windows as well.
Without
--hidden,fdnow never lists dot-prefixed hidden entries, even when a.gitignorepattern negates them. Previously, a negation such as!.gitignorebypassed the ignore crate's hidden filter and the file was listed; negated hidden directories were traversed as well. Hidden directories are now pruned, so their contents are not searched. With--hidden, behavior is unchanged.The check is name-based and runs before the
--min-depthguard, so the hidden contract holds regardless of depth configuration.Fixes #1266
One known limitation: on Windows, files hidden via
FILE_ATTRIBUTE_HIDDENwhose names lack a leading dot are not covered by the name-based check. The follow-up is tracked separately (see Related).Related: #2096
Validation: new regression test
test_hidden_negated_gitignorefails on master and passes here. It covers self-negated hidden files, negated hidden directories, and--min-depthinterplay. Full suite: 157 unit + 109 integration tests pass;cargo fmtandcargo clippy --all-targets --all-features -- -Dwarningsare clean. Manual repro of the issue verified against a local build.Session-settled decisions carried from planning: no third-party branding on this PR (user-directed); fd contribution guidelines followed (user-directed).
AI disclosure: This PR was produced with the assistance of an AI coding assistant (fix implementation, regression test, changelog entry, and PR scaffolding) and was reviewed by the human author before submission.