[][src]Struct git2::Diff

pub struct Diff<'repo> { /* fields omitted */ }

The diff object that contains all individual file deltas.

This is an opaque structure which will be allocated by one of the diff generator functions on the Repository structure (e.g. diff_tree_to_tree or other diff_* functions).

Methods

impl<'repo> Diff<'repo>[src]

pub fn merge(&mut self, from: &Diff<'repo>) -> Result<(), Error>[src]

Merge one diff into another.

This merges items from the "from" list into the "self" list. The resulting diff will have all items that appear in either list. If an item appears in both lists, then it will be "merged" to appear as if the old version was from the "onto" list and the new version is from the "from" list (with the exception that if the item has a pending DELETE in the middle, then it will show as deleted).

Important traits for Deltas<'diff>
pub fn deltas(&self) -> Deltas[src]

Returns an iterator over the deltas in this diff.

pub fn get_delta(&self, i: usize) -> Option<DiffDelta>[src]

Return the diff delta for an entry in the diff list.

pub fn is_sorted_icase(&self) -> bool[src]

Check if deltas are sorted case sensitively or insensitively.

pub fn print<F>(&self, format: DiffFormat, cb: F) -> Result<(), Error> where
    F: FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool
[src]

Iterate over a diff generating formatted text output.

Returning false from the callback will terminate the iteration and return an error from this function.

pub fn foreach(
    &self,
    file_cb: &mut (dyn FnMut(DiffDelta, f32) -> bool + 'a),
    binary_cb: Option<&mut (dyn FnMut(DiffDelta, DiffBinary) -> bool + 'a)>,
    hunk_cb: Option<&mut (dyn FnMut(DiffDelta, DiffHunk) -> bool + 'a)>,
    line_cb: Option<&mut (dyn FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a)>
) -> Result<(), Error>
[src]

Loop over all deltas in a diff issuing callbacks.

Returning false from any callback will terminate the iteration and return an error from this function.

pub fn stats(&self) -> Result<DiffStats, Error>[src]

Accumulate diff statistics for all patches.

pub fn find_similar(
    &mut self,
    opts: Option<&mut DiffFindOptions>
) -> Result<(), Error>
[src]

Transform a diff marking file renames, copies, etc.

This modifies a diff in place, replacing old entries that look like renames or copies with new entries reflecting those changes. This also will, if requested, break modified files into add/remove pairs if the amount of change is above a threshold.

Trait Implementations

impl<'repo> Drop for Diff<'repo>[src]

impl<'repo> Send for Diff<'repo>[src]

Auto Trait Implementations

impl<'repo> RefUnwindSafe for Diff<'repo>

impl<'repo> !Sync for Diff<'repo>

impl<'repo> Unpin for Diff<'repo>

impl<'repo> UnwindSafe for Diff<'repo>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.