pub struct Pathspec { /* private fields */ }Expand description
Parsed and optionally work-tree–resolved pathspec list for matching and display.
Implementations§
Source§impl Pathspec
impl Pathspec
Sourcepub fn scoped(
items: impl IntoIterator<Item = impl AsRef<str>>,
globals: PathspecGlobalFlags,
) -> Self
pub fn scoped( items: impl IntoIterator<Item = impl AsRef<str>>, globals: PathspecGlobalFlags, ) -> Self
Build a scoped pathspec from already-resolved work-tree-relative strings.
Sourcepub fn entire_tree(globals: PathspecGlobalFlags) -> Self
pub fn entire_tree(globals: PathspecGlobalFlags) -> Self
Pathspec list that selects the entire work tree (no argv paths).
Sourcepub fn parse(
items: impl IntoIterator<Item = impl AsRef<str>>,
options: &PathspecOptions,
) -> Result<Self, PathspecParseError>
pub fn parse( items: impl IntoIterator<Item = impl AsRef<str>>, options: &PathspecOptions, ) -> Result<Self, PathspecParseError>
Parse argv / from-file pathspec tokens without resolving against a work tree.
Work-tree-relative resolution and core.precomposeunicode normalization require
Repository::pathspec.
Sourcepub fn is_entire_tree(&self) -> bool
pub fn is_entire_tree(&self) -> bool
Whether the invocation limits paths (false = entire work tree).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether no path limit was given (alias of Self::is_entire_tree).
Sourcepub fn common_prefix(&self) -> Option<&str>
pub fn common_prefix(&self) -> Option<&str>
Longest shared literal directory prefix across positive specs (Git tree narrowing).
Sourcepub fn specs(&self) -> &[String]
pub fn specs(&self) -> &[String]
Resolved work-tree-relative pathspec strings used for matching.
Sourcepub fn iter(&self) -> impl Iterator<Item = &str>
pub fn iter(&self) -> impl Iterator<Item = &str>
User-facing spellings (argv or from-file lines) for messages and --json.
Sourcepub fn globals(&self) -> PathspecGlobalFlags
pub fn globals(&self) -> PathspecGlobalFlags
Global pathspec flags active for this list.
Sourcepub fn matches(&self, repo: &Repository, path: &str) -> Result<bool>
pub fn matches(&self, repo: &Repository, path: &str) -> Result<bool>
Whether path is selected in repo (positive match, no exclude).
§Errors
Same as Repository::pathspec_matcher.
Sourcepub fn matches_entry(
&self,
repo: &Repository,
path: &str,
mode: u32,
) -> Result<bool>
pub fn matches_entry( &self, repo: &Repository, path: &str, mode: u32, ) -> Result<bool>
Entry-aware matching (trailing /, submodules, :(attr:...)).
Sourcepub fn matches_change(
&self,
repo: &Repository,
path: &str,
old_path: Option<&str>,
) -> Result<bool>
pub fn matches_change( &self, repo: &Repository, path: &str, old_path: Option<&str>, ) -> Result<bool>
Whether a diff/staging change is selected (checks old_path for renames).
Sourcepub fn matches_path(&self, path: &str) -> bool
pub fn matches_path(&self, path: &str) -> bool
Match using only pattern rules (no repository attributes); for tests and pure parsing.