1use camino::Utf8PathBuf;
6use thiserror::Error;
7
8#[derive(Clone, Debug, Error, PartialEq)]
11#[non_exhaustive]
12pub enum CommitHashParseError {
13 #[error(
15 "invalid length: expected 40 (SHA-1) or 64 (SHA-256) hex characters, \
16 got {0}"
17 )]
18 InvalidLength(usize),
19
20 #[error("invalid hexadecimal")]
22 InvalidHex(hex::FromHexError),
23}
24
25#[derive(Debug, Error)]
27#[non_exhaustive]
28pub enum GitStubParseError {
29 #[error("git stub is empty")]
31 EmptyInput,
32
33 #[error(
36 "invalid git stub format: expected 'commit:path', got {0:?} \
37 (missing ':' separator)"
38 )]
39 InvalidFormat(String),
40
41 #[error("invalid commit hash in git stub")]
43 InvalidCommitHash(#[from] CommitHashParseError),
44
45 #[error("git stub has empty path (nothing after ':')")]
47 EmptyPath,
48
49 #[error(
52 "git stub path {path:?} contains non-normal component {component:?} \
53 (only plain file/directory names are allowed)"
54 )]
55 InvalidPathComponent {
56 path: Utf8PathBuf,
58 component: String,
60 },
61
62 #[error("git stub path contains a newline character")]
64 NewlineInPath,
65}