pub enum WorktreeError {
Show 25 variants
NotInGitRepository {
start: PathBuf,
},
BareRepositoryUnsupported {
git_dir: PathBuf,
},
CannotDeterminePrimaryWorktree {
git_common_dir: PathBuf,
},
NoParentDirectory {
primary: PathBuf,
},
InvalidBranchName {
given: String,
reason: String,
},
PathEscape {
branch: String,
path: PathBuf,
root: PathBuf,
},
ContainerNotADirectory {
path: PathBuf,
},
WorktreeAlreadyExists {
path: PathBuf,
branch: String,
},
BranchAlreadyCheckedOut {
branch: String,
path: PathBuf,
expected: PathBuf,
},
DestinationConflict {
path: PathBuf,
what: String,
},
BaseDoesNotExist {
base: String,
},
Misplaced {
path: PathBuf,
branch: String,
expected: PathBuf,
},
PrimaryOnNonTrunk {
path: PathBuf,
branch: String,
trunk: String,
expected: PathBuf,
},
DirtyWorktree {
path: PathBuf,
summary: String,
operation: String,
},
LockedWorktree {
path: PathBuf,
reason: Option<String>,
},
PrimaryWorktreeProtected {
path: PathBuf,
operation: String,
},
NoSuchWorktree {
selector: String,
},
NotThisRepository {
path: PathBuf,
git_common_dir: PathBuf,
},
MigrationUnsafe {
path: PathBuf,
reason: String,
},
VerificationFailed {
path: PathBuf,
differences: Vec<String>,
},
LockUnavailable {
path: PathBuf,
holder: Option<String>,
},
TopologyInvalid {
count: usize,
},
GitCommandFailed {
command: String,
status: String,
stderr: String,
},
GitUnavailable {
reason: String,
},
Io {
path: PathBuf,
reason: String,
},
}Expand description
Everything that stops a worktree operation.
Variants§
NotInGitRepository
The start directory is not inside a git work tree.
BareRepositoryUnsupported
The repository is bare. The topology is defined against a primary checkout.
CannotDeterminePrimaryWorktree
git worktree list answered, and nothing in it is the primary worktree.
NoParentDirectory
The primary checkout is at the filesystem root, so it has no parent to be a sibling in.
InvalidBranchName
A branch name cannot be used as given.
PathEscape
The derived worktree path does not stay inside the container. Cannot happen for a valid branch name; refused by name rather than assumed away.
ContainerNotADirectory
The container path exists and is not a directory.
WorktreeAlreadyExists
The worktree asked for is already registered at its canonical path.
BranchAlreadyCheckedOut
The branch is checked out in a worktree that is not its canonical one.
Fields
DestinationConflict
The destination exists and is something else.
BaseDoesNotExist
The base ref asked for does not resolve.
Misplaced
The current worktree is not where its branch belongs.
Fields
PrimaryOnNonTrunk
The primary checkout holds a branch that is not the trunk.
Fields
DirtyWorktree
The worktree has uncommitted or untracked content and the operation would destroy it.
Fields
LockedWorktree
The worktree is locked; git refuses to move or remove it and so does this.
Fields
PrimaryWorktreeProtected
The primary checkout was named to an operation that only linked worktrees accept.
NoSuchWorktree
A selector matched nothing.
NotThisRepository
A path outside every worktree of this repository was named.
MigrationUnsafe
A migration cannot be carried out safely, with the reason.
VerificationFailed
The fingerprint after a move differs from the one before it.
Fields
The repository-scoped lock could not be taken.
TopologyInvalid
The topology is invalid: an error-level diagnostic stands.
GitCommandFailed
A git command failed; its own words are carried through.
Fields
git could not be run at all.
Io
A file or directory could not be read or written.
Implementations§
Source§impl WorktreeError
impl WorktreeError
Sourcepub fn exit_code(&self) -> u8
pub fn exit_code(&self) -> u8
The exit code this error leaves the process with.
use majordomus_cli::worktree::WorktreeError;
use std::path::PathBuf;
let e = WorktreeError::NoSuchWorktree { selector: "nope".into() };
assert_eq!(e.exit_code(), 12);
let e = WorktreeError::DirtyWorktree {
path: PathBuf::from("/a"), summary: "1 change".into(), operation: "remove".into(),
};
assert_eq!(e.exit_code(), 10);Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
The stable machine name of this refusal: what a script or a test matches on, so that neither has to match the prose. It is the variant’s own name.
use majordomus_cli::worktree::WorktreeError;
use std::path::PathBuf;
let e = WorktreeError::Misplaced {
path: PathBuf::from("/tmp/x"), branch: "feature/x".into(), expected: PathBuf::from("/a/foo-wt/feature/x"),
};
assert_eq!(e.code(), "Misplaced");Trait Implementations§
Source§impl Clone for WorktreeError
impl Clone for WorktreeError
Source§fn clone(&self) -> WorktreeError
fn clone(&self) -> WorktreeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorktreeError
impl Debug for WorktreeError
Source§impl Display for WorktreeError
impl Display for WorktreeError
impl Eq for WorktreeError
Source§impl Error for WorktreeError
impl Error for WorktreeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for WorktreeError
impl PartialEq for WorktreeError
Source§fn eq(&self, other: &WorktreeError) -> bool
fn eq(&self, other: &WorktreeError) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WorktreeError
Auto Trait Implementations§
impl Freeze for WorktreeError
impl RefUnwindSafe for WorktreeError
impl Send for WorktreeError
impl Sync for WorktreeError
impl Unpin for WorktreeError
impl UnsafeUnpin for WorktreeError
impl UnwindSafe for WorktreeError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.