pub struct Ignores { /* private fields */ }Expand description
Compiled exclusion for one root. Per-directory matchers are built on
first use and memoized, so the initial scan reads each .gitignore
once and incremental reconciliation reads none.
Implementations§
Source§impl Ignores
impl Ignores
Sourcepub fn new(root: &Path, spec: &IgnoreSpec) -> Ignores
pub fn new(root: &Path, spec: &IgnoreSpec) -> Ignores
Compile spec for root. Unparseable client patterns are dropped
individually: a sync is never refused for one bad glob, and the
server validates the list before it gets here.
Sourcepub fn external_watch_dirs(&self) -> Vec<PathBuf>
pub fn external_watch_dirs(&self) -> Vec<PathBuf>
Directories outside the root that hold ignore sources this matcher
consulted, so the reconciler can watch them. Their parents are
what gets armed — a watch on a file follows its inode and misses
the rename-over an editor or git config performs, the same reason
a single-file sync watches the parent directory.
Sourcepub fn is_external_source(&self, abs: &Path) -> bool
pub fn is_external_source(&self, abs: &Path) -> bool
True when abs is one of the ignore sources above the root. Their
hints arrive from outside the tree, so nothing else recognizes them.
Sourcepub fn source_affects_rules(&mut self, abs: &Path, rel: &str) -> bool
pub fn source_affects_rules(&mut self, abs: &Path, rel: &str) -> bool
Whether a write to this ignore source can change what the matcher excludes — the question the reconciler actually has, since the answer costs it a full re-enumeration.
An ignore file inside an already-excluded directory cannot: it is
never read, because the directory is never descended. That
distinction is not academic — npm install writes thousands of
.gitignore files under node_modules, and rescanning the root
for each one would make the exclusion cost more than it saves.
abs is the absolute path and rel its wire path under the root.
Sourcepub fn is_source_abs(&self, abs: &Path) -> bool
pub fn is_source_abs(&self, abs: &Path) -> bool
True when an absolute path is an ignore source at all — before
asking whether it is a relevant one
(Ignores::source_affects_rules).
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Recompile from disk. Called when an ignore source changed; the reconciler pairs it with a full rescan, since entries the old rules admitted may now be excluded and vice versa.
A full rebuild rather than a cache drop: the sources read once at
construction — the ancestors’ files, info/exclude,
core.excludesFile, core.ignorecase — are exactly the ones no
per-directory cache holds, so clearing only the caches would keep
serving an edited parent .gitignore from the copy compiled at
open.
Sourcepub fn matched(&mut self, rel: &str, is_dir: bool) -> bool
pub fn matched(&mut self, rel: &str, is_dir: bool) -> bool
Whether the entry at wire path rel is excluded. is_dir means
the entry is enumerated as a directory — a symlink to one counts,
unlike in git, because this sync descends it: a build/ pattern
that could not exclude a symlinked build would leave the one hole
through which a whole subtree still gets mirrored.
The root itself is never excluded — a sync of an ignored directory mirrors it, which is what the client asked for.