Re: [RFC PATCHv3 1/4] am: avoid re-directing stdin twice
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 5, 2014, 22:16 UTC
- Message-ID
- <xmqqk35hpvbg.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <xmqqoautpw1g.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 21 quoted lines
> Also, > >>>> - tr -d '\015' <"$1" | >>>> sed -n -e '/^$/q' -e '/^[ ]/d' -e p | >>>> sane_egrep -v '^[!-9;-~]+:' >/dev/null || >>>> patch_format=mbox > > as the tr is at an upsteam of this pipeline, it does not really > matter to the outcome if it gives a write-error error message or not > (the downstream sane_egrep would have decided, based on the data it > was given, if the payload was mbox format), so... > > An easier workaround may be to update the sed script downstream of > tr. It stops reading as soon as it finished to save cycles, and tr > should know that it does not have to produce any more output. For a > broken tr installation, the sed script could be taught to slurp > everything in the message body (without passing it to downstream > sane_egrep, of course), and your "tr" would not see a broken pipe. > > But that is still a workaround, not a fix, and an expensive one at > that.
Redoing what e3f67d30 (am: fix patch format detection for Thunderbird "Save As" emails, 2010-01-25) tried to do without wasting a fork and a pipe may be a workable improvement.
I see Stephen who wrote the original "Thunderbird save-as" is already on the Cc list. How about doing it this way instead?
git-am.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/git-am.sh b/git-am.sh index ee61a77..9db3846 100755 --- a/git-am.sh +++ b/git-am.sh @@ -250,8 +250,7 @@ check_patch_format () { # discarding the indented remainder of folded lines, # and see if it looks like that they all begin with the # header field names... - tr -d '\015' <"$1" | - sed -n -e '/^$/q' -e '/^[ ]/d' -e p | + sed -n -e '/^$/q' -e '/^\r$/q' -e '/^[ ]/d' -e p <"$1" | sane_egrep -v '^[!-9;-~]+:' >/dev/null || patch_format=mbox fi