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

Re: am fails to apply patches for files with CRLF lineendings

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2009, 23:22 UTC
Message-ID
<7vhbrtdtth.fsf@alter.siamese.dyndns.org>
In-Reply-To
<tCQlJn153g8Oa6Z9HKe6xOUQJdcf2PCIVthlTrLgYE-wJ5jFyXVXWw@cipher.nrlssc.navy.mil>
Brandon Casey <brandon.casey.ctr@nrlssc.navy.mil> writes:
> My understanding of the problem is that rfc2822 dictates that...

I think the fundamental problem is that what MUA uses as the internal storage format doesn't necessarily have to even be RFC-2822, which only specifies what should be on-the-wire. The blamed commit took things too far.

It actually is the norm to use LF as the line terminator in the body text in saved messages (and trailing CR as a true part of the payload), and "am" traditionally used that definition. It is meant to read from "mbox" format to begin with.

Before the blamed commit, "am" took what was given literally, and it treated the trailing CR as part of the payload in a text file, each of whose line is LF terminated. This meant that if you sent and your MUA didn't corrupt, or more importantly if you ran format-patch yourself to produce a patch on content with CRLF line endings and fed it to am without any e-mail involved, your CRLF would have been preserved. So in that sense, unlike what you said in your message, the blamed commit didn't decide that the line termination must be LF. It decided that the line termination does not matter, which is a lot worse.

As long as the use of CR is an internal storage matter and "Save As..." doesn't add extra CR that wasn't in the original contents, I wouldn't say that such a MUA is broken. In the use case that led to the blamed commit, the user is choosing to read directly from the internal storage of MUA, bypassing its "Save As..." interface meant to be used to externalize the messages, and the user is responsible for dealing with the fallout, hence my "dos2unix" suggestion in the original thread.

Probably we should revert that commit, unless somebody comes up with a better solution _or_ somebody convincingly argues that there shouldn't be CRLF in your committed history.

Previous: Brandon CaseyNext: Björn Steinbrink
Message 5 of 18 in “am fails to apply patches for files with CRLF lineendings”
  1. Björn SteinbrinkDec 14, 2009
  2. Junio C HamanoDec 14, 2009
  3. Junio C HamanoDec 14, 2009
  4. Brandon CaseyDec 14, 2009
  5. Junio C HamanoDec 14, 2009
  6. Björn SteinbrinkDec 14, 2009
  7. Jason KingDec 14, 2009
  8. Björn SteinbrinkDec 15, 2009
  9. Andreas SchwabDec 15, 2009
  10. Andreas SchwabDec 16, 2009
  11. Fwd: am fails to apply patches for files with CRLF lineendingsBrandon Casey, Dec 15, 2009
  12. Sverre RabbelierDec 15, 2009
  13. Brandon CaseyDec 15, 2009
  14. Andreas SchwabDec 15, 2009
  15. Junio C HamanoDec 15, 2009
  16. Brandon CaseyDec 15, 2009
  17. Brandon CaseyJan 5, 2010
  18. Jason KingFeb 13, 2010

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.