Expand description
Shared pathspec primitive for sley.
This crate owns the byte-faithful port of git’s wildmatch engine
(wildmatch.c::dowild) and the single-item pathspec matcher
(match_pathspec_item), plus a Pathspec type that parses git’s
pathspec magic prefixes (:(exclude), :(icase), :(literal),
:(glob), :(top), :(attr:...), and the shorthand :!/:^/:/).
Four clusters consume this primitive: the rev-walk (sley-rev), diff,
the worktree walker (sley-worktree, which re-exports the engine for its
ls-files path), and the CLI. Keeping the wildmatch port and the magic
parser in one low-level crate (depending only on sley-core) means there
is exactly one implementation of git’s matching semantics to keep in sync
with the 2.54 oracle.
STAGE-A scope: parsing + per-path matches. The TREESAME / history
simplification that consumes a Pathspec to prune the rev-walk is
STAGE-B; this crate only provides the matching primitive that stage will
drive.
Structs§
- Pathspec
- A full pathspec: an ordered list of
PathspecElements combining positive (include) and:(exclude)patterns. - Pathspec
Element - A parsed pathspec element: a single pattern plus its magic flags.
- Pathspec
Match Magic - Pathspec match magic, mirroring git’s
PATHSPEC_LITERAL/PATHSPEC_GLOB/PATHSPEC_ICASE. Constructed from the global--{glob,noglob,icase,literal}-pathspecsoptions. Drivespathspec_item_matches.
Enums§
- Pathspec
Parse Error - Error parsing a pathspec magic prefix.
Constants§
- WM_
CASEFOLD - Case-insensitive match flag (git
WM_CASEFOLD). - WM_
PATHNAME - Pathname-aware match flag (git
WM_PATHNAME):*/?do not cross/,**is required to span directory separators.
Functions§
- pathspec_
is_ glob - True if
pathcontains a glob-special character. - pathspec_
item_ matches - Port of git’s
match_pathspec_itemfor the single-pathspec / single-name case (no prefix, no attr magic).match_is the pathspec,nameis the candidate path. Returns whether the pathspec selectsname(exactly, as a directory prefix, or via wildmatch). Byte-for-byte faithful to git 2.54 for thels-files -- <pathspec>path that t3070 exercises. - wildmatch
- Match
patternagainsttextwith git’swildmatchsemantics.flagsis a bitwise-OR ofWM_CASEFOLDandWM_PATHNAME.