History

Adapt to changes in git-chunk (#279)

Sebastian Thiel committed 4 years ago

Commit 44ea5c31 parent dda26a42 files · +14 −13Browse files

Unified · Split

2 files
  1. git-pack/src/multi_index/chunk.rs +6 −6
  2. git-pack/src/multi_index/init.rs +8 −7
git-pack/src/multi_index/chunk.rs+6−6
@@ -1,9 +1,9 @@
1−pub mod pack_names {
1+pub mod index_names {
22 use git_object::bstr::{BString, ByteSlice};
33 use os_str_bytes::OsStrBytes;
44 use std::path::{Path, PathBuf};
55
6− pub const ID: git_chunk::Kind = *b"PNAM";
6+ pub const ID: git_chunk::Id = *b"PNAM";
77
88 pub mod from_slice {
99 use git_object::bstr::BString;
@@ -50,7 +50,7 @@ pub mod pack_names { · 40 unmodified lines
5050 pub mod fanout {
5151 use std::convert::TryInto;
5252
53− pub const ID: git_chunk::Kind = *b"OIDF";
53+ pub const ID: git_chunk::Id = *b"OIDF";
5454
5555 pub fn from_slice(chunk: &[u8]) -> Option<[u32; 256]> {
5656 if chunk.len() != 4 * 256 {
@@ -69,7 +69,7 @@ pub mod lookup { · 12 unmodified lines
6969 use git_hash::Kind;
7070 use std::ops::Range;
7171
72− pub const ID: git_chunk::Kind = *b"OIDL";
72+ pub const ID: git_chunk::Id = *b"OIDL";
7373
7474 pub fn is_valid(offset: &Range<Offset>, hash: git_hash::Kind, num_objects: u32) -> bool {
7575 (offset.end - offset.start) as usize / hash.len_in_bytes() == num_objects as usize
@@ -80,7 +80,7 @@ pub mod offsets { · 4 unmodified lines
8080 use git_chunk::file::Offset;
8181 use std::ops::Range;
8282
83− pub const ID: git_chunk::Kind = *b"OOFF";
83+ pub const ID: git_chunk::Id = *b"OOFF";
8484
8585 pub fn is_valid(offset: &Range<Offset>, num_objects: u32) -> bool {
8686 let entry_size = 4 /* pack-id */ + 4 /* pack-offset */;
@@ -92,7 +92,7 @@ pub mod large_offsets { · 5 unmodified lines
9292 use git_chunk::file::Offset;
9393 use std::ops::Range;
9494
95− pub const ID: git_chunk::Kind = *b"LOFF";
95+ pub const ID: git_chunk::Id = *b"LOFF";
9696 pub fn is_valid(offset: Option<&Range<Offset>>) -> bool {
9797 offset
9898 .map(|offset| (offset.end - offset.start) as usize % 8 == 0)
git-pack/src/multi_index/init.rs+8−7
@@ -29,7 +29,7 @@ mod error { · 28 unmodified lines
2929 #[error("The multi-pack fan doesn't have the correct size of 256 * 4 bytes")]
3030 MultiPackFanSize,
3131 #[error(transparent)]
32− PackNames(#[from] chunk::pack_names::from_slice::Error),
32+ PackNames(#[from] chunk::index_names::from_slice::Error),
3333 #[error("The chunk with alphabetically ordered object ids doesn't have the correct size")]
3434 OidLookupSize,
3535 #[error("The chunk with offsets into the pack doesn't have the correct size")]
@@ -100,22 +100,23 @@ impl TryFrom<&Path> for File { · 64 unmodified lines
100100 };
101101
102102 let chunks = git_chunk::file::Index::from_bytes(&data, HEADER_LEN, num_chunks as u32)?;
103− let pack_names = chunks.data_by_kind(&data, chunk::pack_names::ID)?;
104− let index_names = chunk::pack_names::from_slice(pack_names, num_packs)?;
105103
106− let fan = chunks.data_by_kind(&data, chunk::fanout::ID)?;
104+ let index_names = chunks.data_by_id(&data, chunk::index_names::ID)?;
105+ let index_names = chunk::index_names::from_slice(index_names, num_packs)?;
106+
107+ let fan = chunks.data_by_id(&data, chunk::fanout::ID)?;
107108 let fan = chunk::fanout::from_slice(fan).ok_or(Error::MultiPackFanSize)?;
108109 let num_objects = fan[255];
109110
110− let lookup = chunks.offset_by_kind(chunk::lookup::ID)?;
111+ let lookup = chunks.offset_by_id(chunk::lookup::ID)?;
111112 if !chunk::lookup::is_valid(&lookup, hash_kind, num_objects) {
112113 return Err(Error::OidLookupSize);
113114 }
114− let offsets = chunks.offset_by_kind(chunk::offsets::ID)?;
115+ let offsets = chunks.offset_by_id(chunk::offsets::ID)?;
115116 if !chunk::offsets::is_valid(&offsets, num_objects) {
116117 return Err(Error::OffsetsSize);
117118 }
118− let large_offsets = chunks.offset_by_kind(chunk::large_offsets::ID).ok();
119+ let large_offsets = chunks.offset_by_id(chunk::large_offsets::ID).ok();
119120 if !chunk::large_offsets::is_valid(large_offsets.as_ref()) {
120121 return Err(Error::LargeOffsetsSize);
121122 }