diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-04-03 07:06:10 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-04-07 14:47:41 -0700 |
| commit | 88bef8db847ae45a22e5238e324654d72d078a26 (patch) | |
| tree | 7c607cfd323df40f1776221f3eba7043fe158193 | |
| parent | 9f4bce35b399508737e30bb5b22787d86cb5001f (diff) | |
| download | git-88bef8db847ae45a22e5238e324654d72d078a26.tar.xz | |
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rwxr-xr-x | t/t5316-pack-delta-depth.sh | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/t/t5316-pack-delta-depth.sh b/t/t5316-pack-delta-depth.sh index cd947b5a5e..defaa06d65 100755 --- a/t/t5316-pack-delta-depth.sh +++ b/t/t5316-pack-delta-depth.sh @@ -76,18 +76,18 @@ test_expect_success 'create series of packs' ' max_chain() { git index-pack --verify-stat-only "$1" >output && - perl -lne ' - BEGIN { $len = 0 } - /chain length = (\d+)/ and $len = $1; - END { print $len } - ' output + awk ' + BEGIN { len=0 } + /chain length = [0-9]+:/{ len=$4 } + END { print len } + ' <output | tr -d ':' } # Note that this whole setup is pretty reliant on the current # packing heuristics. We double-check that our test case # actually produces a long chain. If it doesn't, it should be # adjusted (or scrapped if the heuristics have become too unreliable) -test_expect_success PERL_TEST_HELPERS 'packing produces a long delta' ' +test_expect_success 'packing produces a long delta' ' # Use --window=0 to make sure we are seeing reused deltas, # not computing a new long chain. 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' ' test_cmp expect actual ' -test_expect_success PERL_TEST_HELPERS '--depth limits depth' ' +test_expect_success '--depth limits depth' ' pack=$(git pack-objects --all --depth=5 </dev/null pack) && echo 5 >expect && max_chain pack-$pack.pack >actual && test_cmp expect actual ' -test_expect_success PERL_TEST_HELPERS '--depth=0 disables deltas' ' +test_expect_success '--depth=0 disables deltas' ' pack=$(git pack-objects --all --depth=0 </dev/null pack) && echo 0 >expect && max_chain pack-$pack.pack >actual && test_cmp expect actual ' -test_expect_success PERL_TEST_HELPERS 'negative depth disables deltas' ' +test_expect_success 'negative depth disables deltas' ' pack=$(git pack-objects --all --depth=-1 </dev/null pack) && echo 0 >expect && max_chain pack-$pack.pack >actual && |
