Skip to content

Commit

Permalink
feat: create function to allow setting commit_create_cb while rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav2612000 committed Apr 28, 2024
1 parent 04427a3 commit 066ba42
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/rebase.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::ffi::CString;
use std::{marker, mem, ptr, str};

use libc::c_void;

use crate::build::CheckoutBuilder;
use crate::util::Binding;
use crate::{raw, Error, Index, MergeOptions, Oid, Signature};
use crate::{raw, Commit, Error, Index, MergeOptions, Oid, Signature, Tree};

/// Rebase options
///
Expand Down Expand Up @@ -34,6 +36,20 @@ impl<'cb> RebaseOptions<'cb> {
opts
}

/// Used by `Repository::rebase`, this will trigger a callback
/// when creating commits. For example, to sign commits
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> {

unsafe {
//let parsed = std::mem::transmute(commit_create_cb_closure);
if let Some(commit_create_cb) = commit_create_cb_op {
self.raw.commit_create_cb = Some(std::mem::transmute(commit_create_cb));
}
}

self
}

/// Used by `Repository::rebase`, this will instruct other clients working on this
/// rebase that you want a quiet rebase experience, which they may choose to
/// provide in an application-specific manner. This has no effect upon
Expand Down

0 comments on commit 066ba42

Please sign in to comment.