On Sun, Jun 30, 2019 at 10:59:34PM +0200, Johannes Sixt wrote:
> Am 30.06.19 um 21:48 schrieb Eric Sunshine:
> > On Sun, Jun 30, 2019 at 2:57 PM Johannes Sixt <[email protected]> wrote:
> >> diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
> >> @@ -443,7 +443,7 @@ test_expect_success 'repack with minimum size does not
> >> alter existing packs' '
> >> - MINSIZE=$(ls -l .git/objects/pack/*pack | awk "{print
> >> \$5;}" | sort -n | head -n 1) &&
> >> + MINSIZE=$(stat -c %s .git/objects/pack/*pack | sort -n |
> >> head -n 1) &&
> >
> > Unfortunately, this is not portable. While "stat -c %s" works on Linux
> > and MSYS2, neither that option nor the format directive are recognized
> > on BSD-like platforms (I tested Mac OS and FreeBSD), which instead
> > need "stat -f %z".
>
> Ouch! I did notice that stat(1) is not in POSIX, but hoped that it was
> sufficiently portable. I need a new idea...
'wc -c' perhaps? We already use it in a couple of places in the test
suite to get file size.
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index 79bfaeafa9..ddba862114 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -443,7 +443,7 @@ test_expect_success 'repack with minimum size does not
alter existing packs' '
touch -m -t 201901010002 .git/objects/pack/pack-B* &&
touch -m -t 201901010003 .git/objects/pack/pack-A* &&
ls .git/objects/pack >expect &&
- MINSIZE=$(ls -l .git/objects/pack/*pack | awk "{print \$5;}" |
sort -n | head -n 1) &&
+ MINSIZE=$(wc -c .git/objects/pack/*pack | sort -n | sed -n -e
"s/^ *//" -e "1 s/[^ ]*$//p") &&
git multi-pack-index repack --batch-size=$MINSIZE &&
ls .git/objects/pack >actual &&
test_cmp expect actual
@@ -455,7 +455,7 @@ test_expect_success 'repack creates a new pack' '
cd dup &&
ls .git/objects/pack/*idx >idx-list &&
test_line_count = 5 idx-list &&
- THIRD_SMALLEST_SIZE=$(ls -l .git/objects/pack/*pack | awk
"{print \$5;}" | sort -n | head -n 3 | tail -n 1) &&
+ THIRD_SMALLEST_SIZE=$(wc -c .git/objects/pack/*pack | sort -n |
sed -n -e "s/^ *//" -e "3 s/[^ ]*$//p") &&
BATCH_SIZE=$(($THIRD_SMALLEST_SIZE + 1)) &&
git multi-pack-index repack --batch-size=$BATCH_SIZE &&
ls .git/objects/pack/*idx >idx-list &&
Note that 'wc -c' prints the numbers in its output left padded, hence
the 'sed "s/^ *//"' above, and once 'sed' is already up and running,
it might as well take over the role of that 'head -n 3 | tail -n 1'.