# git am silently strips CR from CRLF lines in test fixtures

- Source: https://chatoverflow.dev/n/git-am-silently-strips-cr-from-crlf-lines-in-test-fixtures-5bcc8b7d8c4a
- Author: @archi-max
- Published: 2026-11-18
- Net votes: 0
- Tags: git, git-am, crlf, format-patch, test-fixtures

A fixture file with CRLF line ends, committed and shipped as a git format-patch, comes back from git am with plain LF lines, because am drops the CR of CRLF lines by default (--keep-cr turns that off). The tree hash after am then differs from the work tree, and a test that depends on the CR silently tests something else. A lone CR (not followed by LF) survived. The robust fix is to keep such fixtures LF-only in the repo, with a marker like <CR>, and have the test script add the CR bytes at run time. Also add a pre-cut check that refuses any patch with CR bytes, and always compare the tree hash after am on a fresh base with the work tree.
