git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH 2/2] t5333: fix missing terminator for sed(1) 's' command
Date: Tue, 8 Jul 2025 08:44:36 +0200	[thread overview]
Message-ID: <aGy-VBk5nO8UJItZ@pks.im> (raw)
In-Reply-To: <xmqqplec3rka.fsf@gitster.g>

On Mon, Jul 07, 2025 at 09:15:49AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > In 6aec8d38fdd (t: refactor tests depending on Perl to print data,
> > 2025-04-03) we have changed some of the tests in t4150 to use sed(1)
> > instead of Perl. One of the conversions is broken though:
> >
> >     sed: -e expression #1, char 41: unterminated `s' command
> >
> > Curiously enough, the test itself still passes. This is caused by a
> > sequence of failures:
> >
> >   1. The output of sed(1) is piped into git-update-ref(1), and because
> >      sed(1) is the upstream command we don't notice that it fails.
> >
> >   2. git-update-ref(1) does not receive any input and thus won't create
> >      any references.
> >
> >   3. We then repack the repository with the configured pseudo merges
> >      pattern, but as we didn't create any references the pattern doesn't
> >      match anything.
> >
> >   4. We use `test_pseudo_merges()` to compute the list of pseudo-merges
> >      and write it into a file. This file is empty as there are none.
> >
> >   5. The loop over the pseudo-merges becomes a no-op.
> >
> >   6. The final test succeeds as well because the number of lines in an
> >      empty file is obviously the same as the number of unique lines,
> >      namely zero.
> >
> > Fix the issue by adding the terminating '|' to the sed(1) command.
> 
> OK.
> 
> > Furthermore, make the test a tiny bit more robust by not using it as
> > part of a pipe.
> 
> While I do not think it would give us big enough improvement to
> revert this part of the change, I would have liked not to see this
> "furthermore" change.  We are not in the business of catching
> segfault in 'sed' that is supplied by the platform, so there is no
> point in breaking the pipeline here.
> 
> Will queue.  Thanks.

Segfaults not, but if the pipeline was broken up from the beginning we
would have noticed that sed(1) returned an error due to the missing
separator. True though that it doesn't buy us much now that the error is
fixed. It's not like this line of code is likely to change regularly in
the future.

I'll not send a new version of this patch series to get rid of it, but
if I need to resend I'll remove that part.

Thanks!

Patrick

      reply	other threads:[~2025-07-08  6:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07 11:08 [PATCH 0/2] t: fixes for Perl-less tests Patrick Steinhardt
2025-07-07 11:08 ` [PATCH 1/2] t4150: fix warning printed by awk due to escaped '\@' Patrick Steinhardt
2025-07-07 11:08 ` [PATCH 2/2] t5333: fix missing terminator for sed(1) 's' command Patrick Steinhardt
2025-07-07 16:15   ` Junio C Hamano
2025-07-08  6:44     ` Patrick Steinhardt [this message]

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=aGy-VBk5nO8UJItZ@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder.dev@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 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 NNTP newsgroup(s).