Skip to content

Commit

Permalink
Fix progress and handling of large of multi-pack index offsets (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 1, 2022
1 parent 89428b2 commit 5dc1f81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions git-pack/src/multi_index/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ 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
.iter()
.filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then(|| e.pack_offset))
{
out.write_u64::<BigEndian>(offset)?;
num_large_offsets
num_large_offsets = num_large_offsets
.checked_sub(1)
.expect("BUG: wrote more offsets the previously found");
}
Expand Down
1 change: 1 addition & 0 deletions git-pack/src/multi_index/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/multi_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::atomic::AtomicBool;

use git_repository as git;

pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 2..=3;
pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;

pub fn create(
index_paths: Vec<PathBuf>,
Expand Down

0 comments on commit 5dc1f81

Please sign in to comment.