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;