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 binding for git_fetchhead_to_annotated_commit #524

Merged
merged 1 commit into from
Mar 2, 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
7 changes: 7 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,13 @@ extern "C" {
repo: *mut git_repository,
reference: *const git_reference,
) -> c_int;
pub fn git_annotated_commit_from_fetchhead(
out: *mut *mut git_annotated_commit,
repo: *mut git_repository,
branch_name: *const c_char,
remote_url: *const c_char,
oid: *const git_oid,
) -> c_int;
pub fn git_annotated_commit_free(commit: *mut git_annotated_commit);
pub fn git_merge_init_options(opts: *mut git_merge_options, version: c_uint) -> c_int;
pub fn git_merge(
Expand Down
23 changes: 23 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,29 @@ impl Repository {
}
}

/// Creates a git_annotated_commit from FETCH_HEAD.
pub fn annotated_commit_from_fetchhead(
&self,
branch_name: &str,
remote_url: &str,
id: &Oid,
) -> Result<AnnotatedCommit<'_>, Error> {
let branch_name = CString::new(branch_name)?;
let remote_url = CString::new(remote_url)?;

let mut ret = ptr::null_mut();
unsafe {
try_call!(raw::git_annotated_commit_from_fetchhead(
&mut ret,
self.raw(),
branch_name,
remote_url,
id.raw()
));
Ok(AnnotatedCommit::from_raw(ret))
}
}

/// Create a new action signature with default user and now timestamp.
///
/// This looks up the user.name and user.email from the configuration and
Expand Down