Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindings for git_index_version() and git_index_set_version() #597

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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