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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 21, 2015, 17:41 UTC
Message-ID
<xmqq1tjdidle.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAFFOgCUTxnbL7vJpf1Hw39CJL_p2raDZ2a3DehhYhdbkVyi2fw@mail.gmail.com>
Alexandre Garnier <zigarn@gmail.com> writes:
> 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

With text=auto, the user instructs us to guess, and we expect either LF or CRLF line-terminated files that is *TEXT*. A lone CR in the middle of the line would mean we cannot reliably guess---it may be LF terminated file with CRs sprinkled inside text, some of which happen to be at the end of the line, or it may be CRLF terminated file with CRs sprinkled in. We try to preserve the user input by not munging when we are not sure.

You are seeing the designed and intended behaviour.

But it would be a bug if the same thing happens when the user explicitly tells us that the file has CRLF line endings, and I suspect we have that bug, which may want to be corrected.

I've Cc'ed various people who worked on convert.c around line endings. I recall we saw a few other discussion threads on text=auto and eol settings. Stakeholders may want to have a unified discussion to first list the issues in the current implementation and come up with fixes for them.

Thanks.
Previous: Alexandre GarnierNext: Torsten Bögershausen
Message 2 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.