Skip to main content

WorktreeError

Enum WorktreeError 

Source
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.

Fields

§start: PathBuf

Where the search began.

§

BareRepositoryUnsupported

The repository is bare. The topology is defined against a primary checkout.

Fields

§git_dir: PathBuf

The bare repository directory.

§

CannotDeterminePrimaryWorktree

git worktree list answered, and nothing in it is the primary worktree.

Fields

§git_common_dir: PathBuf

The common git directory the topology was read from.

§

NoParentDirectory

The primary checkout is at the filesystem root, so it has no parent to be a sibling in.

Fields

§primary: PathBuf

The primary checkout.

§

InvalidBranchName

A branch name cannot be used as given.

Fields

§given: String

What was given.

§reason: String

Why it was refused.

§

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.

Fields

§branch: String

The branch.

§path: PathBuf

What was derived.

§root: PathBuf

Where it had to be.

§

ContainerNotADirectory

The container path exists and is not a directory.

Fields

§path: PathBuf

The container path.

§

WorktreeAlreadyExists

The worktree asked for is already registered at its canonical path.

Fields

§path: PathBuf

The registered path.

§branch: String

The branch it holds.

§

BranchAlreadyCheckedOut

The branch is checked out in a worktree that is not its canonical one.

Fields

§branch: String

The branch.

§path: PathBuf

Where it is checked out.

§expected: PathBuf

Where it belongs.

§

DestinationConflict

The destination exists and is something else.

Fields

§path: PathBuf

The occupied path.

§what: String

What occupies it, in words.

§

BaseDoesNotExist

The base ref asked for does not resolve.

Fields

§base: String

What was asked for.

§

Misplaced

The current worktree is not where its branch belongs.

Fields

§path: PathBuf

The offending worktree.

§branch: String

Its branch.

§expected: PathBuf

Where the branch belongs.

§

PrimaryOnNonTrunk

The primary checkout holds a branch that is not the trunk.

Fields

§path: PathBuf

The primary checkout.

§branch: String

The branch it holds.

§trunk: String

The trunk.

§expected: PathBuf

Where the branch belongs.

§

DirtyWorktree

The worktree has uncommitted or untracked content and the operation would destroy it.

Fields

§path: PathBuf

The worktree.

§summary: String

What is dirty, in words.

§operation: String

The operation that refused.

§

LockedWorktree

The worktree is locked; git refuses to move or remove it and so does this.

Fields

§path: PathBuf

The worktree.

§reason: Option<String>

The reason git recorded, when it recorded one.

§

PrimaryWorktreeProtected

The primary checkout was named to an operation that only linked worktrees accept.

Fields

§path: PathBuf

The primary checkout.

§operation: String

The operation that refused.

§

NoSuchWorktree

A selector matched nothing.

Fields

§selector: String

What was asked for.

§

NotThisRepository

A path outside every worktree of this repository was named.

Fields

§path: PathBuf

The path named.

§git_common_dir: PathBuf

This repository’s common git directory.

§

MigrationUnsafe

A migration cannot be carried out safely, with the reason.

Fields

§path: PathBuf

The worktree that would have moved.

§reason: String

Why it was refused.

§

VerificationFailed

The fingerprint after a move differs from the one before it.

Fields

§path: PathBuf

Where the worktree is now.

§differences: Vec<String>

What differs, one line each.

§

LockUnavailable

The repository-scoped lock could not be taken.

Fields

§path: PathBuf

The lock file.

§holder: Option<String>

What the lock file says holds it, when it says.

§

TopologyInvalid

The topology is invalid: an error-level diagnostic stands.

Fields

§count: usize

How many error-level diagnostics.

§

GitCommandFailed

A git command failed; its own words are carried through.

Fields

§command: String

The arguments, joined for reading.

§status: String

How it exited.

§stderr: String

What it said on standard error.

§

GitUnavailable

git could not be run at all.

Fields

§reason: String

Why not.

§

Io

A file or directory could not be read or written.

Fields

§path: PathBuf

The path.

§reason: String

What the operating system said.

Implementations§

Source§

impl WorktreeError

Source

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);
Source

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");
Source

pub fn io(path: impl Into<PathBuf>, e: &Error) -> Self

An IO failure against a path.

Trait Implementations§

Source§

impl Clone for WorktreeError

Source§

fn clone(&self) -> WorktreeError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorktreeError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for WorktreeError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for WorktreeError

Source§

impl Error for WorktreeError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for WorktreeError

Source§

fn eq(&self, other: &WorktreeError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for WorktreeError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more