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§
source§impl<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.
source§impl<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.
source§impl 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§
source§impl<T: Clone + Pattern> Clone for PatternList<T>where
T::Value: Clone,
impl<T: Clone + Pattern> Clone for PatternList<T>where T::Value: Clone,
source§fn clone(&self) -> PatternList<T>
fn clone(&self) -> PatternList<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Default + Pattern> Default for PatternList<T>where
T::Value: Default,
impl<T: Default + Pattern> Default for PatternList<T>where T::Value: Default,
source§fn default() -> PatternList<T>
fn default() -> PatternList<T>
source§impl<T: Ord + Pattern> Ord for PatternList<T>where
T::Value: Ord,
impl<T: Ord + Pattern> Ord for PatternList<T>where T::Value: Ord,
source§fn cmp(&self, other: &PatternList<T>) -> Ordering
fn cmp(&self, other: &PatternList<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<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,
source§fn eq(&self, other: &PatternList<T>) -> bool
fn eq(&self, other: &PatternList<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<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,
source§fn partial_cmp(&self, other: &PatternList<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &PatternList<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more