Skip to content

Commit

Permalink
Merge pull request rust-lang#139 from joshtriplett/diff_index_to_index
Browse files Browse the repository at this point in the history
Add binding for git_diff_index_to_index
  • Loading branch information
alexcrichton committed May 8, 2016
2 parents 4280007 + 0cc7d1a commit a13c35b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,11 @@ extern {
idx: size_t) -> *const git_diff_delta;
pub fn git_diff_get_stats(out: *mut *mut git_diff_stats,
diff: *mut git_diff) -> c_int;
pub fn git_diff_index_to_index(diff: *mut *mut git_diff,
repo: *mut git_repository,
old_index: *mut git_index,
new_index: *mut git_index,
opts: *const git_diff_options) -> c_int;
pub fn git_diff_index_to_workdir(diff: *mut *mut git_diff,
repo: *mut git_repository,
index: *mut git_index,
Expand Down
20 changes: 20 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,26 @@ impl Repository {
}
}

/// Create a diff between two index objects.
///
/// The first index will be used for the "old_file" side of the delta, and
/// the second index will be used for the "new_file" side of the delta.
pub fn diff_index_to_index(&self,
old_index: &Index,
new_index: &Index,
opts: Option<&mut DiffOptions>)
-> Result<Diff, Error> {
let mut ret = 0 as *mut raw::git_diff;
unsafe {
try_call!(raw::git_diff_index_to_index(&mut ret,
self.raw(),
old_index.raw(),
new_index.raw(),
opts.map(|s| s.raw())));
Ok(Binding::from_raw(ret))
}
}

/// Create a diff between the repository index and the workdir directory.
///
/// This matches the `git diff` command. See the note below on
Expand Down

0 comments on commit a13c35b

Please sign in to comment.