Skip to main content

Ignores

Struct Ignores 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.