Struct git_attributes::PatternList
source · [−]pub struct PatternList<T: Pattern> {
pub patterns: Vec<PatternMapping<T::Value>>,
pub source: Option<PathBuf>,
pub base: Option<BString>,
}
Expand description
A list of patterns which optionally know where they were loaded from and what their base is.
Knowing their base which is relative to a source directory, it will ignore all path to match against that don’t also start with said base.
Fields
patterns: Vec<PatternMapping<T::Value>>
Patterns and their associated data in the order they were loaded in or specified,
the line number in its source file or its sequence number ((pattern, value, line_number)
).
During matching, this order is reversed.
source: Option<PathBuf>
The path from which the patterns were read, or None
if the patterns
don’t originate in a file on disk.
base: Option<BString>
The parent directory of source, or None
if the patterns are global to match against the repository root.
It’s processed to contain slashes only and to end with a trailing slash, and is relative to the repository root.
Implementations
sourceimpl<T> PatternList<T> where
T: Pattern,
impl<T> PatternList<T> where
T: Pattern,
sourcepub fn from_bytes(
bytes: &[u8],
source: impl Into<PathBuf>,
root: Option<&Path>
) -> Self
pub fn from_bytes(
bytes: &[u8],
source: impl Into<PathBuf>,
root: Option<&Path>
) -> Self
source
is the location of the bytes
which represent a list of patterns line by line.
sourcepub fn from_file(
source: impl Into<PathBuf>,
root: Option<&Path>,
follow_symlinks: bool,
buf: &mut Vec<u8>
) -> Result<Option<Self>>
pub fn from_file(
source: impl Into<PathBuf>,
root: Option<&Path>,
follow_symlinks: bool,
buf: &mut Vec<u8>
) -> Result<Option<Self>>
Create a pattern list from the source
file, which may be located underneath root
, while optionally
following symlinks with follow_symlinks
, providing buf
to temporarily store the data contained in the file.
sourceimpl<T> PatternList<T> where
T: Pattern,
impl<T> PatternList<T> where
T: Pattern,
sourcepub fn pattern_matching_relative_path(
&self,
relative_path: &BStr,
basename_pos: Option<usize>,
is_dir: Option<bool>,
case: Case
) -> Option<Match<'_, T::Value>>
pub fn pattern_matching_relative_path(
&self,
relative_path: &BStr,
basename_pos: Option<usize>,
is_dir: Option<bool>,
case: Case
) -> Option<Match<'_, T::Value>>
Return a match if a pattern matches relative_path
, providing a pre-computed basename_pos
which is the
starting position of the basename of relative_path
. is_dir
is true if relative_path
is a directory.
case
specifies whether cases should be folded during matching or not.
sourceimpl PatternList<Ignore>
impl PatternList<Ignore>
sourcepub fn from_overrides(
patterns: impl IntoIterator<Item = impl Into<OsString>>
) -> Self
pub fn from_overrides(
patterns: impl IntoIterator<Item = impl Into<OsString>>
) -> Self
Parse a list of patterns, using slashes as path separators
Trait Implementations
sourceimpl<T: Clone + Pattern> Clone for PatternList<T> where
T::Value: Clone,
impl<T: Clone + Pattern> Clone for PatternList<T> where
T::Value: Clone,
sourcefn clone(&self) -> PatternList<T>
fn clone(&self) -> PatternList<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Default + Pattern> Default for PatternList<T> where
T::Value: Default,
impl<T: Default + Pattern> Default for PatternList<T> where
T::Value: Default,
sourcefn default() -> PatternList<T>
fn default() -> PatternList<T>
Returns the “default value” for a type. Read more
sourceimpl<T: Ord + Pattern> Ord for PatternList<T> where
T::Value: Ord,
impl<T: Ord + Pattern> Ord for PatternList<T> where
T::Value: Ord,
sourcefn cmp(&self, other: &PatternList<T>) -> Ordering
fn cmp(&self, other: &PatternList<T>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq + Pattern> PartialEq<PatternList<T>> for PatternList<T> where
T::Value: PartialEq,
impl<T: PartialEq + Pattern> PartialEq<PatternList<T>> for PatternList<T> where
T::Value: PartialEq,
sourcefn eq(&self, other: &PatternList<T>) -> bool
fn eq(&self, other: &PatternList<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<T: PartialOrd + Pattern> PartialOrd<PatternList<T>> for PatternList<T> where
T::Value: PartialOrd,
impl<T: PartialOrd + Pattern> PartialOrd<PatternList<T>> for PatternList<T> where
T::Value: PartialOrd,
sourcefn partial_cmp(&self, other: &PatternList<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &PatternList<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Eq + Pattern> Eq for PatternList<T> where
T::Value: Eq,
impl<T: Pattern> StructuralEq for PatternList<T>
impl<T: Pattern> StructuralPartialEq for PatternList<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for PatternList<T> where
<T as Pattern>::Value: RefUnwindSafe,
impl<T> Send for PatternList<T> where
<T as Pattern>::Value: Send,
impl<T> Sync for PatternList<T> where
<T as Pattern>::Value: Sync,
impl<T> Unpin for PatternList<T> where
<T as Pattern>::Value: Unpin,
impl<T> UnwindSafe for PatternList<T> where
<T as Pattern>::Value: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more