pub struct Diff<'repo> { /* private fields */ }Expand description
Compare trees, the index, and the working tree for one repository.
Implementations§
Source§impl Diff<'_>
impl Diff<'_>
Sourcepub fn commit_files_many(
&self,
oids: &[ObjectId],
pathspecs: &[String],
opts: CommitFilesManyOptions,
config: &ConfigSet,
thread_policy: &ThreadPolicy,
) -> Result<Vec<CommitFilesResult>>
pub fn commit_files_many( &self, oids: &[ObjectId], pathspecs: &[String], opts: CommitFilesManyOptions, config: &ConfigSet, thread_policy: &ThreadPolicy, ) -> Result<Vec<CommitFilesResult>>
Build per-commit file diffs for a slice of commit oids, preserving input order.
Parent trees are resolved once and reused across consecutive commits (same as
super::write_commits_log_patch). When oids are newest-first and history is
linear, each commit’s first parent is the next oid and its tree is reused without
an extra read. Work runs in parallel when ThreadPolicy allows and the batch is
large enough to amortize pool startup.
§Errors
Propagates object read, tree diff, and parallel pool errors.
Sourcepub fn commit_files_many_work(
&self,
inputs: &[CommitFilesManyInput],
pathspecs: &[String],
opts: CommitFilesManyOptions,
config: &ConfigSet,
thread_policy: &ThreadPolicy,
) -> Result<Vec<CommitFilesResult>>
pub fn commit_files_many_work( &self, inputs: &[CommitFilesManyInput], pathspecs: &[String], opts: CommitFilesManyOptions, config: &ConfigSet, thread_policy: &ThreadPolicy, ) -> Result<Vec<CommitFilesResult>>
Like Self::commit_files_many when commit trees and parents are already loaded.
§Errors
Propagates object read, tree diff, and parallel pool errors.
Source§impl<'repo> Diff<'repo>
impl<'repo> Diff<'repo>
Sourcepub fn new(repo: &'repo Repository) -> Self
pub fn new(repo: &'repo Repository) -> Self
Bind diff helpers to repo.
Sourcepub fn repository(&self) -> &'repo Repository
pub fn repository(&self) -> &'repo Repository
Underlying repository.
Sourcepub fn tree_to_tree(
&self,
old_tree: Option<&ObjectId>,
new_tree: Option<&ObjectId>,
) -> Result<Vec<DiffEntry>>
pub fn tree_to_tree( &self, old_tree: Option<&ObjectId>, new_tree: Option<&ObjectId>, ) -> Result<Vec<DiffEntry>>
Sourcepub fn index_to_tree(
&self,
index: &Index,
tree_oid: Option<&ObjectId>,
ignore_submodules: bool,
) -> Result<Vec<DiffEntry>>
pub fn index_to_tree( &self, index: &Index, tree_oid: Option<&ObjectId>, ignore_submodules: bool, ) -> Result<Vec<DiffEntry>>
Diff the index against a tree (typically HEAD’s tree).
§Errors
Propagates ODB and index diff errors.
Sourcepub fn worktree_to_index(
&self,
index: &mut Index,
ignore_submodule_untracked: bool,
simplify_gitlinks: bool,
) -> Result<Vec<DiffEntry>>
pub fn worktree_to_index( &self, index: &mut Index, ignore_submodule_untracked: bool, simplify_gitlinks: bool, ) -> Result<Vec<DiffEntry>>
Diff the working tree against the index.
§Errors
Returns an error when the repository has no work tree or diff I/O fails.
Sourcepub fn files(
&self,
target: &DiffTarget,
pathspecs: &[String],
opts: &DiffOptions,
) -> Result<Vec<FileDiff>>
pub fn files( &self, target: &DiffTarget, pathspecs: &[String], opts: &DiffOptions, ) -> Result<Vec<FileDiff>>
Structured per-file diffs for target, honoring pathspecs and line-diff opts.
§Errors
Propagates index, ODB, and worktree diff failures.
Source§impl<'repo> Diff<'repo>
impl<'repo> Diff<'repo>
Sourcepub fn has_changes(
&self,
target: &DiffTarget,
pathspecs: &[String],
opts: DiffOptions,
) -> Result<bool>
pub fn has_changes( &self, target: &DiffTarget, pathspecs: &[String], opts: DiffOptions, ) -> Result<bool>
Whether the selected diff has any real changes, stopping at the first one.
Worktree targets honor the index stat cache and only hash blob content when needed.
When whitespace ignore flags are set on opts, content is compared under those rules;
a change that differs only in ignored whitespace returns false.
§Errors
Propagates repository, ODB, and diff errors.