pub struct Pattern {
    pub signature: MagicSignature,
    pub search_mode: SearchMode,
    pub attributes: Vec<Assignment>,
    /* private fields */
}Expand description
The output of a pathspec parsing operation. It can be used to match against a one or more paths.
Fields§
§signature: MagicSignatureAll magic signatures that were included in the pathspec.
search_mode: SearchModeThe search mode of the pathspec.
attributes: Vec<Assignment>All attributes that were included in the ATTR part of the pathspec, if present.
:(attr:a=one b=):path would yield attribute a and b.
Implementations§
Source§impl Pattern
Access
 
impl Pattern
Access
Sourcepub fn is_nil(&self) -> bool
 
pub fn is_nil(&self) -> bool
Returns true if this seems to be a pathspec that indicates that ‘there is no pathspec’.
Note that such a spec is :.
Sourcepub fn prefix_directory(&self) -> &BStr
 
pub fn prefix_directory(&self) -> &BStr
Return the prefix-portion of the path of this spec, which is a directory.
It can be empty if there is no prefix.
A prefix is effectively the CWD seen as relative to the working tree, and it’s assumed to match case-sensitively. This makes it useful for skipping over large portions of input by directly comparing them.
Source§impl Pattern
Mutation
 
impl Pattern
Mutation
Sourcepub fn normalize(
    &mut self,
    prefix: &Path,
    root: &Path,
) -> Result<&mut Self, Error>
 
pub fn normalize( &mut self, prefix: &Path, root: &Path, ) -> Result<&mut Self, Error>
Normalize the pattern’s path by assuring it’s relative to the root of the working tree, and contains
no relative path components. Further, it assures that / are used as path separator.
If self.path is a relative path, it will be put in front of the pattern path if self.signature isn’t indicating TOP already.
If self.path is an absolute path, we will use root to make it worktree relative if possible.
prefix can be empty, we will still normalize this pathspec to resolve relative path components, and
it is assumed not to contain any relative path components, e.g. ‘’, ‘a’, ‘a/b’ are valid.
root is the absolute path to the root of either the worktree or the repository’s git_dir.
Source§impl Pattern
Access
 
impl Pattern
Access
Sourcepub fn is_excluded(&self) -> bool
 
pub fn is_excluded(&self) -> bool
Return true if this pathspec is negated, which means it will exclude an item from the result set instead of including it.
Sourcepub fn always_matches(&self) -> bool
 
pub fn always_matches(&self) -> bool
Returns true is this pattern is supposed to always match, as it’s either empty or designated nil.
Note that technically the pattern might still be excluded.
Sourcepub fn to_bstring(&self) -> BString
 
pub fn to_bstring(&self) -> BString
Translate ourselves to a long display format, that when parsed back will yield the same pattern.
Note that the
Source§impl Pattern
 
impl Pattern
Sourcepub fn from_bytes(input: &[u8], _: Defaults) -> Result<Self, Error>
 
pub fn from_bytes(input: &[u8], _: Defaults) -> Result<Self, Error>
Try to parse a path-spec pattern from the given input bytes.
Sourcepub fn from_literal(input: &[u8], default_signature: MagicSignature) -> Self
 
pub fn from_literal(input: &[u8], default_signature: MagicSignature) -> Self
Take input literally without parsing anything. This will also set our mode to literal to allow this pathspec to match input verbatim, and
use default_signature as magic signature.