Skip to content

Commit

Permalink
Merge pull request #988 from ehuss/fix-visibility
Browse files Browse the repository at this point in the history
Fix visibility of StashSaveOptions and DiffPatchidOptions.
  • Loading branch information
ehuss authored Sep 18, 2023
2 parents 2b2fb37 + 952ada3 commit 67fcacc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub use crate::config::{Config, ConfigEntries, ConfigEntry};
pub use crate::cred::{Cred, CredentialHelper};
pub use crate::describe::{Describe, DescribeFormatOptions, DescribeOptions};
pub use crate::diff::{Deltas, Diff, DiffDelta, DiffFile, DiffOptions};
pub use crate::diff::{DiffBinary, DiffBinaryFile, DiffBinaryKind};
pub use crate::diff::{DiffBinary, DiffBinaryFile, DiffBinaryKind, DiffPatchidOptions};
pub use crate::diff::{DiffFindOptions, DiffHunk, DiffLine, DiffLineType, DiffStats};
pub use crate::email::{Email, EmailCreateOptions};
pub use crate::error::Error;
Expand Down Expand Up @@ -131,7 +131,7 @@ pub use crate::revert::RevertOptions;
pub use crate::revspec::Revspec;
pub use crate::revwalk::Revwalk;
pub use crate::signature::Signature;
pub use crate::stash::{StashApplyOptions, StashApplyProgressCb, StashCb};
pub use crate::stash::{StashApplyOptions, StashApplyProgressCb, StashCb, StashSaveOptions};
pub use crate::status::{StatusEntry, StatusIter, StatusOptions, StatusShow, Statuses};
pub use crate::submodule::{Submodule, SubmoduleUpdateOptions};
pub use crate::tag::Tag;
Expand Down
19 changes: 8 additions & 11 deletions src/stash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use libc::{c_char, c_int, c_void, size_t};
use std::ffi::{c_uint, CStr, CString};
use std::mem;

#[allow(unused)]
/// Stash application options structure
pub struct StashSaveOptions<'a> {
message: Option<CString>,
Expand Down Expand Up @@ -72,13 +71,14 @@ impl<'a> StashSaveOptions<'a> {
///
/// Return `true` to continue processing, or `false` to
/// abort the stash application.
// FIXME: This probably should have been pub(crate) since it is not used anywhere.
pub type StashApplyProgressCb<'a> = dyn FnMut(StashApplyProgress) -> bool + 'a;

/// This is a callback function you can provide to iterate over all the
/// stashed states that will be invoked per entry.
// FIXME: This probably should have been pub(crate) since it is not used anywhere.
pub type StashCb<'a> = dyn FnMut(usize, &str, &Oid) -> bool + 'a;

#[allow(unused)]
/// Stash application options structure
pub struct StashApplyOptions<'cb> {
progress: Option<Box<StashApplyProgressCb<'cb>>>,
Expand Down Expand Up @@ -144,22 +144,20 @@ impl<'cb> StashApplyOptions<'cb> {
}
}

#[allow(unused)]
pub struct StashCbData<'a> {
pub(crate) struct StashCbData<'a> {
pub callback: &'a mut StashCb<'a>,
}

#[allow(unused)]
pub extern "C" fn stash_cb(
pub(crate) extern "C" fn stash_cb(
index: size_t,
message: *const c_char,
stash_id: *const raw::git_oid,
payload: *mut c_void,
) -> c_int {
panic::wrap(|| unsafe {
let mut data = &mut *(payload as *mut StashCbData<'_>);
let data = &mut *(payload as *mut StashCbData<'_>);
let res = {
let mut callback = &mut data.callback;
let callback = &mut data.callback;
callback(
index,
CStr::from_ptr(message).to_str().unwrap(),
Expand Down Expand Up @@ -191,15 +189,14 @@ fn convert_progress(progress: raw::git_stash_apply_progress_t) -> StashApplyProg
}
}

#[allow(unused)]
extern "C" fn stash_apply_progress_cb(
progress: raw::git_stash_apply_progress_t,
payload: *mut c_void,
) -> c_int {
panic::wrap(|| unsafe {
let mut options = &mut *(payload as *mut StashApplyOptions<'_>);
let options = &mut *(payload as *mut StashApplyOptions<'_>);
let res = {
let mut callback = options.progress.as_mut().unwrap();
let callback = options.progress.as_mut().unwrap();
callback(convert_progress(progress))
};

Expand Down

0 comments on commit 67fcacc

Please sign in to comment.