Skip to content

Commit

Permalink
Add bindings for git_index_version() and git_index_set_version() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pjw91 authored Jul 22, 2020
1 parent 892dc1a commit a9d86f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,8 @@ extern "C" {
) -> c_int;

// index
pub fn git_index_version(index: *mut git_index) -> c_uint;
pub fn git_index_set_version(index: *mut git_index, version: c_uint) -> c_int;
pub fn git_index_add(index: *mut git_index, entry: *const git_index_entry) -> c_int;
pub fn git_index_add_all(
index: *mut git_index,
Expand Down
21 changes: 21 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ impl Index {
}
}

/// Get index on-disk version.
///
/// Valid return values are 2, 3, or 4. If 3 is returned, an index
/// with version 2 may be written instead, if the extension data in
/// version 3 is not necessary.
pub fn version(&self) -> u32 {
unsafe { raw::git_index_version(self.raw) }
}

/// Set index on-disk version.
///
/// Valid values are 2, 3, or 4. If 2 is given, git_index_write may
/// write an index with version 3 instead, if necessary to accurately
/// represent the index.
pub fn set_version(&mut self, version: u32) -> Result<(), Error> {
unsafe {
try_call!(raw::git_index_set_version(self.raw, version));
}
Ok(())
}

/// Add or update an index entry from an in-memory struct
///
/// If a previous index entry exists that has the same path and stage as the
Expand Down

0 comments on commit a9d86f4

Please sign in to comment.