Browse Source

gitoxide-core:pack-verify: be explicit about pack-cache choice in relation to algorithm

Only when doing less-memory the pack cache is even used.
pull/68/head
Sebastian Thiel 1 month ago
parent
commit
e7971a924d
No known key found for this signature in database GPG Key ID: 9CB5EE7895E8268B
  1. 16
      gitoxide-core/src/pack/verify.rs
  2. 7
      tests/stateless-journey.sh

16
gitoxide-core/src/pack/verify.rs

@ -71,7 +71,6 @@ impl Default for Context<Vec<u8>, Vec<u8>> {
}
}
#[allow(clippy::large_enum_variant)]
enum EitherCache<const SIZE: usize> {
Left(pack::cache::Noop),
Right(pack::cache::lru::StaticLinkedList<SIZE>),
@ -137,12 +136,17 @@ where
e
})
.ok();
let cache = || -> EitherCache<64> {
if output_statistics.is_some() {
// turn off acceleration as we need to see entire chains all the time
EitherCache::Left(pack::cache::Noop)
const CACHE_SIZE: usize = 64;
let cache = || -> EitherCache<CACHE_SIZE> {
if matches!(algorithm, Algorithm::LessMemory) {
if output_statistics.is_some() {
// turn off acceleration as we need to see entire chains all the time
EitherCache::Left(pack::cache::Noop)
} else {
EitherCache::Right(pack::cache::lru::StaticLinkedList::<CACHE_SIZE>::default())
}
} else {
EitherCache::Right(pack::cache::lru::StaticLinkedList::<64>::default())
EitherCache::Left(pack::cache::Noop)
}
};

7
tests/stateless-journey.sh

@ -544,6 +544,13 @@ snapshot="$snapshot/plumbing"
WITH_SNAPSHOT="$snapshot/index-with-statistics-success" \
expect_run $SUCCESSFULLY "$exe_plumbing" pack-verify --statistics "$PACK_INDEX_FILE"
}
(with "and the less-memory algorithm"
it "verifies the pack index successfully and with desired output" && {
WITH_SNAPSHOT="$snapshot/index-with-statistics-success" \
expect_run $SUCCESSFULLY "$exe_plumbing" pack-verify --algorithm less-memory --statistics "$PACK_INDEX_FILE"
}
)
)
(with "decode"
it "verifies the pack index successfully and with desired output, and decodes all objects" && {

Loading…
Cancel
Save