pub struct GitStatusCache { /* private fields */ }Expand description
Git status cache for efficient lookups.
Implementations§
Source§impl GitStatusCache
impl GitStatusCache
Sourcepub fn initialize(&mut self, start_path: &Path) -> bool
pub fn initialize(&mut self, start_path: &Path) -> bool
Initialize the cache by discovering and scanning the git repository.
start_path is the directory we are scanning (the subtree root). The
git status query is restricted to that subtree via a pathspec so that
only relevant entries are loaded, keeping memory usage proportional to
the scanned directory rather than the whole repository.
Returns true if a worktree was found, even if querying its status failed.
Inspect initialization_error for failures.
Sourcepub fn get_status(&self, path: &Path) -> Option<GitStatus>
pub fn get_status(&self, path: &Path) -> Option<GitStatus>
Get the git status for a path.
Falls back to canonicalizing the path so callers can pass a
non-canonical form (a /var path on macOS, say, where the repository
workdir resolves to /private/var). That fallback costs a syscall, so
bulk callers should use get_status_canonical.
Sourcepub fn get_status_canonical(&self, path: &Path) -> Option<GitStatus>
pub fn get_status_canonical(&self, path: &Path) -> Option<GitStatus>
Look up a path that is already known to be canonical.
Unlike get_status this never touches the
filesystem, which matters when annotating a whole tree: clean files miss
the map, and the canonicalizing fallback would then cost one syscall per
node across the entire scan.
Sourcepub fn is_in_repo(&self, path: &Path) -> bool
pub fn is_in_repo(&self, path: &Path) -> bool
Check if the path is within a git repository.
Sourcepub fn initialization_error(&self) -> Option<&str>
pub fn initialization_error(&self) -> Option<&str>
Failure from the last initialization; absence of a repository is not an error.
Trait Implementations§
Source§impl Debug for GitStatusCache
impl Debug for GitStatusCache
Auto Trait Implementations§
impl Freeze for GitStatusCache
impl RefUnwindSafe for GitStatusCache
impl Send for GitStatusCache
impl Sync for GitStatusCache
impl Unpin for GitStatusCache
impl UnsafeUnpin for GitStatusCache
impl UnwindSafe for GitStatusCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more