git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Shourya Shukla <shouryashukla.oo@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git List <git@vger.kernel.org>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 2/3] t6025: replace pipe with redirection operator
Date: Fri, 17 Jan 2020 16:24:36 -0500	[thread overview]
Message-ID: <CAPig+cQX=jB1KTKcOMVE9u0jX-ZXt_vQBndkzqqQWORu5iFxeA@mail.gmail.com> (raw)
In-Reply-To: <20200117204426.9347-3-shouryashukla.oo@gmail.com>

On Fri, Jan 17, 2020 at 3:45 PM Shourya Shukla
<shouryashukla.oo@gmail.com> wrote:
> The exit code of pipes(|) are always ignored, which will create
> errors in subsequent statements. Let's handle it by redirecting
> its output to a file and capturing return values. Replace pipe
> with redirect(>) operator.

This is not an accurate description. The proper way to explain this is
that exit code of a command upstream of a pipe is lost; the exit code
of a command downstream is not lost. We don't want to lose the exit
code of a git command, so a git command should not be upstream. (We
don't care about non-git commands being upstream when that command's
exit code is not relevant.)

> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
> ---
> diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh
> @@ -17,14 +17,13 @@ test_expect_success 'setup' '
>         git commit -m initial &&
>         git branch b-symlink &&
>         git branch b-file &&
> -       l=$(printf file | git hash-object -t blob -w --stdin) &&

This command is fine as-is. We are interested in the exit code of the
git command (which is correctly downstream), and we don't care about
the exit code of 'printf' (which is upstream), so there is no reason
to rewrite this to use temporary files instead.

> +       printf file >file &&
> +       l=$(git hash-object -t blob -w --stdin) &&

Sorry, but this just doesn't make sense. You're telling "git
hash-object" to take its input from the standard input stream, yet you
don't feed anything to it on that stream. If anything, it should have
been written like this:

     l=$(git hash-object -t blob -w --stdin <file) &&

however, as noted above, there is no reason to avoid pipes in this
case, so this rewrite is unnecessary.

By the way, it's hard to imagine that this test passed once this
change was made (and, if it did pass, then that would likely indicate
that the test is somehow flawed.)

  reply	other threads:[~2020-01-17 21:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16 20:36 [PATCH 0/3] t6025: updating tests Shourya Shukla
2020-01-16 20:36 ` [PATCH 1/3] t6025: modernize style Shourya Shukla
2020-01-16 21:42   ` Johannes Schindelin
2020-01-16 20:36 ` [PATCH 2/3] t6025: replace pipe with redirection operator Shourya Shukla
2020-01-16 22:57   ` Junio C Hamano
2020-01-16 20:36 ` [PATCH 3/3] t6025: use helpers to replace test -f <path> Shourya Shukla
2020-01-16 22:58   ` Junio C Hamano
2020-01-17 20:44     ` [PATCH 0/3] t6025: amended changes after suggestions from the community Shourya Shukla
2020-01-17 20:44       ` [PATCH 1/3] t6025: modernize style Shourya Shukla
2020-01-17 21:15         ` Eric Sunshine
2020-01-17 21:28           ` Junio C Hamano
2020-01-17 20:44       ` [PATCH 2/3] t6025: replace pipe with redirection operator Shourya Shukla
2020-01-17 21:24         ` Eric Sunshine [this message]
2020-01-18  8:33           ` [PATCH 0/3] t6025: updating tests Shourya Shukla
2020-01-18  8:33             ` [PATCH 1/3] t6025: modernize style Shourya Shukla
2020-01-18  8:33             ` [PATCH 2/3] t6025: replace pipe with redirection operator Shourya Shukla
2020-01-18  8:33             ` [PATCH 3/3] t6025: use helpers to replace test -f <path> Shourya Shukla
2020-01-18  8:33             ` [PATCH v3 0/2] t025: amended changes after suggestions from the community Shourya Shukla
2020-01-18  8:33             ` [PATCH v3 1/2] t6025: modernize style Shourya Shukla
2020-01-21 21:57               ` Junio C Hamano
2020-01-18  8:33             ` [PATCH v3 2/2] t6025: use helpers to replace test -f <path> Shourya Shukla
2020-01-21 21:58               ` Junio C Hamano
2020-01-17 20:44       ` [PATCH 3/3] " Shourya Shukla
2020-01-16 21:46 ` [PATCH 0/3] t6025: updating tests Johannes Schindelin

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='CAPig+cQX=jB1KTKcOMVE9u0jX-ZXt_vQBndkzqqQWORu5iFxeA@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=shouryashukla.oo@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.
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).