All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Chris Packham <judge.packham@gmail.com>
Cc: Johannes Sixt <j6t@kdbg.org>, GIT <git@vger.kernel.org>,
	Stephen Boyd <bebarino@gmail.com>
Subject: Re: [RFC PATCHv3 1/4] am: avoid re-directing stdin twice
Date: Fri, 05 Sep 2014 15:00:43 -0700	[thread overview]
Message-ID: <xmqqoautpw1g.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAFOYHZBct1CRA+NumVMvbbuELWTRoGL5FkhBfHD2Wk7QZVe1fA@mail.gmail.com> (Chris Packham's message of "Sat, 6 Sep 2014 09:31:06 +1200")

Chris Packham <judge.packham@gmail.com> writes:

> On Sat, Sep 6, 2014 at 8:26 AM, Johannes Sixt <j6t@kdbg.org> wrote:
>> Am 05.09.2014 12:06, schrieb Chris Packham:
>>> In check_patch_format we feed $1 to a block that attempts to determine
>>> the patch format. Since we've already redirected $1 to stdin there is no
>>> need to redirect it again when we invoke tr. This prevents the following
>>> errors when invoking git am
>>>
>>>   $ git am patch.patch
>>>   tr: write error: Broken pipe
>>>   tr: write error
>>>   Patch format detection failed.
>>> ...
>>
>> I wonder why tr (assuming it is *this* instance of tr) dies with a write
>> error instead of from a SIGPIPE. Is SIGPIPE ignored somewhere and then
>> the tr invocation inherits this "ignore SIGPIPE" setting?
>> ...
> Perhaps putting the tr outside the whole block would be a better solution?

Perhaps fixing the root cause of your (but not other people's) "tr"
failing is the right solution, no?

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.

  reply	other threads:[~2014-09-05 22:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 10:06 [RFC PATCHv3 0/4] am: patch-format Chris Packham
2014-09-05 10:06 ` [RFC PATCHv3 1/4] am: avoid re-directing stdin twice Chris Packham
2014-09-05 20:26   ` Johannes Sixt
2014-09-05 21:31     ` Chris Packham
2014-09-05 22:00       ` Junio C Hamano [this message]
2014-09-05 22:16         ` Junio C Hamano
2014-09-05 22:25           ` Junio C Hamano
2014-09-05 23:18             ` Stephen Boyd
2014-09-06  7:34               ` Junio C Hamano
2014-09-06 12:46                 ` Torsten Bögershausen
2014-09-05 10:06 ` [RFC PATCHv3 2/4] t/am: add test for stgit patch format Chris Packham
2014-09-05 10:06 ` [RFC PATCHv3 3/4] t/am: add tests for hg " Chris Packham
2014-09-05 10:06 ` [RFC PATCHv3 4/4] am: add gitk " Chris Packham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqoautpw1g.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=judge.packham@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.