From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff King Subject: Re: [PATCH] git-format-patch, git-send-email: generate/handle escaped >From Date: Thu, 11 Jun 2009 06:55:39 -0400 Message-ID: <20090611105538.GA4409@coredump.intra.peff.net> References: <1244714434-20794-1-git-send-email-bonzini@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: git@vger.kernel.org To: Paolo Bonzini X-From: git-owner@vger.kernel.org Thu Jun 11 12:56:00 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MEhwt-0008Hi-Es for gcvg-git-2@gmane.org; Thu, 11 Jun 2009 12:55:59 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932294AbZFKKzq (ORCPT ); Thu, 11 Jun 2009 06:55:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761770AbZFKKzq (ORCPT ); Thu, 11 Jun 2009 06:55:46 -0400 Received: from peff.net ([208.65.91.99]:38629 "EHLO peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760199AbZFKKzp (ORCPT ); Thu, 11 Jun 2009 06:55:45 -0400 Received: (qmail 9065 invoked by uid 107); 11 Jun 2009 10:55:57 -0000 Received: from coredump.intra.peff.net (HELO coredump.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.40) with (AES128-SHA encrypted) SMTP; Thu, 11 Jun 2009 06:55:57 -0400 Received: by coredump.intra.peff.net (sSMTP sendmail emulation); Thu, 11 Jun 2009 06:55:39 -0400 Content-Disposition: inline In-Reply-To: <1244714434-20794-1-git-send-email-bonzini@gnu.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Thu, Jun 11, 2009 at 12:00:34PM +0200, Paolo Bonzini wrote: > I noticed that the mbox files generated by git-format-patch (especially > with --stdout) are not proper in the sense that the lines starting with > "From " are not escaped with a > sign. This is unlikely to cause problems > with mail clients such as mutt, but many scripts designed to work on > mbox files will fumble in this case. > > This patch fixes it and dually unescapes the lines in git-send-email. Ugh. Can we please at least make this optional? Many modern MTAs handle the current situation just fine by being much more strict in their "From" matching (i.e., you would need something that really looks like a valid "From" line to get a match), and do not do ">From" de-quoting at all (mutt is such an example). Some even take it a step farther and use Content-Length headers, though I do not think that is a good idea here (we encourage people to munge the contents while stored as an mbox). > +++ b/pretty.c > @@ -868,6 +868,8 @@ void pp_remainder(enum cmit_fmt fmt, > memset(sb->buf + sb->len, ' ', indent); > strbuf_setlen(sb, sb->len + indent); > } > + if (fmt == CMIT_FMT_EMAIL && !prefixcmp(line, "From ")) > + strbuf_addch(sb, '>'); This is the lossy "mboxo" conversion. A quoted From is now indistinguishable from an original ">From". To be reversible, you need to quote "s/^>*From />&/". But of course, which conversion you want depends entirely on what you are going to feed it to, and which mbox they are expecting. Which is why it really should be configurable. Your use case looks to be feeding it to send-email; I suspect you would be better served by improving the 'From ' detection in send-email, probably to something like: /^From \S+ \w{3} \w{3} \d+ \d\d:\d\d:\d\d \d+/ though that may be too strict. It would probably make sense to steal one from one of the many mbox-reading CPAN modules. -Peff