use crate::refs::ReferenceError;
use crate::{
CommitError, HistoryError, ObjectId, ObjectKind, ObjectReadError, PeelError,
ResolvePrefixError, TreeError,
};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum RevisionError {
#[error(transparent)]
Parse(#[from] super::ParseRevisionError),
#[error("{0} are not supported yet")]
Unsupported(&'static str),
#[error("unknown revision `{0}`")]
NotFound(String),
#[error("commit {commit} has no parent {parent}")]
NoParent {
commit: ObjectId,
parent: usize,
},
#[error("{id} is a {found}, not a {wanted}", found = .found.as_str(), wanted = .wanted.as_str())]
WrongKind {
id: ObjectId,
found: ObjectKind,
wanted: ObjectKind,
},
#[error("path `{path}` does not exist in {tree}")]
NoPath {
tree: ObjectId,
path: String,
},
#[error("log for `{name}` only has {entries} entries")]
ReflogTooShort {
name: String,
entries: usize,
},
#[error("no reflog for `{0}`")]
NoReflog(String),
#[error("HEAD does not point to a branch")]
DetachedHead,
#[error("no {kind} configured for branch `{branch}`")]
NoUpstream {
branch: String,
kind: &'static str,
},
#[error(transparent)]
Abbreviated(#[from] ResolvePrefixError),
#[error("missing object {0}")]
MissingObject(ObjectId),
#[error(transparent)]
Reference(#[from] ReferenceError),
#[error(transparent)]
Read(#[from] ObjectReadError),
#[error(transparent)]
Peel(#[from] PeelError),
#[error("parsing commit {id}")]
Commit {
id: ObjectId,
#[source]
source: CommitError,
},
#[error("parsing tree {id}")]
Tree {
id: ObjectId,
#[source]
source: TreeError,
},
#[error(transparent)]
History(#[from] HistoryError),
}