Skip to main content

Crate sley_pathspec

Crate sley_pathspec 

Source
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§

LsFilesPathFilter
Pathspec
A full pathspec: an ordered list of PathspecElements combining positive (include) and :(exclude) patterns.
PathspecAttributeCheck
PathspecElement
A parsed pathspec element: a single pattern plus its magic flags.
PathspecMatchMagic
Pathspec match magic, mirroring git’s PATHSPEC_LITERAL/PATHSPEC_GLOB/ PATHSPEC_ICASE. Constructed from the global --{glob,noglob,icase,literal}-pathspecs options. Drives pathspec_item_matches.

Enums§

PathspecAttrRequirement
PathspecAttributeState
PathspecParseError
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§

normalize_ls_files_pathspec
normalized_revwalk_pathspec
parse_normalized_pathspec_element
pathspec_attrs_match_with
pathspec_filters_have_include
pathspec_filters_match
pathspec_filters_match_with
pathspec_is_glob
True if path contains a glob-special character.
pathspec_item_matches
Port of git’s match_pathspec_item for the single-pathspec / single-name case (no prefix, no attr magic). match_ is the pathspec, name is the candidate path. Returns whether the pathspec selects name (exactly, as a directory prefix, or via wildmatch). Byte-for-byte faithful to git 2.54 for the ls-files -- <pathspec> path that t3070 exercises.
wildmatch
Match pattern against text with git’s wildmatch semantics. flags is a bitwise-OR of WM_CASEFOLD and WM_PATHNAME.