pub struct Worktree<'repo> { /* private fields */ }Expand description
A worktree checkout containing the files of the repository in consumable form.
Implementations§
source§impl<'repo> Worktree<'repo>
impl<'repo> Worktree<'repo>
sourcepub fn open_index(&self) -> Result<File, Error>
Available on crate feature index only.
pub fn open_index(&self) -> Result<File, Error>
index only.A shortcut to crate::Repository::open_index().
source§impl<'repo> Worktree<'repo>
impl<'repo> Worktree<'repo>
sourcepub fn excludes(
&self,
overrides: Option<Search>
) -> Result<AttributeStack<'_>, Error>
Available on crate feature excludes only.
pub fn excludes( &self, overrides: Option<Search> ) -> Result<AttributeStack<'_>, Error>
excludes only.Configure a file-system cache checking if files below the repository are excluded.
This takes into consideration all the usual repository configuration, namely:
$XDG_CONFIG_HOME/…/ignoreifcore.excludesFileis not set, otherwise use the configured file.$GIT_DIR/info/excludeif present.
When only excludes are desired, this is the most efficient way to obtain them. Otherwise use
Worktree::attributes() for accessing both attributes and excludes.
source§impl<'repo> Worktree<'repo>
impl<'repo> Worktree<'repo>
sourcepub fn attributes(
&self,
overrides: Option<Search>
) -> Result<AttributeStack<'repo>, Error>
Available on crate feature attributes only.
pub fn attributes( &self, overrides: Option<Search> ) -> Result<AttributeStack<'repo>, Error>
attributes only.Configure a file-system cache checking if files below the repository are excluded or for querying their attributes.
This takes into consideration all the usual repository configuration, namely:
$XDG_CONFIG_HOME/…/ignore|attributesifcore.excludesFile|attributesFileis not set, otherwise use the configured file.$GIT_DIR/info/exclude|attributesif present.
sourcepub fn attributes_only(&self) -> Result<AttributeStack<'repo>, Error>
Available on crate feature attributes only.
pub fn attributes_only(&self) -> Result<AttributeStack<'repo>, Error>
attributes only.Like attributes(), but without access to exclude/ignore information.
source§impl<'repo> Worktree<'repo>
impl<'repo> Worktree<'repo>
sourcepub fn pathspec(
&self,
patterns: impl IntoIterator<Item = impl AsRef<BStr>>
) -> Result<Pathspec<'repo>, Error>
Available on crate feature attributes only.
pub fn pathspec( &self, patterns: impl IntoIterator<Item = impl AsRef<BStr>> ) -> Result<Pathspec<'repo>, Error>
attributes only.Configure pathspecs patterns to be matched against, with pathspec attributes read from the worktree and then from the index
if needed.
Deviation
Pathspec attributes match case-insensitively by default if the underlying filesystem is configured that way.
source§impl<'repo> Worktree<'repo>
impl<'repo> Worktree<'repo>
Access
sourcepub fn is_main(&self) -> bool
pub fn is_main(&self) -> bool
Return true if this worktree is the main worktree associated with a non-bare git repository.
It cannot be removed.
sourcepub fn is_locked(&self) -> bool
pub fn is_locked(&self) -> bool
Return true if this worktree cannot be pruned, moved or deleted, which is useful if it is located on an external storage device.
Always false for the main worktree.
sourcepub fn lock_reason(&self) -> Option<BString>
pub fn lock_reason(&self) -> Option<BString>
Provide a reason for the locking of this worktree, if it is locked at all.
Note that we squelch errors in case the file cannot be read in which case the reason is an empty string.
sourcepub fn id(&self) -> Option<&BStr>
pub fn id(&self) -> Option<&BStr>
Return the ID of the repository worktree, if it is a linked worktree, or None if it’s a linked worktree.
sourcepub fn dot_git_exists(&self) -> bool
pub fn dot_git_exists(&self) -> bool
Returns true if the .git file or directory exists within the worktree.
This is an indicator for the worktree to be checked out particularly if the parent repository is a submodule.