Repository navigation
fix: watcher honours walker ignore rules in ripgrep builds (#915) - #916
gustav-fff wants to merge 1 commit into
Conversation
Ripgrep builds returned no walker ignore rules, so the watcher fell back to libgit2 is_path_ignored, which knows nothing about .ignore files (local or in parent dirs). Live updates drifted from what a rescan produces: creates/edits under a .ignore re-included dir were dropped, and files under a .ignore excluded dir got indexed. The ripgrep walker now hands its WalkBuilder to WalkIgnoreRules, which lazily builds ignore::IncrementalIgnore from it on first watcher query. Same config, same precedence as the walk. Requires ignore >= 0.4.33. Closes #915
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Closes #915
Root cause
Ripgrep walker returns
ignore_rules: None(crates/fff-core/src/walk/ripgrep.rs:85, ripgrepWalkIgnoreRuleswas uninhabited inwalk/mod.rs:31). SoIgnoreFilter::is_ignored(crates/fff-core/src/watcher/background_watcher.rs:957) falls back to libgit2is_path_ignored, which does not read.ignorefiles (local or parent dirs). Watcher and walker classify paths differently. zlob builds unaffected.Fix
Ripgrep walker moves its
WalkBuilderintoWalkIgnoreRules. On first watcher query it buildsignore::IncrementalIgnore(WalkBuilder::build_matchers), ripgrep's own single-path matcher with walk-identical precedence.IgnoreFilter::is_ignorednow takesis_dirso dir-only patterns match; zlob path ignores it, behaviour unchanged.@dmtrKovalenko two things to look at:
ignorebumped0.4.22->0.4.33(first withbuild_matchers). Lock:ignore0.4.25->0.4.33,regex-automata0.4.14->0.4.18.non_git_repo_overrides,.ignore) instead of theis_non_code_directorysubstring heuristic. Same as walker, but it is a behaviour change.Matcher is behind a
parking_lot::Mutex(matchedneeds&mutfor its per-dir cache). Held for onematchedcall, never nested with the picker lock.Steps to reproduce
On
origin/main(d978416), default features (ripgrep). Append the two tests from #915 (dot_ignore_negation_keeps_gitignored_dir_live,dot_ignore_exclusion_is_kept_by_watcher, now incrates/fff-core/src/watcher/rescan_tests.rson this branch) to the same file on main, then:cargo test -p fff-search --lib dot_ignoreExpected: 2 passed. Actual on main:
Real watcher (macOS FSEvents) setup:
.gitignore=projects/,.ignore=!projects/\nscratch/,projects/a/.gitignore=target/,watch: true. After scan, createprojects/a/src/added.rs, append toprojects/a/src/main.rs, createroot_added.rs. Grep after 5s on main:Expected: all 1, while
projects/a/target/new.oandscratch/new.txtstay out.How verified
cargo test -p fff-search --lib: 218 passed (ripgrep), incl. 2 new tests.surfaces_reusable_ignore_rulesnow runs on both backends.make test-rust(zlob, CI config): all passed.cargo test --workspace --exclude fff-nvim --exclude fff-python(ripgrep): all passed.cargo clippy --workspace --no-default-features --features zlob -- -D warningsandcargo clippy -p fff-search -p fff-c -- -D warnings: clean.target/andscratch/stay out.is_path_ignored3.06s;IncrementalIgnorecold 260ms, warm 5.4ms. Initial scan pays nothing (matcher built lazily);index_new_directorywalks do not build it at all.node_modules/from a parent-dir.ignoreabove the Chromium root. The walker skips them, libgit2 said not ignored, the new matcher agrees with the walker.Automated triage via Gustav. Honk-Honk 🪿
Summary by CodeRabbit
.ignorenegation rules are better respected, helping prevent excluded files from being indexed while allowing explicitly unignored directories to remain active.