Skip to main content

Module attributes

Module attributes 

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

AttrRule
One line in a gitattributes file.
MacroTable
Macro definitions from [attr]name ... lines.
ParsedGitAttributes
Result of parsing a gitattributes file.

Enums§

AttrValue
Parsed attribute value for display (check-attr output).

Constants§

MAX_ATTR_FILE_BYTES
Maximum .gitattributes file size (bytes) before Git ignores the file.
MAX_ATTR_LINE_BYTES
Maximum length of a single .gitattributes line (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/.gitattributes may apply to rel_path (Git prepare_attr_stack).
attr_rule_matches
Match one parsed rule against a repo-relative path (Git path_matches / attr.c).
builtin_objectmode_index
builtin_objectmode from the index when --cached is used.
builtin_objectmode_worktree
Return builtin_objectmode value for a path (working tree), or None if 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 name is reserved (builtin_* except the real builtin names Git allows).
load_gitattributes_bare
Bare repository: only info/attributes from disk (no in-repo .gitattributes file).
load_gitattributes_for_diff
Load merged .gitattributes rules for diff and merge (respects GIT_ATTR_SOURCE / attr.tree).
load_gitattributes_from_index
Load attributes from the index (stage 0) for .gitattributes paths only.
load_gitattributes_from_tree
Read .gitattributes blob from a tree object at tree_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 .gitattributes file located in attr_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-attr output (C-style) when needed.
resolve_attr_treeish
Resolve attr.tree, GIT_ATTR_SOURCE, --source precedence 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).