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

[PATCH v3] Re: git-am: fix maildir support regression: accept email file as patch

From
NSNicolas Sebrecht <nicolas.s.dev@gmx.fr>
Date
Jul 16, 2009, 00:49 UTC
Message-ID
<20090716004952.GB12971@vidovic>
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).
Show 12 quoted lines
>     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
Show 12 quoted lines
> 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
Previous: Nicolas SebrechtNext: Junio C Hamano
Message 9 of 26 in “git-am: fix maildir support regression: accept email file as patch”
  1. git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 15, 2009
  2. Re: git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 15, 2009
  3. Junio C HamanoJul 15, 2009
  4. Junio C HamanoJul 15, 2009
  5. Re: git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 16, 2009
  6. Re: git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 16, 2009
  7. Junio C HamanoJul 16, 2009
  8. Re: git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 16, 2009
  9. Re: git-am: fix maildir support regression: accept email file as patchNicolas Sebrecht, Jul 16, 2009
  10. Junio C HamanoJul 16, 2009
  11. git-am: allow e-mail file(s) as inputNicolas Sebrecht, Jul 16, 2009
  12. Re: git-am: allow e-mail file(s) as inputNicolas Sebrecht, Jul 16, 2009
  13. git-am: allow e-mail file(s) as inputNicolas Sebrecht, Jul 16, 2009
  14. Stephen BoydJul 16, 2009
  15. Junio C HamanoJul 16, 2009
  16. Re: git-am: allow e-mail file(s) as inputNicolas Sebrecht, Jul 16, 2009
  17. Re: git-am: allow e-mail file(s) as inputNicolas Sebrecht, Jul 16, 2009
  18. Johannes SixtJul 16, 2009
  19. Johannes SixtJul 16, 2009
  20. mailinfo: allow e-mail files as inputNicolas Sebrecht, Jul 16, 2009
  21. Junio C HamanoJul 17, 2009
  22. Re: mailinfo: allow e-mail files as inputNicolas Sebrecht, Jul 17, 2009
  23. Nanako ShiraishiJul 17, 2009
  24. Junio C HamanoJul 17, 2009
  25. Re: mailinfo: allow e-mail files as inputNicolas Sebrecht, Jul 17, 2009
  26. mailinfo: allow e-mail files as inputNicolas Sebrecht, Aug 6, 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.