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

[PATCH v2] git-am: fix maildir support regression for unordered headers in emails

From
NSNicolas Sebrecht <nicolas.s.dev@gmx.fr>
Date
Jul 15, 2009, 05:52 UTC
Message-ID
<2433101adeafddeab78815083446552ff3ea9f49.1247636959.git.nicolas.s.dev@gmx.fr>
In-Reply-To
<20090714122354.GA13806@vidovic>

Patch format detection introduced by a5a6755a1d4707bf2fab7752e5c974ebf63d086a may refuse valid patches from verbatim emails.

Emails may have header fields in a random order.
Signed-off-by: Nicolas Sebrecht <nicolas.s.dev@gmx.fr>
---
 git-am.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index d64d997..18e53d0 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -146,6 +146,7 @@ clean_abort () {
 }
 
 patch_format=
+is_verbatim_email=
 
 check_patch_format () {
 	# early return if patch_format was set from the command line
@@ -191,6 +192,15 @@ check_patch_format () {
 			esac
 			;;
 		esac
+		# Keep maildir workflows support.
+		# Verbatim emails may have header fields in random order.
+		is_verbatim_email='true'
+		for line in "$l1" "$l2" "$l3"; do
+			printf "$line" | grep --quiet --extended-regexp '^([^\ ])+: +.*' ||
+				is_verbatim_email='false'
+		done
+		# next treatments don't differ from mailbox format
+		[[ $is_verbatim_email == 'true' ]] && patch_format=mbox
 	} < "$1" || clean_abort
 }
 
-- 
1.6.4.rc0.129.gf738
Previous: Nicolas SebrechtNext: Junio C Hamano
Message 7 of 10 in “git-am: less strong format "mbox" detection”
  1. git-am: less strong format "mbox" detectionNicolas Sebrecht, Jul 14, 2009
  2. Giuseppe BilottaJul 14, 2009
  3. Re: git-am: less strong format "mbox" detectionNicolas Sebrecht, Jul 14, 2009
  4. Johannes SixtJul 14, 2009
  5. Junio C HamanoJul 14, 2009
  6. Re: git-am: less strong format "mbox" detectionNicolas Sebrecht, Jul 14, 2009
  7. git-am: fix maildir support regression for unordered headers in emailsNicolas Sebrecht, Jul 15, 2009
  8. Junio C HamanoJul 15, 2009
  9. Derek FawcusJul 15, 2009
  10. Re: git-am: fix maildir support regression for unordered headers in emailsNicolas Sebrecht, Jul 15, 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.