Skip to main content

Status

Struct Status 

Source
pub struct Status<'repo> { /* private fields */ }
Expand description

Compute staged, unstaged, untracked, and ignored paths for one repository.

Implementations§

Source§

impl<'repo> Status<'repo>

Source

pub fn new(repo: &'repo Repository) -> Self

Bind status operations to repo.

Source

pub fn repository(&self) -> &'repo Repository

Underlying repository.

Source

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());
Source

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());
Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'repo> Clone for Status<'repo>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'repo> Copy for Status<'repo>

Source§

impl<'repo> Debug for Status<'repo>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'repo> !RefUnwindSafe for Status<'repo>

§

impl<'repo> !UnwindSafe for Status<'repo>

§

impl<'repo> Forget for Status<'repo>

§

impl<'repo> Freeze for Status<'repo>

§

impl<'repo> Send for Status<'repo>

§

impl<'repo> Sync for Status<'repo>

§

impl<'repo> Unpin for Status<'repo>

§

impl<'repo> UnsafeUnpin for Status<'repo>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.