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

Subsystems: the rest

DORMANTno replies

2 messages, 1 author, 2016-06-15 · open the first message on its own page

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

From: Nicolas Sebrecht <hidden>
Date: 2016-06-15 22:47:03

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 <redacted>
---
 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

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

From: Nicolas Sebrecht <hidden>
Date: 2016-06-15 22:47:03

The 16/07/09, Nicolas Sebrecht wrote:
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.
I realized this patch is wrong. Please ignore it.

-- 
Nicolas Sebrecht
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help