Skip to main content

UncommittedDiff

Struct UncommittedDiff 

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

Staged, unstaged, and working-tree diffs over one loaded index.

Every method reuses the same Index and, once a working-tree method needs them, the same WorktreeRules, so collecting entries and then loading their contents reads neither twice. Working-tree scans may refresh stat data on the in-memory index; nothing is written to disk.

Obtain one from Diff::uncommitted or UncommittedDiff::new.

Implementations§

Source§

impl<'repo> UncommittedDiff<'repo>

Source

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

Diff repo against an index the caller already loaded.

§Parameters
  • repo - repository to diff.
  • index - its index (normally the on-disk index).
Source

pub fn index(&self) -> &Index

The index every comparison uses.

Source

pub fn staged_entries(&self, renames: RenameDetection) -> Result<Vec<DiffEntry>>

Index against HEAD’s tree (grit diff --staged), sorted by path.

An unborn HEAD compares against the empty tree, so every index entry is added.

§Parameters
  • renames - rename detection between deleted and added paths.
§Errors

Returns HEAD resolution, config, and object read errors.

Source

pub fn unstaged_entries( &mut self, renames: RenameDetection, ) -> Result<Vec<DiffEntry>>

Working tree against the index (grit diff --unstaged), sorted by path.

§Parameters
  • renames - rename detection between deleted and added paths.
§Errors

Returns Error::RequiresWorkTree in a bare repository, plus worktree rule, I/O, and object read errors.

Source

pub fn worktree_entries( &mut self, base_tree: Option<&ObjectId>, renames: RenameDetection, ) -> Result<Vec<DiffEntry>>

Working tree and index together against base_tree (grit diff, grit diff --against), sorted by path.

§Parameters
  • base_tree - tree to compare with; None for the empty tree (an unborn HEAD).
  • renames - rename detection between deleted and added paths.
§Errors

Returns Error::RequiresWorkTree in a bare repository, plus worktree rule, I/O, and object read errors.

Source

pub fn load_worktree_changes( &mut self, entries: Vec<DiffEntry>, ) -> Result<Vec<FileChange>>

Load entries from Self::unstaged_entries or Self::worktree_entries: old sides from the object database, new sides from the working tree (with gitlinks showing the submodule’s checked-out commit and -dirty state).

§Errors

Returns Error::RequiresWorkTree in a bare repository, plus I/O, filter, and object read errors.

Auto Trait Implementations§

§

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

§

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

§

impl<'repo> Freeze for UncommittedDiff<'repo>

§

impl<'repo> Send for UncommittedDiff<'repo>

§

impl<'repo> Sync for UncommittedDiff<'repo>

§

impl<'repo> Unpin for UncommittedDiff<'repo>

§

impl<'repo> UnsafeUnpin for UncommittedDiff<'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> 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, 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.