From 066ba42d2515f3c1b90579804aeabeed9f1e4432 Mon Sep 17 00:00:00 2001 From: Pranav2612000 Date: Sun, 28 Apr 2024 18:32:07 +0530 Subject: [PATCH] feat: create function to allow setting commit_create_cb while rebasing --- src/rebase.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/rebase.rs b/src/rebase.rs index 2bf8fe3e8a..b5275fe00a 100644 --- a/src/rebase.rs +++ b/src/rebase.rs @@ -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 /// @@ -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, &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