Skip to content

Commit bab1021

Browse files
author
Stephan Dilly
committed
add apply sys api
seems like enum flags need to be untyped (fix ci) trying to fix windows ci issue fix typo next try fixing windows warning next windows ci fix
1 parent 0b8047f commit bab1021

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

libgit2-sys/lib.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub const GIT_SUBMODULE_UPDATE_OPTIONS_VERSION: c_uint = 1;
2323
pub const GIT_ODB_BACKEND_VERSION: c_uint = 1;
2424
pub const GIT_REFDB_BACKEND_VERSION: c_uint = 1;
2525
pub const GIT_CHERRYPICK_OPTIONS_VERSION: c_uint = 1;
26+
pub const GIT_APPLY_OPTIONS_VERSION: c_uint = 1;
2627

2728
macro_rules! git_enum {
2829
(pub enum $name:ident { $($variants:tt)* }) => {
@@ -1728,6 +1729,35 @@ pub struct git_cherrypick_options {
17281729
pub checkout_opts: git_checkout_options,
17291730
}
17301731

1732+
pub type git_apply_delta_cb =
1733+
Option<extern "C" fn(delta: *const git_diff_delta, payload: *mut c_void) -> c_int>;
1734+
1735+
pub type git_apply_hunk_cb =
1736+
Option<extern "C" fn(hunk: *const git_diff_hunk, payload: *mut c_void) -> c_int>;
1737+
1738+
git_enum! {
1739+
pub enum git_apply_flags_t {
1740+
GIT_APPLY_CHECK = 1<<0,
1741+
}
1742+
}
1743+
1744+
#[repr(C)]
1745+
pub struct git_apply_options {
1746+
pub version: c_uint,
1747+
pub delta_cb: git_apply_delta_cb,
1748+
pub hunk_cb: git_apply_hunk_cb,
1749+
pub payload: *mut c_void,
1750+
pub flags: u32,
1751+
}
1752+
1753+
git_enum! {
1754+
pub enum git_apply_location_t {
1755+
GIT_APPLY_LOCATION_WORKDIR = 0,
1756+
GIT_APPLY_LOCATION_INDEX = 1,
1757+
GIT_APPLY_LOCATION_BOTH = 2,
1758+
}
1759+
}
1760+
17311761
extern "C" {
17321762
// threads
17331763
pub fn git_libgit2_init() -> c_int;
@@ -3587,6 +3617,22 @@ extern "C" {
35873617
mainline: c_uint,
35883618
merge_options: *const git_merge_options,
35893619
) -> c_int;
3620+
3621+
// apply
3622+
pub fn git_apply_options_init(opts: *mut git_apply_options, version: c_uint) -> c_int;
3623+
pub fn git_apply_to_tree(
3624+
out: *mut *mut git_index,
3625+
repo: *mut git_repository,
3626+
preimage: *mut git_tree,
3627+
diff: *mut git_diff,
3628+
options: *const git_apply_options,
3629+
) -> c_int;
3630+
pub fn git_apply(
3631+
repo: *mut git_repository,
3632+
diff: *mut git_diff,
3633+
location: git_apply_location_t,
3634+
options: *const git_apply_options,
3635+
) -> c_int;
35903636
}
35913637

35923638
pub fn init() {

0 commit comments

Comments
 (0)