Skip to main content

resolve_output

Function resolve_output 

Source
pub fn resolve_output(
    declared: Option<EolMode>,
    autocrlf: Option<&str>,
    eol: Option<&str>,
) -> EolMode
Expand description

What the working tree should receive, given the declaration and git’s config.

The table is measured, not guessed: autocrlf=true yields CRLF and ignores core.eol, autocrlf=input yields LF and ignores it too, and only autocrlf=false lets core.eol decide.

One row deliberately departs from git’s own table, since 2026-08-11: with core.autocrlf false or unset and core.eol unset, this writes the stored bytes back unchanged rather than the platform’s own ending. That is the configuration in which git converts nothing, and until this change declaring a path secret opted it into a conversion the same file would never have received while stored in the clear. Measured on git 2.55, two throwaway repositories, a declared path and an undeclared one holding identical bytes:

configundeclared, git decidesdeclared, we decidedagreed?
autocrlf=trueLF in, CRLF outCRLF outyes
autocrlf=inputCRLF in, LF outLF outyes
autocrlf=false, eol unsetLF in, LF outCRLF outno
autocrlf=false, eol=lfCRLF in, CRLF outLF outno

git status was clean in all four, so nothing signalled either mismatch. The third row is what this arm fixes; the fourth is the check-in half — clean normalises before the header can record which ending was there — and no choice made here can bring that back, so it stays a documented limit rather than a fixed one. What the change does buy for it is that the answer stops depending on the platform: after this, a declared path on Windows and on Linux receives identical bytes unless something explicitly asks otherwise, which is what §Non-Functional Requirements means by no differences across machines.

An explicit core.eol=native still selects the platform’s ending, because that is a user asking for it rather than a default nobody chose, and it is the way back to the previous behaviour without editing .git-xcrypt. So is eol=native on the pattern, which outranks all of this.

Nothing here touches a stored byte: clean never reads configuration, the ciphertext is unchanged, and whatever this writes normalises back to the same plaintext — so the repository stays clean across the change.