gix_diff

Function index

Source
pub fn index<'rhs, 'lhs: 'rhs, E, Find>(
    lhs: &'lhs State,
    rhs: &'rhs State,
    cb: impl FnMut(ChangeRef<'lhs, 'rhs>) -> Result<Action, E>,
    rewrite_options: Option<RewriteOptions<'_, Find>>,
    pathspec: &mut Search,
    pathspec_attributes: &mut dyn FnMut(&BStr, Case, bool, &mut Outcome) -> bool,
) -> Result<Option<Outcome>, Error>
where E: Into<Box<dyn Error + Send + Sync>>, Find: FindObjectOrHeader,
Available on crate feature index only.
Expand description

Produce an entry-by-entry diff between lhs and rhs, sending changes to cb(change) -> Action for consumption, which would turn lhs into rhs if applied. Use pathspec to reduce the set of entries to look at, and pathspec_attributes may be used by pathspecs that perform attribute lookups.

If cb indicated that the operation should be cancelled, no error is triggered as this isn’t supposed to occur through user-interaction - this diff is typically too fast.

Note that rewrites will be emitted at the end, so no ordering can be assumed. They will only be tracked if rewrite_options is Some. Note that the set of entries participating in rename tracking is affected by pathspec.

Return the outcome of the rewrite tracker if it was enabled.

Note that only rhs may contain unmerged entries, as rhs is expected to be the index read from .git/index. Unmerged entries are skipped entirely.

Conceptually, rhs is ours, and lhs is theirs. The entries in lhs and rhs are both expected to be sorted like index entries are typically sorted.

Note that sparse indices aren’t supported, they must be “unsparsed” before.