]> git.ipfire.org Git - thirdparty/git.git/commitdiff
p5303: avoid sed GNU-ism
authorJeff King <peff@peff.net>
Fri, 29 Jan 2021 20:04:08 +0000 (15:04 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jan 2021 23:13:54 +0000 (15:13 -0800)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/perf/p5303-many-packs.sh

index f4c2ab0584707d7930476566882d3124b18e52e5..ce0c42cc9f72d6ff610c5fa0608353beb64fa3df 100755 (executable)
@@ -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 |