pub struct Status<'repo> { /* private fields */ }Expand description
Compute staged, unstaged, untracked, and ignored paths for one repository.
Implementations§
Source§impl<'repo> Status<'repo>
impl<'repo> Status<'repo>
Sourcepub fn new(repo: &'repo Repository) -> Self
pub fn new(repo: &'repo Repository) -> Self
Bind status operations to repo.
Sourcepub fn repository(&self) -> &'repo Repository
pub fn repository(&self) -> &'repo Repository
Underlying repository.
Sourcepub fn run(
&self,
options: &StatusOptions,
progress: &mut dyn ProgressSink,
cancel: &CancelToken,
) -> Result<StatusModel>
pub fn run( &self, options: &StatusOptions, progress: &mut dyn ProgressSink, cancel: &CancelToken, ) -> Result<StatusModel>
Full status model from StatusOptions.
§Errors
Propagates repository, diff, index, and untracked-walk failures. Returns
crate::error::Error::Cancelled when cancel is set.
§Examples
use grit_lib::progress::{CancelToken, NullProgress};
use grit_lib::repo::{InitOptions, Repository};
use grit_lib::status::StatusOptions;
let dir = tempfile::tempdir()?;
let (repo, _) = Repository::init(dir.path(), &InitOptions::default())?;
let model = repo.status().run(
&StatusOptions::default(),
&mut NullProgress,
&CancelToken::never(),
)?;
assert!(model.staged.is_empty() && model.unstaged.is_empty());Sourcepub fn assemble_summary(
&self,
model: StatusModel,
options: StatusSummaryOptions,
) -> Result<StatusSummary>
pub fn assemble_summary( &self, model: StatusModel, options: StatusSummaryOptions, ) -> Result<StatusSummary>
Dashboard summary: branch standing, guidance, and conflict grouping for a StatusModel.
Call after Self::run when the CLI or an embedder needs header and integration hints
without rescanning the worktree.
§Errors
Propagates crate::branch_tracking::BranchStanding::compute failures.
§Examples
use grit_lib::progress::{CancelToken, NullProgress};
use grit_lib::repo::{InitOptions, Repository};
use grit_lib::status::{StatusOptions, StatusSummaryOptions};
let dir = tempfile::tempdir()?;
let (repo, _) = Repository::init(dir.path(), &InitOptions::default())?;
let status = repo.status();
let model = status.run(&StatusOptions::default(), &mut NullProgress, &CancelToken::never())?;
let summary = status.assemble_summary(model, StatusSummaryOptions::default())?;
assert!(summary.conflict_groups.is_empty());Sourcepub fn untracked(
&self,
index: &mut Index,
options: &UntrackedOptions,
progress: &mut dyn ProgressSink,
cancel: &CancelToken,
) -> Result<(Vec<String>, Vec<String>)>
pub fn untracked( &self, index: &mut Index, options: &UntrackedOptions, progress: &mut dyn ProgressSink, cancel: &CancelToken, ) -> Result<(Vec<String>, Vec<String>)>
Walk the work tree and collect untracked and ignored paths into sorted lists.
Honors UntrackedOptions (ignored mode, show_all, pathspec limit, UNTR cache policy).
§Errors
Propagates ignore-rule load, index, and walk failures. Returns
crate::error::Error::Cancelled when cancel is set.
Sourcepub fn untracked_with_meta(
&self,
index: &mut Index,
options: &UntrackedOptions,
rules: Option<&WorktreeRules>,
cancel: &CancelToken,
) -> Result<(Vec<String>, Vec<String>, UntrackedCollectMeta)>
pub fn untracked_with_meta( &self, index: &mut Index, options: &UntrackedOptions, rules: Option<&WorktreeRules>, cancel: &CancelToken, ) -> Result<(Vec<String>, Vec<String>, UntrackedCollectMeta)>
Like Self::untracked, also returning walk metadata (collapsed clean units, etc.).
When rules is Some, ignore and attribute files already loaded for this operation are
reused instead of reading them again.
§Errors
Same as Self::untracked.
Sourcepub fn expand_untracked_for_staging(
&self,
index: &mut Index,
untracked: Vec<String>,
pathspecs: &[String],
) -> Result<Vec<String>>
pub fn expand_untracked_for_staging( &self, index: &mut Index, untracked: Vec<String>, pathspecs: &[String], ) -> Result<Vec<String>>
Expand collapsed untracked directory markers (dir/) into concrete file paths for staging.
§Errors
Propagates ignore-rule and walk failures.
Sourcepub fn diff_entry_matches_pathspec(
&self,
entry: &DiffEntry,
pathspec: &Pathspec,
) -> Result<bool>
pub fn diff_entry_matches_pathspec( &self, entry: &DiffEntry, pathspec: &Pathspec, ) -> Result<bool>
Whether a diff entry matches pathspec using typed pathspec evaluation (rename-aware).
§Errors
Same as Pathspec::matches_change.