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

Re: Please make git-am handle \r\n-damaged patches

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 4, 2009, 06:46 UTC
Message-ID
<7v7hxk5b4y.fsf@alter.siamese.dyndns.org>
In-Reply-To
<81b0412b0908032335s3363849aj32a0e93efa15c012@mail.gmail.com>
Alex Riesen <raa.lkml@gmail.com> writes:
> Maybe it is as simple as that (not tested yet,
> and sent through gmail, so please be careful):

I thought about this approach, but it made me worried about a case where an otherwise sane piece of e-mail has \r at the end of one line as the real payload. But as long as we are talking about a text e-mail (and we are talking about mailsplit here and a binary payload with a CTE applied counts as text), I think we can safely use an approach like this.

Show 14 quoted lines
>
> diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
> index ad5f6b5..02c1c92 100644
> --- a/builtin-mailsplit.c
> +++ b/builtin-mailsplit.c
> @@ -58,6 +58,8 @@ int read_line_with_nul(char *buf, int size, FILE *in)
>  		if (c == '\n' || len + 1 >= size)
>  			break;
>  	}
> +	if (len && buf[len - 1] == '\r')
> +		--len;
>  	buf[len] = '\0';
>
>  	return len;
Previous: Alex RiesenNext: Alex Riesen
Message 10 of 33 in “Please make git-am handle \r\n-damaged patches”
  1. H. Peter AnvinAug 3, 2009
  2. Junio C HamanoAug 3, 2009
  3. Wesley J. LandakerAug 3, 2009
  4. H. Peter AnvinAug 3, 2009
  5. H. Peter AnvinAug 3, 2009
  6. Sverre RabbelierAug 3, 2009
  7. H. Peter AnvinAug 3, 2009
  8. Paolo BonziniAug 4, 2009
  9. Alex RiesenAug 4, 2009
  10. Junio C HamanoAug 4, 2009
  11. Let mailsplit and mailinfo handle mails with CRLF line-endingsAlex Riesen, Aug 4, 2009
  12. Sverre RabbelierAug 4, 2009
  13. Brandon CaseyAug 4, 2009
  14. Alex RiesenAug 4, 2009
  15. Let mailsplit and mailinfo handle mails with CRLF line-endingsAlex Riesen, Aug 4, 2009
  16. Brandon CaseyAug 4, 2009
  17. Brandon CaseyAug 4, 2009
  18. Alex RiesenAug 4, 2009
  19. Alex RiesenAug 4, 2009
  20. Alex RiesenAug 4, 2009
  21. Brandon CaseyAug 4, 2009
  22. Erik Faye-LundAug 4, 2009
  23. Alex RiesenAug 4, 2009
  24. Erik Faye-LundAug 4, 2009
  25. Tony FinchAug 5, 2009
  26. Nanako ShiraishiAug 4, 2009
  27. Junio C HamanoAug 4, 2009
  28. 0/4 Re: Please make git-am handle \r\n-damaged patchesBrandon Casey, Aug 5, 2009
  29. 1/4 strbuf: add new function strbuf_getwholeline()Brandon Casey, Aug 5, 2009
  30. 2/4 builtin-mailinfo,builtin-mailsplit: use strbufsBrandon Casey, Aug 5, 2009
  31. 3/4 builtin-mailsplit.c: remove read_line_with_nul() since it is no longer usedBrandon Casey, Aug 5, 2009
  32. 4/4 Allow mailsplit (and hence git-am) to handle mails with CRLF line-endingsBrandon Casey, Aug 5, 2009
  33. Alex RiesenAug 5, 2009

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.