From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 22C131F934 for ; Fri, 29 Jan 2021 20:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbhA2UFU (ORCPT ); Fri, 29 Jan 2021 15:05:20 -0500 Received: from cloud.peff.net ([104.130.231.41]:40758 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbhA2UEv (ORCPT ); Fri, 29 Jan 2021 15:04:51 -0500 Received: (qmail 3590 invoked by uid 109); 29 Jan 2021 20:03:45 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 29 Jan 2021 20:03:45 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 8521 invoked by uid 111); 29 Jan 2021 20:04:08 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Fri, 29 Jan 2021 15:04:08 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 29 Jan 2021 15:04:08 -0500 From: Jeff King To: Junio C Hamano Cc: Taylor Blau , git@vger.kernel.org, dstolee@microsoft.com Subject: [PATCH] p5303: avoid sed GNU-ism Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Jan 29, 2021 at 02:32:50PM -0500, Jeff King wrote: > > this construct: > > > > ... | > > sed -n '1~5p' | > > head -n "$1" | > > ... > > > > which is a GNUism. Peff often says that very small population > > actually run our perf suite, and this seems to corroborate the > > conjecture. > > Oops. Looks like I was the one who introduced that. Nobody seems to have > complained, so I'm somewhat tempted to leave it. But it would not be too > hard to replace with perl, I think. Maybe worth doing this? -- >8 -- Subject: [PATCH] p5303: avoid sed GNU-ism Using "1~5" isn't portable. Nobody seems to have noticed, since perhaps people don't tend to run the perf suite on more exotic platforms. Still, it's better to set a good example. We can use: perl -ne 'print if $. % 5 == 1' instead. But we can further observe that perl does a good job of the other parts of this pipeline, and fold the whole thing together. Signed-off-by: Jeff King --- t/perf/p5303-many-packs.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/t/perf/p5303-many-packs.sh b/t/perf/p5303-many-packs.sh index f4c2ab0584..ce0c42cc9f 100755 --- a/t/perf/p5303-many-packs.sh +++ b/t/perf/p5303-many-packs.sh @@ -21,10 +21,14 @@ repack_into_n () { mkdir staging && git rev-list --first-parent HEAD | - sed -n '1~5p' | - head -n "$1" | - perl -e 'print reverse <>' \ - >pushes + perl -e ' + my $n = shift; + while (<>) { + last unless @commits < $n; + push @commits, $_ if $. % 5 == 1; + } + print reverse @commits; + ' "$1" >pushes # create base packfile head -n 1 pushes | -- 2.30.0.759.g69d54d14a7