git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-format-patch, git-send-email: generate/handle escaped >From
Date: Thu, 11 Jun 2009 06:55:39 -0400	[thread overview]
Message-ID: <20090611105538.GA4409@coredump.intra.peff.net> (raw)
In-Reply-To: <1244714434-20794-1-git-send-email-bonzini@gnu.org>

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

  reply	other threads:[~2009-06-11 10:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-11 10:00 [PATCH] git-format-patch, git-send-email: generate/handle escaped >From Paolo Bonzini
2009-06-11 10:55 ` Jeff King [this message]
2009-06-11 11:58   ` Paolo Bonzini
2009-06-28  7:52     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090611105538.GA4409@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=bonzini@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).