Skip to main content

Module pathspec

Module pathspec 

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

PathspecMatchContext
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 a PathspecMatchContext.
literal_pathspecs_enabled
Whether GIT_LITERAL_PATHSPECS is enabled (shell * and ? are literal, not globs).
matches_pathspec
Returns whether path matches the pathspec spec with default (file) context.
matches_pathspec_for_object
Match a pathspec against a tree path, using .gitattributes for :(attr:...).
matches_pathspec_with_context
Like matches_pathspec, but uses ctx for trailing-/ literal pathspecs.
pathspec_matches
True if path is matched by spec (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).