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

Re: [PATCH v2] Re: mailinfo: allow individual e-mail files as input

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 7, 2009, 02:30 UTC
Message-ID
<kRgAbadymu_kXO_N6eQZL3RZpkCM95QJxM7bDH84bRuxk2kjGYKwjA@cipher.nrlssc.navy.mil>
In-Reply-To
<20090807015238.GF12924@vidovic>
Nicolas Sebrecht wrote:
Show 16 quoted lines
> The 06/08/09, Brandon Casey wrote:
> 
>> diff --git a/git-am.sh b/git-am.sh
>> index d64d997..49f2be4 100755
>> --- a/git-am.sh
>> +++ b/git-am.sh
> 
> <...>
> 
>> +			{
>> +				echo "$l1"
>> +				echo "$l2"
>> +				echo "$l3"
>> +				cat
> 
> UUOC, I guess.

I needed to use google to figure out that UUOC means Useless Use Of Cat, but I think you are mistaken. Rather than trying to explain it, try this with and without 'cat' commented out:

#!/bin/sh
{
    {
        echo "line one"
        echo "line two"
        cat
    } | sed -e 's/$/Q/'
} <<-EOF
This is a line of text
Here is another line of text.
And another
EOF

Hopefully you'll see the parallels to the sequence in git-am.sh and understand that cat was used to send the rest of the email through sed along with the first three lines that were read explicitly. git-am.sh looks more like this:

   {
      read l1
      ...
      {
         echo "$l1"
         ...
         cat
      } | sed ...
   } << "$1"

At least, I thought that is how it looked until I read your other email where you pointed out that "$1" is an argument to sed.

>> +			} | sed -n -e '/^$/q' -e '/^[ 	]/d' -e p "$1" |
>                                                    ^^
> 
> Is it still needed?

Yes. The '/^[ ]/d' portion of the sed statement deletes any lines with leading space or tab. This avoids passing continuation fields to the grep statement which is not designed for them, and so would fail (or match, depending on how you look at it. We used -v with grep).

-brandon
Previous: Junio C HamanoNext: Nicolas Sebrecht
Message 18 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.