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

Re: [PATCH 2/3] Re: mailinfo: allow individual e-mail files as input

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 7, 2009, 01:59 UTC
Message-ID
<Bq46oDu9ypgY1WI5GDyfybM5nluSMTj7VLfPqQH2BjK-xQyDLXAh5Q@cipher.nrlssc.navy.mil>
In-Reply-To
<20090807013650.GE12924@vidovic>
Nicolas Sebrecht wrote:
Show 33 quoted lines
> The 06/08/09, Brandon Casey wrote:
> 
>>  git-am.sh     |   14 ++++++++++++++
>>  t/t4150-am.sh |    2 +-
>>  2 files changed, 15 insertions(+), 1 deletions(-)
>>
>> diff --git a/git-am.sh b/git-am.sh
>> index d64d997..dd60f5d 100755
>> --- a/git-am.sh
>> +++ b/git-am.sh
>> @@ -191,6 +191,20 @@ check_patch_format () {
>>  			esac
>>  			;;
>>  		esac
>> +		if test -z "$patch_format" &&
>> +			test -n "$l1" &&
>> +			test -n "$l2" &&
>> +			test -n "$l3"
>> +		then
>> +			# This begins with three non-empty lines.  Is this a
>> +			# piece of e-mail a-la RFC2822?  Grab all the headers,
>> +			# discarding the indented remainder of folded lines,
>> +			# and see if it looks like that they all begin with the
>> +			# header field names...
>> +			sed -n -e '/^$/q' -e '/^[ 	]/d' -e p "$1" |
>> +			egrep -v '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
>> +			patch_format=mbox
>> +		fi
>>  	} < "$1" || clean_abort
>>  }
> 
> May I ask why you resurrect this "first three lines check for rfc2822"
> instead of dumbly falling back to the "mbox" patch_format? Performance?
This at least checks that the header has the correct form for an email.

The dumb fallback to mbox format would just blindly pass the patch to mailsplit which (I think) would just dump out an improperly formatted email. git-am would then start the process of applying the malformed patch and fail. With this patch, we can catch the failure earlier and hopefully provide a better complaint to the user.

-brandon
Previous: Nicolas SebrechtNext: Junio C Hamano
Message 20 of 24 in “What's in git.git (Aug 2009, #01; Wed, 05)”
  1. Junio C HamanoAug 5, 2009
  2. Brandon CaseyAug 6, 2009
  3. Nicolas SebrechtAug 6, 2009
  4. Nicolas SebrechtAug 6, 2009
  5. 1/3 t4150-am: demonstrate git-am's failure to handle some patch emailsBrandon Casey, Aug 7, 2009
  6. 2/3 mailinfo: allow individual e-mail files as inputBrandon Casey, Aug 7, 2009
  7. 3/3 git-am: print fair error message when format detection failsBrandon Casey, Aug 7, 2009
  8. Jeff KingAug 7, 2009
  9. Brandon CaseyAug 7, 2009
  10. mailinfo: allow individual e-mail files as inputBrandon Casey, Aug 7, 2009
  11. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  12. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  13. Brandon CaseyAug 7, 2009
  14. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  15. Brandon CaseyAug 7, 2009
  16. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  17. Junio C HamanoAug 7, 2009
  18. Brandon CaseyAug 7, 2009
  19. 2/3 Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  20. Brandon CaseyAug 7, 2009
  21. Junio C HamanoAug 7, 2009
  22. Nanako ShiraishiAug 7, 2009
  23. Junio C HamanoAug 7, 2009
  24. Brandon CaseyAug 7, 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.