Skip to main content

WorktreeError

Enum WorktreeError 

Source
#[non_exhaustive]
pub enum WorktreeError {
Show 43 variants Linked(LinkedWorktreeError), PathIo(PathIoError), FileChanged { path: String, }, Path { detail: String, }, NonUtf8Path { path: String, }, InvalidPath { path: String, }, InvalidPathComponent { path: String, reason: PathComponentError, }, OutsideRepo(PathOutsideRepoError), PathspecFromFile(PathspecFromFileParseError), InvalidAttrPathspec { spec: String, reason: AttrPathspecError, }, PathspecNoMatch { spec: String, }, PathspecBeyondSymlink { spec: String, }, PathspecIgnored { paths: Vec<String>, }, RestoreConflictWithStaged, RestoreConflictWithSource, RestoreConflictMissingTheirs { path: String, }, RestoreConflictMissingOurs { path: String, }, RestoreConflictNotUnmerged { path: String, }, RestorePathUnmerged { paths: Vec<String>, }, EmbeddedRepoWithoutCommit { path: String, }, RemoveBlocked { paths: Vec<BlockedRemoval>, }, NotRemovingRecursively { path: String, }, RemovePathsRequired, RemoveContainsCurrentDirectory { path: String, }, RestorePathsRequired, RestoreStageWithRemerge, RequiresWorkTree, MoveSourceNotTracked { src: String, }, MoveDestinationExists { src: String, destination: String, }, MoveDestinationNotDirectory { destination: String, }, MoveIntoSubdirectory { src: String, destination: String, }, MoveIntoSelf { src: String, destination: String, }, MoveNothingToMove { src: String, }, MoveDuplicateDestination { destination: String, }, MoveBadSource { src: String, destination: String, }, MoveMissingIndexEntry { path: String, }, WouldOverwrite { reason: OverwriteReason, paths: Vec<String>, message: String, }, DirtyWorktree { operation: WorktreeOperation, paths: Vec<String>, }, CheckoutRollbackIncomplete { source: ErrorSummary, unrestored: Vec<String>, }, MoveRollbackIncomplete { source: ErrorSummary, unreversed: usize, backup_restore: Option<ErrorSummary>, }, UnmergedConflictMarkers { paths: Vec<String>, }, Filter(FilterError), Submodule(SubmoduleError),
}
Expand description

Worktree-area failure (checkout, status, add/rm/mv/restore/clean, pathspec, filters, linked worktrees).

Surfaced on the umbrella as Error::Worktree.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Linked(LinkedWorktreeError)

Linked worktree registry add/remove/move/lock/repair failure.

§

PathIo(PathIoError)

Filesystem I/O on a repository-relative worktree path.

§

FileChanged

A worktree file changed while it was being hashed and stored.

Fields

§path: String

Index-relative path of the file.

§

Path

General path resolution failure (invalid UTF-8, out-of-bounds, etc.).

Fields

§detail: String

What went wrong with the path.

§

NonUtf8Path

A path that must be UTF-8 for this operation is not.

Fields

§path: String

The path with invalid bytes replaced.

§

InvalidPath

A path string failed validation (legacy invalid-path checks).

Fields

§path: String

Offending path text.

§

InvalidPathComponent

A repository-relative path failed component validation.

Fields

§path: String

Full repository-relative path that was rejected.

§reason: PathComponentError

Which component rule failed.

§

OutsideRepo(PathOutsideRepoError)

Path resolves outside the repository.

§

PathspecFromFile(PathspecFromFileParseError)

--pathspec-from-file parse failure.

§

InvalidAttrPathspec

Malformed :(attr:...) pathspec magic.

Fields

§spec: String

The offending pathspec as given.

§reason: AttrPathspecError

What is wrong with its attr clause.

§

PathspecNoMatch

Pathspec matched no tracked or indexed file.

Fields

§spec: String

User-supplied pathspec that matched nothing.

Literal pathspec crosses a symlink directory component.

Fields

§spec: String

User-supplied pathspec that crosses a symlink directory.

§

PathspecIgnored

Explicit pathspecs name ignored paths.

Fields

§paths: Vec<String>

Repository-relative paths that cannot be staged while ignored.

§

RestoreConflictWithStaged

Restore conflict options combined with --staged.

§

RestoreConflictWithSource

Restore conflict options combined with --source.

§

RestoreConflictMissingTheirs

Missing “theirs” stage for a conflict restore path.

Fields

§path: String

Repository-relative path.

§

RestoreConflictMissingOurs

Missing “ours” stage for a conflict restore path.

Fields

§path: String

Repository-relative path.

§

RestoreConflictNotUnmerged

Path is not unmerged when remerge was requested.

Fields

§path: String

Repository-relative path.

§

RestorePathUnmerged

Worktree restore requested for paths that still have conflict stages.

Fields

§paths: Vec<String>

Matched repository-relative paths with conflict stages (sorted, deduplicated).

§

EmbeddedRepoWithoutCommit

Nested .git checkout has no commit on its current branch.

Fields

§path: String

Repository-relative path to the nested checkout directory.

§

RemoveBlocked

