git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Sebrecht <nicolas.s.dev@gmx.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: Nicolas Sebrecht <nicolas.s.dev@gmx.fr>,
	git@vger.kernel.org,
	Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Subject: [PATCH v3] Re: git-am: fix maildir support regression: accept email file as patch
Date: Thu, 16 Jul 2009 02:49:52 +0200	[thread overview]
Message-ID: <20090716004952.GB12971@vidovic> (raw)
In-Reply-To: <7v1voheevy.fsf@alter.siamese.dyndns.org>

The 15/07/09, Junio C Hamano wrote:

> I think you did not understand the point of the three liner I sent you.
> 
> 	sed -e '/^$/q' -e '/^[ 	]/d' "$1" |

I'll change it to

 	sed -e '/^$/q' -e '/^[[:blank:]]/d' "$1" |

to conform to reality (and the paragraph 3.4.2 of the RFC 822).

>     The point of this is not to use the silly "we only look at the first
>     three lines" rule.  Instead, it ignores these l1/l2/l3, but grabs all
>     the header lines, but discards second and subsequent physical lines if
>     a logical line was folded.  Which means that the effect of this is to
>     pipe the whole header (again, without worrying about the indented
>     remainder of folded lines) to downsream, which is the grep -v below
> 
>         grep -v -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
>
>     This checks if there is a line that does _NOT_ match the usual
>     e-mail header pattern.  If there is such a line, it means that the
>     file is not an e-mail message.  If there is no such line, we say...

I don't see the reason to have the option -v. It's only related to
what's printed to output and doesn't change the exit status which
tell us if an expression has matched.

This gives:

   grep -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null &&
   patch_format=mbox

> One caveat is that the above logic alone won't catch a random file that
> does not have _any_ e-mail headers in it.  So you might need to do
> something like:
> 
> 	LF='
>         '
> 	case "$l1$LF$l2$LF$l3" in
>         *"$LF$LF"*)
>         	# has a completely empty line in there?
>                 # that means the message has only two headers at most;
>                 # that cannot be an email.
> 		;;

I think we can strip this part. The purpose is to accept what _may_ be a
patch. Any wrong patch or random file will be rejected later.

-- 
Nicolas Sebrecht

  parent reply	other threads:[~2009-07-16  0:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-15 22:19 [PATCH v3] git-am: fix maildir support regression: accept email file as patch Nicolas Sebrecht
2009-07-15 22:43 ` [PATCH v3] " Nicolas Sebrecht
2009-07-15 22:54 ` [PATCH v3] " Junio C Hamano
2009-07-15 23:56   ` Junio C Hamano
2009-07-16  1:00     ` [PATCH v3] " Nicolas Sebrecht
2009-07-16  2:06       ` Nicolas Sebrecht
2009-07-16  2:30       ` Junio C Hamano
2009-07-16  2:59         ` Nicolas Sebrecht
2009-07-16  0:49   ` Nicolas Sebrecht [this message]
2009-07-16  2:41     ` Junio C Hamano
2009-07-16  4:05       ` [PATCH v4] git-am: allow e-mail file(s) as input Nicolas Sebrecht
2009-07-16  4:10         ` [PATCH v4] " Nicolas Sebrecht
2009-07-16  5:23       ` [PATCH v5] " Nicolas Sebrecht
2009-07-16  7:09         ` Stephen Boyd
2009-07-16  7:24           ` Junio C Hamano
2009-07-16  7:50             ` [PATCH v5] " Nicolas Sebrecht
2009-07-16  8:06               ` Nicolas Sebrecht
2009-07-16  8:17                 ` Johannes Sixt
2009-07-16  8:12               ` Johannes Sixt
2009-07-16 17:45             ` [PATCH v6] mailinfo: allow e-mail files " Nicolas Sebrecht
2009-07-17  1:05               ` Junio C Hamano
2009-07-17  2:20                 ` [PATCH v6] " Nicolas Sebrecht
2009-07-17 10:06               ` [PATCH v6] " Nanako Shiraishi
2009-07-17 19:54                 ` Junio C Hamano
2009-07-17 22:04                   ` [PATCH v6] " Nicolas Sebrecht
2009-08-06 17:07                     ` [PATCH v7] " Nicolas Sebrecht

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

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

  git send-email \
    --in-reply-to=20090716004952.GB12971@vidovic \
    --to=nicolas.s.dev@gmx.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=giuseppe.bilotta@gmail.com \
    /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.
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 NNTP newsgroup(s).