fix(linter): skip looking for ignore files in parent directories#17813
fix(linter): skip looking for ignore files in parent directories#17813camc314 wants to merge 1 commit into
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@camc314, is there anything I can do to help this get merged? |
|
this issue become more prominent when many devs are using ai agents + git worktrees. |
|
i ran into this issue today, and took quite a long time to pinpoint. please get this merged. i have nested git repos, even without using worktrees. i have put my home dir under git management and have |
|
TLDR: i'd NOT merge this PR, and rather enable i researched it again, and The proper fix would be to set Full example: |
… .gitignore Switches `require_git(false)` to `require_git(true)` in both the oxlint and oxfmt walkers, and reverts the `parents(false)` workaround added in oxc-project#17813 (oxlint only). **Background:** `require_git(false)` was introduced in oxc-project#17375 so that `.gitignore` rules would apply even in directories without a `.git` file. A side-effect is that the `ignore` crate reads `.gitignore` files from directories *above* the git root, which is non-standard git behaviour. This caused a concrete bug: when linting inside a nested git repo (`parent_repo/child_repo/`), the parent repo's `.gitignore` incorrectly filtered files in the child repo. **Why require_git(true) is the right fix:** The `ignore` crate's `matched_ignore` already implements the correct git-boundary logic via a `saw_git` flag. When iterating parent directories from innermost to outermost, `saw_git` is set to `true` the moment the innermost `.git` directory is encountered, preventing gitignore rules from any outer repository from being applied. Setting `require_git(true)` activates this standard behaviour. **Why parents(false) can be reverted (oxlint):** `parents(false)` was a workaround for the nested-repo bug. With `require_git(true)` the `saw_git` mechanism handles this correctly, so `parents(true)` can be restored. This also fixes the regression where running `oxlint src/` would fail to pick up `.gitignore` rules from the repo root sitting above `src/`. **Trade-off:** `.gitignore` rules no longer apply in directories that have no `.git` ancestor. This reverts the behaviour added in oxc-project#17375.
This regressed in oxlint v1.36.0 (fec2863) This is caused by the walker configuring `ignore` with `.require_git(false)`, which makes `.gitignore` files from parent directories above the current repository apply to the walk. That differs from Git behavior, where `.gitignore` lookup stops at the working tree root. Here is how we handle it: - detect whether all walk roots are inside a Git/JJ repository boundary - enable `require_git(true)` for repository walks so parent `.gitignore` files above the repo boundary are ignored - keep `require_git(false)` for non-repository walks so local `.gitignore` files still work outside Git repos - add regression coverage for nested repositories, worktree-style `.git` files, and subdirectory walks inside a repo Here is how the `ignore` crate checks for git directories: - when `require_git(true)` is enabled, it records whether each directory has a `.git` or `.jj` entry - while matching `.gitignore` rules, it applies parent gitignore matchers only until it has seen that repository boundary - `.git` files are handled as boundaries too, which covers Git worktrees Fixes #17510. Fixes #17805. Fixes #19902. Closes #21727. Closes #17513. Closes #17813. Closes #20951. Closes #20952.
|
Fixed by #22033 The fix should be released on Monday (May 4th) (or possibly tuesday due to the holiday). |

fixes #17805
closes #17513
fixes #17510