Struct git2::Pathspec

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

Structure representing a compiled pathspec used for matching against various structures.

Implementations§

source§

impl Pathspec

source

pub fn new<I, T>(specs: I) -> Result<Pathspec, Error>
where T: IntoCString, I: IntoIterator<Item = T>,

Creates a new pathspec from a list of specs to match against.

source

pub fn match_diff( &self, diff: &Diff<'_>, flags: PathspecFlags, ) -> Result<PathspecMatchList<'_>, Error>

Match a pathspec against files in a diff.

The list returned contains the list of all matched filenames (unless you pass PATHSPEC_FAILURES_ONLY in the flags) and may also contain the list of pathspecs with no match if the PATHSPEC_FIND_FAILURES flag is specified.

source

pub fn match_tree( &self, tree: &Tree<'_>, flags: PathspecFlags, ) -> Result<PathspecMatchList<'_>, Error>

Match a pathspec against files in a tree.

The list returned contains the list of all matched filenames (unless you pass PATHSPEC_FAILURES_ONLY in the flags) and may also contain the list of pathspecs with no match if the PATHSPEC_FIND_FAILURES flag is specified.

source

pub fn match_index( &self, index: &Index, flags: PathspecFlags, ) -> Result<PathspecMatchList<'_>, Error>

This matches the pathspec against the files in the repository index.

The list returned contains the list of all matched filenames (unless you pass PATHSPEC_FAILURES_ONLY in the flags) and may also contain the list of pathspecs with no match if the PATHSPEC_FIND_FAILURES flag is specified.

source

pub fn match_workdir( &self, repo: &Repository, flags: PathspecFlags, ) -> Result<PathspecMatchList<'_>, Error>

Match a pathspec against the working directory of a repository.

This matches the pathspec against the current files in the working directory of the repository. It is an error to invoke this on a bare repo. This handles git ignores (i.e. ignored files will not be considered to match the pathspec unless the file is tracked in the index).

The list returned contains the list of all matched filenames (unless you pass PATHSPEC_FAILURES_ONLY in the flags) and may also contain the list of pathspecs with no match if the PATHSPEC_FIND_FAILURES flag is specified.

source

pub fn matches_path(&self, path: &Path, flags: PathspecFlags) -> bool

Try to match a path against a pathspec

Unlike most of the other pathspec matching functions, this will not fall back on the native case-sensitivity for your platform. You must explicitly pass flags to control case sensitivity or else this will fall back on being case sensitive.

Trait Implementations§

source§

impl Drop for Pathspec

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.