Struct git2::Worktree

source ·
pub struct Worktree { /* private fields */ }
Expand description

An owned git worktree

This structure corresponds to a git_worktree in libgit2.

Implementations§

source§

impl Worktree

source

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.

source

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

source

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.

source

pub fn validate(&self) -> Result<(), Error>

Validates the worktree

This checks that it still exists on the filesystem and that the metadata is correct

source

pub fn lock(&self, reason: Option<&str>) -> Result<(), Error>

Locks the worktree

source

pub fn unlock(&self) -> Result<(), Error>

Unlocks the worktree

source

pub fn is_locked(&self) -> Result<WorktreeLockStatus, Error>

Checks if worktree is locked

source

pub fn prune( &self, opts: Option<&mut WorktreePruneOptions>, ) -> Result<(), Error>

Prunes the worktree

source

pub fn is_prunable( &self, opts: Option<&mut WorktreePruneOptions>, ) -> Result<bool, Error>

Checks if the worktree is prunable

Trait Implementations§

source§

impl Drop for Worktree

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.