Skip to content

feat: .codesearchinclude whitelist — index only matching files when present - #346

Merged
flupkede merged 4 commits into
developfrom
features/codesearchinclude
Oct 17, 2026
Merged

flupkede merged 4 commits into
developfrom
features/codesearchinclude

Conversation

@flupkede

Copy link
Copy Markdown
Owner

Next to the ignore machinery there was no way to say "index ONLY these". A .codesearchinclude at the repo root (plus a global ~/.codesearch/.codesearchinclude, lowest precedence) now acts as a whitelist: when it exists, a file is indexed only when the file itself or an ancestor matches its gitignore-style rules (src/ covers src/a/b.rs), and a !-rule un-includes again (last match along the component chain wins, mirroring gitignore order).

Semantics: ignore rules still win first — an include can never resurrect an ignored file — and an absent or empty list keeps the historical behavior. Both gates share the implementation shape: the walker (gate after the ignore machinery, before the binary probe, counted in the previously-reserved skipped_ignored stat) and the watcher's is_watchable, so incremental reindex follows the same whitelist.

Pinned by 4 tests: walker whitelist+ancestor, negation, absent-list no-op, watcher gate. Validation: fmt clean, clippy --all-targets -D warnings clean, cargo test --lib --bins green (includes the PR #308 merge).

…resent

Next to the ignore machinery there was no way to say 'index ONLY
these'. A .codesearchinclude at the repo root (plus a global
~/.codesearch/.codesearchinclude, lowest precedence) now acts as a
whitelist: when it exists, a file is indexed only when the file itself
or an ancestor matches an include rule (src/ covers src/a/b.rs), and a
!-rule inside the file un-includes again (last match along the
component chain wins, mirroring gitignore order). Ignore rules still
win first — an include can never resurrect an ignored file. Absent or
empty list = historical behavior (index everything the ignore rules
allow).

Both gates share the semantics: the walker (before the binary probe,
counted in the previously-reserved skipped_ignored stat) and the
watcher's is_watchable (incremental reindex follows the same whitelist).
Pinned by 4 tests: walker whitelist+ancestor, negation, absent-list
no-op, watcher gate.
Stage 2: CHANGELOG entry under the pending version (### Added), one
highlights line, plan ticked. Full validation green (fmt, clippy
--all-targets -D warnings, cargo test --lib --bins).

Review deviation: the reviewer subagent aborted twice (quota) — stage 1
was self-reviewed read-only instead; all invariants checked against the
diff (absent-list no-op, Match<&Glob> handling, ancestor walk, gate
placement, ignore-wins-first, negation, global-to-local order).
@flupkede
flupkede merged commit fba9c29 into develop Oct 17, 2026
4 of 6 checks passed
@flupkede
flupkede deleted the features/codesearchinclude branch October 17, 2026 14:13
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