Skip to content

Fix parent ignore matching for multiple explicit roots#3321

Open
markusylisiurunen wants to merge 1 commit intoBurntSushi:masterfrom
markusylisiurunen:fix-3320-parent-ignore-multiple-roots
Open

Fix parent ignore matching for multiple explicit roots#3321
markusylisiurunen wants to merge 1 commit intoBurntSushi:masterfrom
markusylisiurunen:fix-3320-parent-ignore-multiple-roots

Conversation

@markusylisiurunen
Copy link
Copy Markdown

Fixes #3320.

This fixes an order-dependent bug in parent ignore matching when ripgrep is given multiple explicit search roots.

The root cause was in Ignore::add_parents. Absolute-parent matchers were cached only by ancestor directory path, but they also carried root-specific state in absolute_base. When a later explicit root reused a cached matcher built for an earlier root, parent ignore rules could be evaluated relative to the wrong root, which made .rgignore / parent ignore behavior depend on the order of the explicit roots.

The fix keeps the existing per-directory cache, but stops reusing the cached matcher node directly across roots. Instead, on a cache hit, it rebinds the current parent chain and absolute_base while reusing the compiled matcher data. The cache entry is then refreshed to keep reuse working across successive roots.

Tests added:

  • a low-level regression in crates/ignore/src/dir.rs covering reuse across multiple explicit roots
  • a traversal regression in crates/ignore/src/walk.rs covering both root orders

Validation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order-dependent .rgignore bug with multiple explicit search roots

1 participant