Expand description
The managed section of .gitattributes.
The section holds one static line, * filter=git-xcrypt, and the whole
security guarantee rests on it. It does not depend on the contents of
.git-xcrypt, so it cannot drift from it — that is the entire point of the
catch-all construction.
Everything below that line is cosmetic in the sense that letting it go
stale never stores a secret in the clear. It is not cosmetic in the sense of
being optional: -text is what keeps git’s own CRLF conversion off the
ciphertext. Git applies that conversion to the output of the clean filter,
so on a path where some other rule sets text — a user’s own *.env text
line is entirely ordinary — the conversion eats the CR bytes inside the
ciphertext. git add still exits 0, the damaged blob is committed, and the
loss only surfaces at the next checkout as a failed authentication tag, with
the plaintext already gone.
So the rendered lines have to cover exactly the set of paths the filter
encrypts. Neither direction is free: too narrow leaves the hole above, too
broad turns line-ending conversion off for files that are not encrypted at
all. The two syntaxes make that harder than it sounds — see [translate].
Structs§
- Attribute
Resolver - Answers “would git run our filter for this path, and would git convert its line endings”, the way git answers both.
- Culprit
- Where an attribute value came from, in terms a reader can act on.
- Resolution
- What git resolves for one path, on both axes the managed section sets.
- Staged
Attributes - A
.gitattributeswhose working-tree file is gone but whose staged copy git still reads on the check-in path.
Enums§
- Declared
Eol - The
eol=value git resolved, in the only two spellings that decide anything. - EolConversion
- Whether git would run its own end-of-line conversion over stored bytes.
- Filter
Attribute - What git resolves the
filterattribute to for one path. - Rendering
- Spells a pattern so it matches either case of every ASCII letter.
Constants§
- ACCEPTED
- Every spelling of the section this build considers current.
- CATCH_
ALL - The line the filter actually hangs on.
Functions§
- attribute_
files_ under - Every
.gitattributesin the working tree underwork_tree, sorted shallowest first, ties by path. - catch_
all_ present - Whether the attributes file at
pathcarries the catch-all line. - desired
- What the attributes file at
pathshould contain forextra_lines. - driver_
keys - The configuration keys
initwrites, forstatusto check for completeness. - foreign_
lines_ touching - Lines outside the managed section that touch one of
axes. - has_
section - Whether
contentsshows any sign of a managed section. - read
- Reads the attributes file at
path, treating an absent one as empty. - render_
lines - Renders the per-pattern lines for
config. - render_
lines_ as_ written render_linesin whichever spelling the file already uses.- render_
section - Renders the body of the managed section, LF-terminated.
- render_
section_ with - Renders the body of the managed section with a chosen line terminator.
- staged_
fallbacks - The
.gitattributesfiles git would read from the index for check-in. - upsert
- Replaces the managed section in
contents, or appends one. - write_
section - Writes the managed section into the attributes file at
path.