Skip to content

Add Repository::cherrypick_commit() #499

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

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
8 changes: 8 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,14 @@ extern "C" {
commit: *mut git_commit,
options: *const git_cherrypick_options,
) -> c_int;
pub fn git_cherrypick_commit(
out: *mut *mut git_index,
repo: *mut git_repository,
cherrypick_commit: *mut git_commit,
our_commit: *mut git_commit,
mainline: c_uint,
merge_options: *const git_merge_options,
) -> c_int;
}

pub fn init() {
Expand Down
23 changes: 23 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,29 @@ impl Repository {
}
}

/// Create an index of uncommitted changes, representing the result of
/// cherry-picking.
pub fn cherrypick_commit(
&self,
cherrypick_commit: &Commit<'_>,
our_commit: &Commit<'_>,
mainline: u32,
options: Option<&MergeOptions>,
) -> Result<Index, Error> {
let mut ret = ptr::null_mut();
unsafe {
try_call!(raw::git_cherrypick_commit(
&mut ret,
self.raw(),
cherrypick_commit.raw(),
our_commit.raw(),
mainline,
options.map(|o| o.raw())
));
Ok(Binding::from_raw(ret))
}
}

/// Retrieves the name of the reference supporting the remote tracking branch,
/// given the name of a local branch reference.
pub fn branch_upstream_name(&self, refname: &str) -> Result<Buf, Error> {
Expand Down