Skip to content

Commit 066ba42

Browse files
committed
feat: create function to allow setting commit_create_cb while rebasing
1 parent 04427a3 commit 066ba42

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/rebase.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use std::ffi::CString;
22
use std::{marker, mem, ptr, str};
33

4+
use libc::c_void;
5+
46
use crate::build::CheckoutBuilder;
57
use crate::util::Binding;
6-
use crate::{raw, Error, Index, MergeOptions, Oid, Signature};
8+
use crate::{raw, Commit, Error, Index, MergeOptions, Oid, Signature, Tree};
79

810
/// Rebase options
911
///
@@ -34,6 +36,20 @@ impl<'cb> RebaseOptions<'cb> {
3436
opts
3537
}
3638

39+
/// Used by `Repository::rebase`, this will trigger a callback
40+
/// when creating commits. For example, to sign commits
41+
pub fn commit_create_cb(&mut self, commit_create_cb_op: Option<fn(&Oid, &Signature<'_>, &Signature<'_>, &i8, &i8, &Tree<'_>, usize, &Commit<'_>, *mut c_void) -> i32>) -> &mut RebaseOptions<'cb> {
42+
43+
unsafe {
44+
//let parsed = std::mem::transmute(commit_create_cb_closure);
45+
if let Some(commit_create_cb) = commit_create_cb_op {
46+
self.raw.commit_create_cb = Some(std::mem::transmute(commit_create_cb));
47+
}
48+
}
49+
50+
self
51+
}
52+
3753
/// Used by `Repository::rebase`, this will instruct other clients working on this
3854
/// rebase that you want a quiet rebase experience, which they may choose to
3955
/// provide in an application-specific manner. This has no effect upon

0 commit comments

Comments
 (0)