Stop the ignore-file search at the working-tree boundary - #4527
Open
willemkokke wants to merge 1 commit into
Open
Stop the ignore-file search at the working-tree boundary#4527willemkokke wants to merge 1 commit into
willemkokke wants to merge 1 commit into
Conversation
The upward search for .gitignore/.ignore/.git/info/exclude treated the directory tree as one hierarchy: from a linked worktree (whose .git is a gitdir pointer file, not a directory) it sailed past the working-tree root, found the enclosing checkout's .git/info/exclude, and applied its patterns rooted at the enclosing checkout. A pattern like '.claude/worktrees/' in a main checkout's exclude file (how several agent tools register their worktrees) then matched every file inside the worktree, and pyrefly skipped all of the project's includes with 'No Python files matched'. git's own semantics: a directory carrying a .git entry (file or directory) is a working-tree root; an outer repository's ignore rules never apply inside it, and the repository's shared info/exclude applies to each worktree relative to that worktree's own root. The search now walks upward collecting the nearest .gitignore and .ignore, stops at the first directory with a .git entry, and resolves info/exclude through the gitdir pointer and commondir for linked worktrees -- rooted at the working tree being checked.
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D115778027. (Because this pull request was imported automatically, there will not be any future comments.) |
meta-codesync Bot
pushed a commit
that referenced
this pull request
Aug 14, 2026
Summary: Fixes #4526. One of the two PRs replacing #4402, split per review feedback — the other is #4527 (`crates/pyrefly_util/src/globs.rs`). The two touch disjoint files and can land in either order. **Problem.** Follow-up to #2402. The `HiddenDirFilter::RelativeTo` allowance carried only `import_root`, so for a src-layout project (`import_root = <project>/src`) an include outside it — `tests/check.py` — prefix-matched no root and fell back to absolute-path component checking, where a checkout under a hidden directory (`~/.codex/worktrees/…`, `.claude/worktrees/…`) has every ancestor chain hidden and the include was silently dropped. The root list was also derived from `use_ignore_files`, so `--use-ignore-files=false` degraded the filter to `HiddenDirFilter::All` and hid the project entirely. **Approach.** Build the allowance from every include root plus the import root, independent of `use_ignore_files`. **Why it works.** `has_hidden_component` checks components relative to the most specific matching root, so listing every root the project actually declares means each of the project's files is judged relative to a root it lives under — hidden ancestors above the project stop mattering, while hidden directories *inside* it (`src/.venv/…`) are still excluded. And the allowance describes where the project lives, which has nothing to do with whether ignore files are consulted, so disabling one mechanism no longer hardens the other. **Tests.** New `test_hidden_dir_filter_is_relative_to_every_include_root` covers a src-layout project under `.claude/worktrees/…` with a `tests/` include, in both `use_ignore_files` states, and asserts `src/.venv/…` is still excluded; it fails on `main` (`tests/check.py` not covered) and passes with the fix. The existing `test_get_filtered_globs_coverage_scope` expectation is updated to the new `RelativeTo` construction. `cargo test -p pyrefly_config` passes. Pull Request resolved: #4528 Reviewed By: rchen152 Differential Revision: D115778066 fbshipit-source-id: 27fc2242b3b99508c4b006b67779547eead068d6
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.
No description provided.