Skip to content

Commit 18d0fd3

Browse files
kastiglionealexcrichton
authored andcommitted
Add Repository::cherrypick_commit() (#499)
1 parent 6db911b commit 18d0fd3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: libgit2-sys/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,14 @@ extern "C" {
34703470
commit: *mut git_commit,
34713471
options: *const git_cherrypick_options,
34723472
) -> c_int;
3473+
pub fn git_cherrypick_commit(
3474+
out: *mut *mut git_index,
3475+
repo: *mut git_repository,
3476+
cherrypick_commit: *mut git_commit,
3477+
our_commit: *mut git_commit,
3478+
mainline: c_uint,
3479+
merge_options: *const git_merge_options,
3480+
) -> c_int;
34733481
}
34743482

34753483
pub fn init() {

Diff for: src/repo.rs

+23
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,29 @@ impl Repository {
24692469
}
24702470
}
24712471

2472+
/// Create an index of uncommitted changes, representing the result of
2473+
/// cherry-picking.
2474+
pub fn cherrypick_commit(
2475+
&self,
2476+
cherrypick_commit: &Commit<'_>,
2477+
our_commit: &Commit<'_>,
2478+
mainline: u32,
2479+
options: Option<&MergeOptions>,
2480+
) -> Result<Index, Error> {
2481+
let mut ret = ptr::null_mut();
2482+
unsafe {
2483+
try_call!(raw::git_cherrypick_commit(
2484+
&mut ret,
2485+
self.raw(),
2486+
cherrypick_commit.raw(),
2487+
our_commit.raw(),
2488+
mainline,
2489+
options.map(|o| o.raw())
2490+
));
2491+
Ok(Binding::from_raw(ret))
2492+
}
2493+
}
2494+
24722495
/// Retrieves the name of the reference supporting the remote tracking branch,
24732496
/// given the name of a local branch reference.
24742497
pub fn branch_upstream_name(&self, refname: &str) -> Result<Buf, Error> {

0 commit comments

Comments
 (0)