1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum GitError {
6 #[error("git operation failed")]
7 Git(#[from] git2::Error),
8
9 #[error("not a git repository: '{path}'")]
10 NotARepository { path: PathBuf },
11
12 #[error("failed to resolve reference '{refspec}'")]
13 RefNotFound {
14 refspec: String,
15 #[source]
16 source: git2::Error,
17 },
18
19 #[error("reference '{refspec}' does not point to a tree")]
20 NotATree {
21 refspec: String,
22 #[source]
23 source: git2::Error,
24 },
25
26 #[error("working tree has uncommitted changes")]
27 DirtyWorkingTree,
28
29 #[error("failed to delete file at '{path}'")]
30 FileDelete {
31 path: PathBuf,
32 #[source]
33 source: std::io::Error,
34 },
35
36 #[error("HEAD is detached, not on a branch")]
37 DetachedHead,
38
39 #[error("diff delta has no file path")]
40 MissingDeltaPath,
41
42 #[error("HEAD has no parent commit")]
43 NoParentCommit {
44 #[source]
45 source: git2::Error,
46 },
47}