Skip to content

Commit 88bef8d

Browse files
pks-tgitster
authored andcommitted
t5316: refactor max_chain() to not depend on Perl
The `max_chain()` helper function is used to extract the maximum delta chain of a packfile as printed by git-index-pack(1). The script uses Perl to extract that data, but it can be trivially refactored to use awk(1) instead. Refactor the helper accordingly so that we can drop a couple of PERL_TEST_HELPERS prerequisites. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f4bce3 commit 88bef8d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

t/t5316-pack-delta-depth.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ test_expect_success 'create series of packs' '
7676

7777
max_chain() {
7878
git index-pack --verify-stat-only "$1" >output &&
79-
perl -lne '
80-
BEGIN { $len = 0 }
81-
/chain length = (\d+)/ and $len = $1;
82-
END { print $len }
83-
' output
79+
awk '
80+
BEGIN { len=0 }
81+
/chain length = [0-9]+:/{ len=$4 }
82+
END { print len }
83+
' <output | tr -d ':'
8484
}
8585

8686
# Note that this whole setup is pretty reliant on the current
8787
# packing heuristics. We double-check that our test case
8888
# actually produces a long chain. If it doesn't, it should be
8989
# adjusted (or scrapped if the heuristics have become too unreliable)
90-
test_expect_success PERL_TEST_HELPERS 'packing produces a long delta' '
90+
test_expect_success 'packing produces a long delta' '
9191
# Use --window=0 to make sure we are seeing reused deltas,
9292
# not computing a new long chain.
9393
pack=$(git pack-objects --all --window=0 </dev/null pack) &&
@@ -96,21 +96,21 @@ test_expect_success PERL_TEST_HELPERS 'packing produces a long delta' '
9696
test_cmp expect actual
9797
'
9898

99-
test_expect_success PERL_TEST_HELPERS '--depth limits depth' '
99+
test_expect_success '--depth limits depth' '
100100
pack=$(git pack-objects --all --depth=5 </dev/null pack) &&
101101
echo 5 >expect &&
102102
max_chain pack-$pack.pack >actual &&
103103
test_cmp expect actual
104104
'
105105

106-
test_expect_success PERL_TEST_HELPERS '--depth=0 disables deltas' '
106+
test_expect_success '--depth=0 disables deltas' '
107107
pack=$(git pack-objects --all --depth=0 </dev/null pack) &&
108108
echo 0 >expect &&
109109
max_chain pack-$pack.pack >actual &&
110110
test_cmp expect actual
111111
'
112112

113-
test_expect_success PERL_TEST_HELPERS 'negative depth disables deltas' '
113+
test_expect_success 'negative depth disables deltas' '
114114
pack=$(git pack-objects --all --depth=-1 </dev/null pack) &&
115115
echo 0 >expect &&
116116
max_chain pack-$pack.pack >actual &&

0 commit comments

Comments
 (0)