From: Johannes Sixt <j6t@kdbg.org>
To: Stefan Beller <sbeller@google.com>,
Prathamesh Chavan <pc44800@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
Pranit Bauva <pranit.bauva@gmail.com>
Subject: Re: [PATCH] t*: avoid using pipes
Date: Tue, 7 Mar 2017 21:39:39 +0100 [thread overview]
Message-ID: <3026648b-a26c-bc67-62dc-170217d6c2ca@kdbg.org> (raw)
In-Reply-To: <CAGZ79kaYi1OLuOKvbCmDrMCq0fZnO2Ry7JML=Puwmx6TTtEYog@mail.gmail.com>
Am 07.03.2017 um 18:21 schrieb Stefan Beller:
> On Tue, Mar 7, 2017 at 8:10 AM, Prathamesh Chavan <pc44800@gmail.com> wrote:
>> I'm Prathamesh Chavan. As a part of my micropraoject I have been working on
>> "Avoid pipes for git related commands in test suites".
Welcome to the Git community!
> * keep it micro first, e.g. just convert one file,
> send to list, wait for reviewers feedback and incorporate that
> (optional step after having done the full development cycle:
> convert all the other files; each as its own patch)
> * split up this one patch into multiple patches, e.g. one
> file per patch, then send a patch series.
Actually, being a *micro* project, it should stay so. Not doing all of
the changes would leave some tasks for other apprentices to get warm
with our review process.
>> https://github.com/pratham-pc/git/tree/micro-proj
>
> While I did look at that, not everyone here in the git community
> does so. (Also for getting your change in, Junio seems to strongly prefer
> patches on list instead of e.g. fetching and cherry-picking from your
> github)
Thank you, Stefan, for digging out one particularly interesting case.
> When looking at the content, the conversion seems a bit mechanical
> (which is fine for a micro project), such as:
> ...
> - test "$(git show --pretty=format:%s | head -n 1)" = "one"
> + test "$(git show --pretty=format:%s >out && head -n 1 <out)" = "one"
> ...
>
> specifically for the "head" command I don't think it makes a
> difference in correctness whether you pipe the file into the tool
> or give the filename, i.e. "head -n 1 out" would work just as fine.
True, but!
The intent of removing git invocations from the upstream of a pipe is
that a failure exit code is able to stop a && chain.
The example above does not achieve this even after removal of the pipe.
The reason is that exit code of process expansions $(...) is usually
ignored. To meet the intent, further changes are necessary, for example to:
git show --pretty=format:%s >out &&
test "$(head -n 1 out)" = "one"
Side note: There is one exception where the exit code of $(...) is not
ignored: when it occurs in the last variable assignment of a command
that consists only of variable assignments.
-- Hannes
next prev parent reply other threads:[~2017-03-07 20:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 16:10 [PATCH] t*: avoid using pipes Prathamesh Chavan
2017-03-07 17:21 ` Stefan Beller
2017-03-07 20:39 ` Johannes Sixt [this message]
2017-03-07 20:52 ` Stefan Beller
2017-03-08 6:03 ` Jeff King
2017-03-08 13:32 ` Prathamesh Chavan
2017-03-09 5:26 ` Prathamesh Chavan
-- strict thread matches above, loose matches on Subject: below --
2017-03-07 16:18 Prathamesh Chavan
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3026648b-a26c-bc67-62dc-170217d6c2ca@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=pc44800@gmail.com \
--cc=pranit.bauva@gmail.com \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).