Expand description
Line endings — the part git normally does, which we have to do ourselves.
Git converts on the far side of the filter, so for an encrypted path it would always hit ciphertext rather than content. The conversion therefore moves here, and it moves asymmetrically:
- clean never reads git’s configuration. The same file has to yield the same plaintext on every machine, or the ciphertext differs and determinism dies.
- smudge does read it. That is the one moment where machines are allowed to
differ, and where they should — but only when the configuration asks. Since
2026-08-11 the case where nothing asks writes the stored bytes back
unchanged rather than the platform’s own ending, so two machines differ
because someone chose it and not by default; see
resolve_output.
Whether a file was normalised at all is recorded in the header’s flag bit, so
smudge never has to ask .git-xcrypt — which also removes a real race, since
git does not promise to write .git-xcrypt before the files it filters.
Functions§
- apply
- Applies a resolved line-ending mode to content that was normalised to LF.
- git_
writes_ crlf - Whether git would write
CRLFinto the working tree for a path it converts itself. - looks_
binary - Whether git — and therefore we — would treat this content as binary.
- normalisation_
is_ reversible - Whether the working tree’s own bytes can still be recovered from what
cleanis about to store. - normalise_
to_ lf - Replaces every
CRLFwithLF. - resolve_
output - What the working tree should receive, given the declaration and git’s config.
- should_
normalise - Whether the content should be normalised, given its declared mode.
- to_crlf
- Rewrites LF as CRLF.