#[non_exhaustive]pub struct GitContext {
pub repo_kind: RepoKind,
pub repo_path: PathBuf,
pub head: Head,
/* private fields */
}Expand description
Git state shared across all git_* segments for the duration of
one render invocation. Populated once by
resolve_repo and held behind an
Arc in DataContext.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.repo_kind: RepoKindWhich repo flavor was discovered.
repo_path: PathBufAbsolute path to the repository directory (the .git dir for
main, the .git/worktrees/<name>/ dir for linked worktrees,
the repo path itself for bare).
head: HeadResolved HEAD.
Implementations§
Source§impl GitContext
impl GitContext
Sourcepub fn new(repo_kind: RepoKind, repo_path: PathBuf, head: Head) -> Self
pub fn new(repo_kind: RepoKind, repo_path: PathBuf, head: Head) -> Self
Construct a GitContext from pre-resolved fields without
opening a repo. Lazy dirty / upstream accessors then
return their defaults (empty dirty state, no upstream)
because no gix::Repository is held. Pair with
DataContext::preseed_git.
Sourcepub fn dirty(&self) -> Arc<DirtyState>
pub fn dirty(&self) -> Arc<DirtyState>
Dirty state, scanned lazily on first access. Returns
DirtyState::Clean when no repo handle is held.
The scan covers untracked files and tracked modifications. HEAD↔index (staged-only) changes are not detected because gix 0.67 doesn’t expose that comparison.
Sourcepub fn preseed_upstream(
&self,
value: Option<UpstreamState>,
) -> Result<(), Arc<Option<UpstreamState>>>
pub fn preseed_upstream( &self, value: Option<UpstreamState>, ) -> Result<(), Arc<Option<UpstreamState>>>
Pre-populate the upstream OnceCell with an explicit value,
bypassing the real walker. Returns Err via
OnceCell::set’s semantics when the cell was already
populated.
Sourcepub fn preseed_dirty_state(
&self,
value: DirtyState,
) -> Result<(), Arc<DirtyState>>
pub fn preseed_dirty_state( &self, value: DirtyState, ) -> Result<(), Arc<DirtyState>>
Pre-populate the dirty OnceCell with an explicit value,
bypassing the real scan. Same OnceCell::set semantics as
Self::preseed_upstream.
Sourcepub fn upstream(&self) -> Arc<Option<UpstreamState>>
pub fn upstream(&self) -> Arc<Option<UpstreamState>>
Upstream-tracking state, scanned lazily on first access.
Returns Arc<None> in five distinct cases:
- HEAD is detached / unborn / an
OtherRef. - The branch has no tracking upstream configured.
- The configured tracking ref has no local object (never fetched, or remote pruned).
- The repo is shallow — ancestor walks truncate at the shallow frontier and would silently undercount.
- HEAD and upstream share no merge base (unrelated histories)
OR
gixfailed partway through (corrupt index, cache open failure, …). In the failure case the cause is written to stderr with thelinesmith:prefix on the first read.
Cases 1-4 render identically to ahead/behind segments (no upstream). Case 5 deliberately fuses “walker failed” into “no upstream” — distinguishing them in the plugin mirror requires a structured variant (follow-up).