pub struct Worktree { /* private fields */ }
Expand description
An owned git worktree
This structure corresponds to a git_worktree
in libgit2.
Implementations§
source§impl Worktree
impl Worktree
sourcepub fn open_from_repository(repo: &Repository) -> Result<Worktree, Error>
pub fn open_from_repository(repo: &Repository) -> Result<Worktree, Error>
Open a worktree of a the repository
If a repository is not the main tree but a worktree, this
function will look up the worktree inside the parent
repository and create a new git_worktree
structure.
sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Retrieves the name of the worktree
This is the name that can be passed to repo::Repository::find_worktree to reopen the worktree. This is also the name that would appear in the list returned by repo::Repository::worktrees
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Retrieves the path to the worktree
This is the path to the top-level of the source and not the path to the .git file within the worktree. This path can be passed to repo::Repository::open.
sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validates the worktree
This checks that it still exists on the filesystem and that the metadata is correct
sourcepub fn is_locked(&self) -> Result<WorktreeLockStatus, Error>
pub fn is_locked(&self) -> Result<WorktreeLockStatus, Error>
Checks if worktree is locked
sourcepub fn prune(
&self,
opts: Option<&mut WorktreePruneOptions>,
) -> Result<(), Error>
pub fn prune( &self, opts: Option<&mut WorktreePruneOptions>, ) -> Result<(), Error>
Prunes the worktree
sourcepub fn is_prunable(
&self,
opts: Option<&mut WorktreePruneOptions>,
) -> Result<bool, Error>
pub fn is_prunable( &self, opts: Option<&mut WorktreePruneOptions>, ) -> Result<bool, Error>
Checks if the worktree is prunable