Skip to content

Commit

Permalink
Add Repository::fetchhead_to_annotated_commit (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhickman authored Mar 2, 2020
1 parent 666aeab commit 0811452
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit 0811452

Please sign in to comment.