Skip to content

Fix inherited gitignore patterns in nested directories - #495

Open
dajiaohuang wants to merge 1 commit into
dalance:masterfrom
dajiaohuang:fix/inherit-parent-gitignore-20261016
Open

dajiaohuang wants to merge 1 commit into
dalance:masterfrom
dajiaohuang:fix/inherit-parent-gitignore-20261016

Conversation

@dajiaohuang

Copy link
Copy Markdown

Summary

Preserve ancestor .gitignore rules when entering a directory with its own .gitignore. Check the ignore stack from the closest directory outward, stopping at the first matching rule so that a child's explicit whitelist still takes precedence.

Reproduction

With *.log in the root .gitignore and *.tmp in nested/.gitignore, ambs needle . currently searches nested/ignored.log. Likewise, ambr --no-interactive needle replacement . rewrites it, despite the inherited ignore pattern. Merely adding an unrelated nested .gitignore should not stop the root pattern from applying.

Validation

  • Added CLI regression tests for both search and replacement, including child whitelist precedence and unchanged ignored-file contents. Both fail on the unchanged base and pass with this change.
  • All 9 existing library tests and the 2 new integration tests pass on Windows x86-64 and Linux x86-64 (test executables run from isolated fixture directories).
  • Additional isolated CLI checks cover literal/regex search and replacement, captures, file-based keywords/replacements, Unicode, binary/VCS filtering, large-file search, timestamp preservation, and Linux config overrides; interactive yes/no/all replacement also checked on Linux.
  • cargo fmt --all -- --check and git diff --check pass.

No macOS or ARM64 validation was run.

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.

1 participant