pub struct IndexStatProbe { /* private fields */ }Expand description
Stage-0 index stat data that can prove a worktree path clean without re-reading and re-hashing it.
This is the public carrier for sley’s racy-git shortcut. Callers that already
parsed .git/index can build a probe from the matching IndexEntry and
the index file’s mtime, then pass it to worktree_entry_state or
worktree_entry_state_by_git_path. The probe is trusted only when its path,
mode, and object id match the expected entry and the cached stat is not
racily clean; otherwise the helper falls back to the same content hashing
path used by stream_short_status_with_options.
Implementations§
Source§impl IndexStatProbe
impl IndexStatProbe
Sourcepub fn from_index_entry(
entry: IndexEntry,
index_mtime: Option<(u64, u64)>,
) -> Self
pub fn from_index_entry( entry: IndexEntry, index_mtime: Option<(u64, u64)>, ) -> Self
Build a probe from a parsed stage-0 index entry and the index file’s mtime
split as (seconds, nanoseconds).
Sourcepub fn from_index_entry_and_index_path(
entry: IndexEntry,
index_path: impl AsRef<Path>,
) -> Self
pub fn from_index_entry_and_index_path( entry: IndexEntry, index_path: impl AsRef<Path>, ) -> Self
Build a probe from a parsed index entry and the path of the index file on disk, using that file’s mtime as the racy-clean reference timestamp.
Sourcepub fn from_repository_index(
git_dir: impl AsRef<Path>,
format: ObjectFormat,
git_path: &[u8],
) -> Result<Option<Self>>
pub fn from_repository_index( git_dir: impl AsRef<Path>, format: ObjectFormat, git_path: &[u8], ) -> Result<Option<Self>>
Read this repository’s index and return a probe for git_path when a
stage-0 entry exists.
For repeated lookups prefer IndexStatProbeCache::from_repository_index
and IndexStatProbeCache::probe_for_git_path. This one-shot helper
keeps a small process-local cache for back-to-back calls against an
unchanged index, but the explicit cache makes ownership and invalidation
clearer for high-volume embedders.
Sourcepub fn entry(&self) -> &IndexEntry
pub fn entry(&self) -> &IndexEntry
The parsed index entry this probe was built from.
Sourcepub fn index_mtime(&self) -> Option<(u64, u64)>
pub fn index_mtime(&self) -> Option<(u64, u64)>
The index file mtime used as the racy-clean reference timestamp.
Trait Implementations§
Source§impl Clone for IndexStatProbe
impl Clone for IndexStatProbe
Source§fn clone(&self) -> IndexStatProbe
fn clone(&self) -> IndexStatProbe
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IndexStatProbe
impl Debug for IndexStatProbe
impl Eq for IndexStatProbe
Source§impl PartialEq for IndexStatProbe
impl PartialEq for IndexStatProbe
Source§fn eq(&self, other: &IndexStatProbe) -> bool
fn eq(&self, other: &IndexStatProbe) -> bool
self and other values to be equal, and is used by ==.