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
BCBrandon Casey <brandon.casey.ctr@nrlssc.navy.mil>
Date
Dec 14, 2009, 22:56 UTC
Message-ID
<tCQlJn153g8Oa6Z9HKe6xOUQJdcf2PCIVthlTrLgYE-wJ5jFyXVXWw@cipher.nrlssc.navy.mil>
In-Reply-To
<7vvdg9i9mn.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 15 quoted lines
> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> 
>> Commit c2ca1d7 "Allow mailsplit ... to handle mails with CRLF line-endings"
>> seems to be responsible.
> 
> Yes, that commit is not only responsible but was deliberate.  For a better
> backstory, see:
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/124718/focus=124721
> 
> You'd notice that I was one of the people who didn't want to have this
> change, so you don't need to convince _me_ that this was not a change to
> keep everybody happy, but you'd need to try a better job than I did back
> then to convince people who thought that "am" should directly work on
> "Thunderbird saved mails" that what they want was a bad idea X-<.

My understanding of the problem is that rfc2822 dictates that CRLF is the line ending in an email message for _every_ line, and that CR cannot occur without LF and vice versa. So there is no reliable way to extract patches from the body of an email and expect line endings to be conveyed accurately. Some email clients save emails with the line-endings of the platform, some save in what they call "raw" format with rfc2822's CRLF line endings. So we have to _assume_ that the patch extracted from the email has a particular line ending and make-it-so. For better or worse (better for me), commit c2ca1d7 chose LF line-endings as the line-ending of choice.

I agree that git-am should be able to apply everything that git-format-patch produces. Perhaps the diff machinery should be modified to treat files containing \r as binary when generating the output for format-patch. Then we'd get a binary diff in the email.

-brandon
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.