From 5dc1f813ead64ad13edb2b5ed9bd660d198c7ddb Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 1 Jan 2022 16:36:11 +0800 Subject: [PATCH] Fix progress and handling of large of multi-pack index offsets (#279) --- git-pack/src/multi_index/chunk.rs | 4 ++-- git-pack/src/multi_index/write.rs | 1 + gitoxide-core/src/pack/multi_index.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/git-pack/src/multi_index/chunk.rs b/git-pack/src/multi_index/chunk.rs index c089a6b61cf..42a75861983 100644 --- a/git-pack/src/multi_index/chunk.rs +++ b/git-pack/src/multi_index/chunk.rs @@ -243,7 +243,7 @@ pub mod large_offsets { pub(crate) fn write( sorted_entries: &[multi_index::write::Entry], - num_large_offsets: usize, + mut num_large_offsets: usize, mut out: impl std::io::Write, ) -> std::io::Result<()> { for offset in sorted_entries @@ -251,7 +251,7 @@ pub mod large_offsets { .filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then(|| e.pack_offset)) { out.write_u64::(offset)?; - num_large_offsets + num_large_offsets = num_large_offsets .checked_sub(1) .expect("BUG: wrote more offsets the previously found"); } diff --git a/git-pack/src/multi_index/write.rs b/git-pack/src/multi_index/write.rs index a5e158c3d6b..25801b9212b 100644 --- a/git-pack/src/multi_index/write.rs +++ b/git-pack/src/multi_index/write.rs @@ -118,6 +118,7 @@ impl multi_index::File { .then_with(|| l.pack_index.cmp(&r.pack_index)) }); entries.dedup_by_key(|e| e.id); + progress.inc_by(entries.len()); progress.show_throughput(start); if should_interrupt.load(Ordering::Relaxed) { return Err(Error::Interrupted); diff --git a/gitoxide-core/src/pack/multi_index.rs b/gitoxide-core/src/pack/multi_index.rs index 4901ad6f09c..d47807070a3 100644 --- a/gitoxide-core/src/pack/multi_index.rs +++ b/gitoxide-core/src/pack/multi_index.rs @@ -5,7 +5,7 @@ use std::sync::atomic::AtomicBool; use git_repository as git; -pub const PROGRESS_RANGE: std::ops::RangeInclusive = 2..=3; +pub const PROGRESS_RANGE: std::ops::RangeInclusive = 1..=3; pub fn create( index_paths: Vec,