Struct gix::Worktree

source ·
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>

source

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

Available on crate feature index only.
source

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

Available on crate feature index only.
source§

impl<'repo> Worktree<'repo>

source

pub fn excludes( &self, overrides: Option<Search> ) -> Result<AttributeStack<'_>, Error>

Available on crate feature 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/…/ignore if core.excludesFile is not set, otherwise use the configured file.
  • $GIT_DIR/info/exclude if 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>

source

pub fn attributes( &self, overrides: Option<Search> ) -> Result<AttributeStack<'repo>, Error>

Available on crate feature 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|attributes if core.excludesFile|attributesFile is not set, otherwise use the configured file.
  • $GIT_DIR/info/exclude|attributes if present.
source

pub fn attributes_only(&self) -> Result<AttributeStack<'repo>, Error>

Available on crate feature attributes only.

Like attributes(), but without access to exclude/ignore information.

source§

impl<'repo> Worktree<'repo>

source

pub fn pathspec( &self, patterns: impl IntoIterator<Item = impl AsRef<BStr>> ) -> Result<Pathspec<'repo>, Error>

Available on crate feature 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>

Access

source

pub fn base(&self) -> &'repo Path

Read the location of the checkout, the base of the work tree

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl<'repo> Clone for Worktree<'repo>

source§

fn clone(&self) -> Worktree<'repo>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'repo> Debug for Worktree<'repo>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'repo> !RefUnwindSafe for Worktree<'repo>

§

impl<'repo> !Send for Worktree<'repo>

§

impl<'repo> !Sync for Worktree<'repo>

§

impl<'repo> Unpin for Worktree<'repo>

§

impl<'repo> !UnwindSafe for Worktree<'repo>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere 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 Twhere 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.