Skip to content

Commit f08b6c5

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71ca53e commit f08b6c5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

t/perf/p5303-many-packs.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ repack_into_n () {
2121
mkdir staging &&
2222

2323
git rev-list --first-parent HEAD |
24-
sed -n '1~5p' |
25-
head -n "$1" |
26-
perl -e 'print reverse <>' \
27-
>pushes
24+
perl -e '
25+
my $n = shift;
26+
while (<>) {
27+
last unless @commits < $n;
28+
push @commits, $_ if $. % 5 == 1;
29+
}
30+
print reverse @commits;
31+
' "$1" >pushes
2832

2933
# create base packfile
3034
head -n 1 pushes |

0 commit comments

Comments
 (0)