Expand description
Gitattributes parsing and pattern matching for check-attr and validation.
Implements Git-consistent rule ordering, macro expansion ([attr]), binary
expansion, ** globbing via crate::wildmatch, and optional case folding
for core.ignorecase.
Structs§
- Attr
Rule - One line in a gitattributes file.
- Macro
Table - Macro definitions from
[attr]name ...lines. - Parsed
GitAttributes - Result of parsing a gitattributes file.
Enums§
- Attr
Value - Parsed attribute value for display (
check-attroutput).
Constants§
- MAX_
ATTR_ FILE_ BYTES - Maximum
.gitattributesfile size (bytes) before Git ignores the file. - MAX_
ATTR_ LINE_ BYTES - Maximum length of a single
.gitattributesline (bytes), matching Git (ATTR_MAX_LINE_LENGTH). Lines of this length or longer are ignored with a warning.
Functions§
- attr_
rule_ applies_ to_ path - Whether a rule from
dir/.gitattributesmay apply torel_path(Gitprepare_attr_stack). - attr_
rule_ matches - Match one parsed rule against a repo-relative path (Git
path_matches/attr.c). - builtin_
objectmode_ index builtin_objectmodefrom the index when--cachedis used.- builtin_
objectmode_ worktree - Return
builtin_objectmodevalue for a path (working tree), orNoneif unavailable. - builtin_
warnings_ for_ rules - Collect warnings for invalid
builtin_*assignments (check-attr continues). - collect_
attrs_ for_ path - Merge assignments: later rules override earlier; within one expanded rule, last wins.
- is_
reserved_ builtin_ name - Returns true if
nameis reserved (builtin_*except the real builtin names Git allows). - load_
gitattributes_ bare - Bare repository: only
info/attributesfrom disk (no in-repo.gitattributesfile). - load_
gitattributes_ for_ diff - Load merged
.gitattributesrules for diff and merge (respectsGIT_ATTR_SOURCE/attr.tree). - load_
gitattributes_ from_ index - Load attributes from the index (stage 0) for
.gitattributespaths only. - load_
gitattributes_ from_ tree - Read
.gitattributesblob from a tree object attree_oid, recursively. - load_
gitattributes_ stack - Load the full stack of attribute rules for a normal repository (working tree).
- normalize_
rel_ path - Normalize
./..segments in a repo-relative path string. - parse_
gitattributes_ file_ content - Parse one gitattributes file from disk (patterns are relative to
attr_base, the directory containing the file — use""for the repository root file). - parse_
gitattributes_ file_ content_ with_ base - Parse attributes defined in a
.gitattributesfile located inattr_base(repo-relative,/separators, no trailing slash; empty string for the repository root). - path_
relative_ to_ worktree - Resolve a user path to a repo-relative path (forward slashes).
- quote_
path_ for_ check_ attr - Quote a path for
check-attroutput (C-style) when needed. - resolve_
attr_ treeish - Resolve
attr.tree,GIT_ATTR_SOURCE,--sourceprecedence for check-attr. - resolve_
tree_ oid - Parse a revision to a tree OID for attribute loading.
- validate_
rules_ for_ add - Validate user-defined attribute names in parsed rules (for
git add).