git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] Git does not convert CRLF=>LF on files with \r not before \n

From
Alexandre Garnier <zigarn@gmail.com>
Date
Apr 21, 2015, 13:51 UTC
Message-ID
<CAFFOgCUTxnbL7vJpf1Hw39CJL_p2raDZ2a3DehhYhdbkVyi2fw@mail.gmail.com>
Here is a test:

git init -q crlf-test cd crlf-test echo '* text=auto' > .gitattributes git add .gitattributes git commit -q -m "Normalize EOL" echo -ne 'some content\r\nother \rcontent with CR\r\ncontent\r\nagain content with\r\r\n' > inline-cr.txt echo "Working directory content:" cat -A inline-cr.txt echo git add inline-cr.txt echo "Indexed content:" git show :inline-cr.txt | cat -A

Result ------ File content: some content^M$ other ^Mcontent with CR^M$ content^M$ again content with^M^M$

Indexed content: some content^M$ other ^Mcontent with CR^M$ content^M$ again content with^M^M$

Expected result --------------- File content: some content^M$ other ^Mcontent with CR^M$ content^M$ again content with^M^M$

Indexed content: some content$ other ^Mcontent with CR$ content$ again content with^M$ # or even 'again content with$' for this last line

If you remove the \r that are not at the end of the lines, EOL are converted as expected: File content: some content^M$ other content with CR^M$ content^M$ again content with^M$

Indexed content: some content$ other content with CR$ content$ again content with$

-- 
Alex
Next: Junio C Hamano
Message 1 of 5 in “[BUG] Git does not convert CRLF=>LF on files with \r not before \n”
  1. Alexandre GarnierApr 21, 2015
  2. Junio C HamanoApr 21, 2015
  3. Torsten BögershausenApr 21, 2015
  4. Alexandre GarnierApr 22, 2015
  5. Junio C HamanoApr 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.