git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] git-am: fix maildir support regression: accept email file as patch
@ 2009-07-15 22:19 Nicolas Sebrecht
  2009-07-15 22:43 ` [PATCH v3] " Nicolas Sebrecht
  2009-07-15 22:54 ` [PATCH v3] " Junio C Hamano
  0 siblings, 2 replies; 26+ messages in thread
From: Nicolas Sebrecht @ 2009-07-15 22:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta, Nicolas Sebrecht

Patch format detection introduced by a5a6755a1d4707bf2fab7752e5c974ebf63d086a
may refuse valid patches.

We keep detection on the first three lines. Emails may have:
 - header fields in a random order;
 - folded lines.

Signed-off-by: Nicolas Sebrecht <nicolas.s.dev@gmx.fr>
---
 git-am.sh |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index d64d997..6190297 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -146,6 +146,7 @@ clean_abort () {
 }
 
 patch_format=
+is_email=
 
 check_patch_format () {
 	# early return if patch_format was set from the command line
@@ -191,6 +192,22 @@ check_patch_format () {
 			esac
 			;;
 		esac
+		# Keep maildir workflows support.
+		# Emails may have header fields in random order.
+		is_email='true'
+		for line in "$l1" "$l2" "$l3"
+		do
+			printf "$line" |
+				# The line may be a folded line
+				sed -e '/^$/q' -e '/^[ ]/d' |
+				grep -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
+				is_email='false'
+		done
+		# next treatments don't differ from mailbox format
+		if [ $is_email == 'true' ]
+		then
+			patch_format=mbox
+		fi
 	} < "$1" || clean_abort
 }
 
-- 
1.6.4.rc0.128.g69018

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2009-08-06 17:08 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).