apply_patch: preserve existing line endings or support CRLF/LF selection
What variant of Codex are you using?
Codex App on native Windows
What feature would you like to see?
Summary
When Codex uses the built-in apply_patch tool to modify an existing CRLF file on native Windows, newly inserted lines are written with LF endings while untouched lines retain CRLF. The resulting file has mixed line endings.
Requested behavior
- Preserve the existing file's dominant line-ending style by default.
- Optionally support an explicit
preserve,crlf, orlfsetting. - For new files, respect repository configuration such as
.gitattributesor.editorconfigwhere possible.
Why this matters
Mixed endings cause Git warnings and Visual Studio normalization prompts. Agents then need a separate whole-file normalization rewrite after every focused patch. Besides being inefficient, that extra rewrite increases the risk of noisy diffs.
Reproduction
- On native Windows, create or open a source file that consistently uses CRLF.
- Ask Codex to make a focused partial edit using its built-in
apply_patchtool. - Inspect the resulting file at the byte level.
- The inserted lines use LF while the pre-existing lines remain CRLF.
Expected behavior
A focused patch should not change or mix the target file's established line endings.
Additional information
Observed repeatedly in a C# repository whose documented convention is CRLF. The current workaround is to normalize every touched file after apply_patch, which requires a second write unrelated to the logical code change.
1 Comment
I have this issue all the time with LLMs on Windows.