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
Brandon Casey <drafnel@gmail.com>
Date
Dec 15, 2009, 03:59 UTC
Message-ID
<ee63ef30912141959g2da1bc65y20b9bdb93a2a8d41@mail.gmail.com>
In-Reply-To
<7vfx7d7zpp.fsf@alter.siamese.dyndns.org>
On Mon, Dec 14, 2009 at 8:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Brandon Casey <drafnel@gmail.com> writes:
>
>>> 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.
>>
>> But isn't each email in the mbox file supposed to be RFC-2822 formatted
>> anyway?
>
> If you are talking about the same "mbox" I was talking about, which is
> what I see when I peek "/var/mail/junio", then the answer is no.

Yes, that is what I was talking about, but I did not know whether the individual mails which are separated by "From user@host ..." were supposed to be in RFC-2822 format or not.

> Their lines are terminated with a LF, and if you insert CR at the end of the
> line it would appear as true payload.

How do you insert CR at the end of the line? Can you use mutt or something like it to send a mail which contains a CR? I have tried, and I have not been able to do so. I have tried mutt, mailx, and sendmail. For sendmail, I of course constructed the email headers by hand and piped it through sendmail. The CRLF in my tests were converted to LF by the time they reached /var/mail/casey.

Show 7 quoted lines
> DOSsy boxes can have C:\mail\user
> or whatever that has DOS text, of course, so there is no "supposed to be".
>
> Having said that, it does not matter an iota in the real world if somebody
> declares on _this list_ that it a bug that Thunderbird spits out CRLF text
> in response to "Save As..."  on platforms where LF is the natural line
> terminator [*1*].
I'm not sure it is a bug, just a change in behavior.
> Whether it is a bug or not, we still need to help
> people with such a program without breaking others.
I agree.
Show 5 quoted lines
> I saw "peeking the line ending of the first line" as suggested as a
> solution, and my gut feeling, without thinking too much about it, is
> that it is likely to be the right thing to do, especially if we do
> both the check and the necessary conversion in either mailinfo or even
> in mailsplit.

Yes, I think it will work as a work-around, unfortunately I cannot work on implementing this at the moment. I think the better solution, if it is not too costly, is to detect the presence of CR and produce a binary patch that can be sent through email and applied by git-am.

-brandon
Previous: Junio C HamanoNext: Brandon Casey
Message 16 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.