git_ref/
peel.rs

1/// A function for use in [`crate::file::ReferenceExt::peel_to_id_in_place()`] to indicate no peeling should happen.
2pub fn none(
3    _id: git_hash::ObjectId,
4    #[allow(clippy::ptr_arg)] _buf: &mut Vec<u8>,
5) -> Result<Option<(git_object::Kind, &[u8])>, std::convert::Infallible> {
6    Ok(Some((git_object::Kind::Commit, &[])))
7}
8
9///
10pub mod to_id {
11    use std::path::PathBuf;
12
13    use git_object::bstr::BString;
14
15    use crate::file;
16
17    /// The error returned by [`crate::file::ReferenceExt::peel_to_id_in_place()`].
18    #[derive(Debug, thiserror::Error)]
19    #[allow(missing_docs)]
20    pub enum Error {
21        #[error("Could not follow a single level of a symbolic reference")]
22        Follow(#[from] file::find::existing::Error),
23        #[error("Aborting due to reference cycle with first seen path being {start_absolute:?}")]
24        Cycle { start_absolute: PathBuf },
25        #[error("Refusing to follow more than {max_depth} levels of indirection")]
26        DepthLimitExceeded { max_depth: usize },
27        #[error("An error occurred when trying to resolve an object a reference points to")]
28        Find(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
29        #[error("Object {oid} as referred to by {name:?} could not be found")]
30        NotFound { oid: git_hash::ObjectId, name: BString },
31    }
32}