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>
impl<'repo> UncommittedDiff<'repo>
Sourcepub fn new(repo: &'repo Repository, index: Index) -> Self
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).
Sourcepub fn staged_entries(&self, renames: RenameDetection) -> Result<Vec<DiffEntry>>
pub fn staged_entries(&self, renames: RenameDetection) -> Result<Vec<DiffEntry>>
Sourcepub fn unstaged_entries(
&mut self,
renames: RenameDetection,
) -> Result<Vec<DiffEntry>>
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.
Sourcepub fn worktree_entries(
&mut self,
base_tree: Option<&ObjectId>,
renames: RenameDetection,
) -> Result<Vec<DiffEntry>>
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;Nonefor the empty tree (an unbornHEAD).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.
Sourcepub fn load_worktree_changes(
&mut self,
entries: Vec<DiffEntry>,
) -> Result<Vec<FileChange>>
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.