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§
- bloom_
lookup_ prefix - bloom_
lookup_ prefix_ with_ cwd - Path prefix used for Bloom-filter lookups (
revision.cconvert_pathspec_to_bloom_keyvec). - 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. - extend_
pathspec_ list_ implicit_ cwd - When every pathspec is an exclude and none use
:(top)/:/, Git prepends an implicit positive that matches only under the process cwd (relative to the work tree), not the whole repository (PATHSPEC_PREFER_CWDinpathspec.c).cwd_from_repo_rootis that prefix without a trailing slash, or empty at the work tree root. - has_
glob_ chars - Whether the pattern uses wildcards after Git pathspec escaping rules.
- literal_
pathspecs_ enabled - Whether
GIT_LITERAL_PATHSPECSis enabled (shell*and?are literal, not globs). - matches_
ls_ tree_ pathspec - Pathspec matching for
ls-treeafter Git forcespathspec.has_wildcard = 0(ls-tree.c). - 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_ list - Git
match_pathspecsemantics over a pathspec list: OR of positive specs minus OR of exclude specs. If every element is exclude-only, Git implicitly prepends.(match all); this function does the same. - matches_
pathspec_ list_ for_ object matches_pathspec_listfor tree/index objects with mode and.gitattributesrules.- matches_
pathspec_ list_ with_ context - Like
matches_pathspec_list, but usesctxfor non-magic pathspec elements (trailing/). - matches_
pathspec_ set_ for_ object - True if
pathmatches the combined pathspec list: any positive spec (or all paths when there are only excludes, matching Gitparse_pathspec), and not matched by any exclude spec. - matches_
pathspec_ set_ for_ object_ ls_ tree - Like
matches_pathspec_set_for_object, but usesmatches_ls_tree_pathspecfor each element sols-files/ index filtering agrees withls-treeon patterns such asa[a]. - matches_
pathspec_ with_ context - Like
matches_pathspec, but usesctxfor trailing-/literal pathspecs and for wildcard pathspecs where the pattern continues after a directory boundary (Gitmatches_pathspec+ directory semantics). - parse_
pathspecs_ from_ source - Read pathspec entries from raw file bytes (stdin or file), matching Git’s
--pathspec-from-file/--pathspec-file-nulrules. - path_
allowed_ by_ pathspec_ list - Whether
pathis included when Git applies a pathspec list with optional:(exclude)entries. - pathspec_
contributes_ match - True when
specmatchespathfor pathspec bookkeeping (positive match or exclude hit). - pathspec_
exclude_ matches - True if
pathis matched by an exclude pathspec’s pattern. Returnsfalseifspecis not an exclude pathspec. - pathspec_
has_ top - True if
specuses:(top)or short:/(repo-root-relative) magic. - pathspec_
is_ exclude - Returns whether
specuses Git’s exclude magic (:(exclude),:!,:^, etc.). - pathspec_
matches - True if
pathis matched byspec(Git pathspec syntax, including magic and globals). - pathspec_
wants_ descent_ into_ tree - Whether tree-walking should recurse into directory
full_namefor pathspecspecwithout-r(Gitread_tree/show_recursive“interesting” descent). - pathspecs_
allow_ bloom - Whether every pathspec can participate in Bloom precomputation (Git
forbid_bloom_filters). - 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).