Remove refused paths with unsaved content without --force.

Fields

§paths: Vec<BlockedRemoval>

Each refused path with the reason it was refused.

§

NotRemovingRecursively

Directory pathspec without -r on remove.

Fields

§path: String

Directory path that requires -r.

§

RemovePathsRequired

Remove called with no pathspecs.

§

RemoveContainsCurrentDirectory

Clean refused to remove a directory that contains the current working directory.

Fields

§path: String

Repository-relative directory path.

§

RestorePathsRequired

Restore called with no pathspecs.

§

RestoreStageWithRemerge

Restore was asked both to pick a conflict side and to rebuild conflict markers.

§

RequiresWorkTree

Operation requires a checked-out work tree.

§

MoveSourceNotTracked

Move source is not tracked.

Fields

§src: String

Untracked or missing source path.

§

MoveDestinationExists

Move destination exists without --force.

Fields

§src: String

Source path in the move request.

§destination: String

Existing destination path.

§

MoveDestinationNotDirectory

Trailing slash named a destination that is not a directory.

Fields

§destination: String

Destination path (trailing slash already removed).

§

MoveIntoSubdirectory

Destination lies under the source directory.

Fields

§src: String

Source directory path.

§destination: String

Invalid destination under the source.

§

MoveIntoSelf

Source and destination are the same path.

Fields

§src: String

Source path.

§destination: String

Destination equal to the source.

§

MoveNothingToMove

Source has no index entries to move.

Fields

§src: String

Source path with no index entries.

§

MoveDuplicateDestination

Multiple sources would move to the same destination.

Fields

§destination: String

Destination path that would receive more than one source.

§

MoveBadSource

Move source path is missing or not a file, directory, or symlink.

Fields

§src: String

Source path.

§destination: String

Planned destination path.

§

MoveMissingIndexEntry

Internal invariant: missing index entry during a move.

Fields

§path: String

Index path that should exist during a move.

§

WouldOverwrite

Checkout or switch would overwrite local or untracked content.

Fields

§reason: OverwriteReason

Whether tracked local edits or untracked paths block the operation.

§paths: Vec<String>

Repository-relative paths that would be overwritten (sorted, deduplicated).

§message: String

Human-readable summary (depends on OverwriteReason).

§

DirtyWorktree

Staged or unstaged changes block an operation that needs a clean worktree.

Fields

§operation: WorktreeOperation

The operation that was refused.

§paths: Vec<String>

Repository-relative paths with staged or unstaged changes (sorted, deduplicated).

§

CheckoutRollbackIncomplete

A checkout failed or was cancelled before it finished, and putting the work tree back failed for some paths.

Refs and the index are unchanged, as after any failed checkout; only unrestored differ from the index. Error::is_cancelled reports whether source was a cancellation.

Fields

§source: ErrorSummary

Why the checkout stopped.

§unrestored: Vec<String>

Repository-relative paths left different from the index (sorted, deduplicated).

§

MoveRollbackIncomplete

A move failed, and putting the work tree back failed too.

The index is unchanged; renames that could not be reversed and forced-destination backups that could not be restored are left as they are on disk.

Fields

§source: ErrorSummary

Why the move stopped.

§unreversed: usize

Number of completed renames that could not be reversed.

§backup_restore: Option<ErrorSummary>

Why restoring the destinations a forced move replaced failed, when it did.

§

UnmergedConflictMarkers

Staging refused paths that still contain conflict markers.

Fields

§paths: Vec<String>

Repository-relative paths that were not staged because markers remain.

§

Filter(FilterError)

Clean/smudge filter or EOL conversion failure.

§

Submodule(SubmoduleError)

Submodule layout or state failure during worktree operations.

Implementations§

Source§

impl WorktreeError

Source

pub fn is_cancelled(&self) -> bool

Whether this failure records a cancellation (a checkout whose rollback was incomplete after it was cancelled).

Source

pub fn kind_name(&self) -> &'static str

Stable snake_case slug for this failure (matches former Error::kind_name values).

Trait Implementations§

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 Error for WorktreeError

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 From<FilterError> for WorktreeError

Source§

fn from(source: FilterError) -> Self

Converts to this type from the input type.
Source§

impl From<LinkedWorktreeError> for WorktreeError

Source§

fn from(source: LinkedWorktreeError) -> Self

Converts to this type from the input type.
Source§

impl From<PathIoError> for WorktreeError

Source§

fn from(source: PathIoError) -> Self

Converts to this type from the input type.
Source§

impl From<PathOutsideRepoError> for WorktreeError

Source§

fn from(source: PathOutsideRepoError) -> Self

Converts to this type from the input type.
Source§

impl From<PathspecFromFileParseError> for WorktreeError

Source§

fn from(source: PathspecFromFileParseError) -> Self

Converts to this type from the input type.
Source§

impl From<SubmoduleError> for WorktreeError

Source§

fn from(source: SubmoduleError) -> Self

Converts to this type from the input type.
Source§

impl From<WorktreeError> for Error

Source§

fn from(source: WorktreeError) -> Self

Converts to this type from the input type.

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.