From 373885f37f687629362c152f81db850eff8fcb91 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 6 May 2016 15:17:40 -0700 Subject: [PATCH] Add binding for git_repository_set_index --- libgit2-sys/lib.rs | 2 ++ src/repo.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 1ade9be838..72b3e05125 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -1419,6 +1419,8 @@ extern { pub fn git_repository_workdir(repo: *mut git_repository) -> *const c_char; pub fn git_repository_index(out: *mut *mut git_index, repo: *mut git_repository) -> c_int; + pub fn git_repository_set_index(repo: *mut git_repository, + index: *mut git_index) -> c_int; pub fn git_repository_config(out: *mut *mut git_config, repo: *mut git_repository) -> c_int; pub fn git_repository_config_snapshot(out: *mut *mut git_config, diff --git a/src/repo.rs b/src/repo.rs index d2901ed69d..d75240e3ee 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -675,6 +675,14 @@ impl Repository { } } + /// Set the Index file for this repository. + pub fn set_index(&self, index: &mut Index) -> Result<(), Error> { + unsafe { + try_call!(raw::git_repository_set_index(self.raw(), index.raw())); + } + Ok(()) + } + /// Get the configuration file for this repository. /// /// If a configuration file has not been set, the default config set for the