Skip to content

Introduce stash_count(&self) -> Result<usize, Error> #564

@twe4ked

Description

@twe4ked

Would it be possible to introduce something like this to Repository? I'm not sure if the goals of this project are to keep it mapping to the libgit2 directly or not. I'm also not sure if allowing not requiring a mutable reference here is sound.

/// Count number of git stashes
pub fn stash_count(&self) -> Result<usize, Error> {
    unsafe {
        let mut count = 0;
        let mut data = StashCbData {
            callback: &mut |_, _, _| {
                count += 1;
                true
            },
        };
        let cb: raw::git_stash_cb = Some(stash_cb);
        try_call!(raw::git_stash_foreach(
            self.raw(),
            cb,
            &mut data as *mut _ as *mut _
        ));
        Ok(count)
    }
}

Based of the stash_foreach implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions