diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 5d0b173be3..744ab65a18 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 3dce08f097..7fad7619ba 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