Expand description
Git-compatible pathspec matching (magic tokens and global flags).
Global flags are read from the same environment variables as Git:
GIT_LITERAL_PATHSPECS, GIT_GLOB_PATHSPECS, GIT_NOGLOB_PATHSPECS,
GIT_ICASE_PATHSPECS. The grit binary sets these from CLI flags such as
--literal-pathspecs before dispatching subcommands.
Structs§
- Pathspec
Match Context - Optional path metadata for literal pathspecs with a trailing
/(tree-walk / diff-tree).
Functions§
- context_
from_ mode_ bits - Classify a raw Git mode (e.g. from an index or tree entry) for pathspec matching.
- context_
from_ mode_ octal - Parse a Git mode string (e.g.
100644,040000) into aPathspecMatchContext. - literal_
pathspecs_ enabled - Whether
GIT_LITERAL_PATHSPECSis enabled (shell*and?are literal, not globs). - matches_
pathspec - Returns whether
pathmatches the pathspecspecwith default (file) context. - matches_
pathspec_ for_ object - Match a pathspec against a tree path, using
.gitattributesfor:(attr:...). - matches_
pathspec_ with_ context - Like
matches_pathspec, but usesctxfor trailing-/literal pathspecs. - pathspec_
matches - True if
pathis matched byspec(Git pathspec syntax, including magic and globals). - simple_
length - Returns the length of the leading literal segment before the first glob metacharacter,
matching Git’s
simple_length()(*?[\) on bytes. - validate_
global_ pathspec_ flags - Validates global pathspec environment flags the same way Git does.
- wildmatch_
flags_ icase_ glob - Returns wildmatch flags for
:(icase)/:(glob)-style patterns when those appear as explicit magic (not used by default CLI pathspecs).