| @@ -92,7 +92,7 @@ impl TryFrom<&Path> for File { · 91 unmodified lines |
| 92 | }; | 92 | }; |
| 93 | ofs += 1; | 93 | ofs += 1; |
| 94 | | 94 | |
| 95 | let hash_kind = match data[ofs] { | 95 | let object_hash = match data[ofs] { |
| 96 | 1 => git_hash::Kind::Sha1, | 96 | 1 => git_hash::Kind::Sha1, |
| 97 | x => { | 97 | x => { |
| 98 | return Err(Error::UnsupportedHashVersion(x)); | 98 | return Err(Error::UnsupportedHashVersion(x)); |
| @@ -113,17 +113,17 @@ impl TryFrom<&Path> for File { · 14 unmodified lines |
| 113 | let base_graphs_list_offset = chunks | 113 | let base_graphs_list_offset = chunks |
| 114 | .validated_usize_offset_by_id(BASE_GRAPHS_LIST_CHUNK_ID, |chunk_range| { | 114 | .validated_usize_offset_by_id(BASE_GRAPHS_LIST_CHUNK_ID, |chunk_range| { |
| 115 | let chunk_size = chunk_range.len(); | 115 | let chunk_size = chunk_range.len(); |
| 116 | if chunk_size % hash_kind.len_in_bytes() != 0 { | 116 | if chunk_size % object_hash.len_in_bytes() != 0 { |
| 117 | return Err(Error::InvalidChunkSize { | 117 | return Err(Error::InvalidChunkSize { |
| 118 | id: BASE_GRAPHS_LIST_CHUNK_ID, | 118 | id: BASE_GRAPHS_LIST_CHUNK_ID, |
| 119 | msg: format!( | 119 | msg: format!( |
| 120 | "chunk size {} is not a multiple of {}", | 120 | "chunk size {} is not a multiple of {}", |
| 121 | chunk_size, | 121 | chunk_size, |
| 122 | hash_kind.len_in_bytes() | 122 | object_hash.len_in_bytes() |
| 123 | ), | 123 | ), |
| 124 | }); | 124 | }); |
| 125 | } | 125 | } |
| 126 | let chunk_base_graph_count: u32 = (chunk_size / hash_kind.len_in_bytes()) | 126 | let chunk_base_graph_count: u32 = (chunk_size / object_hash.len_in_bytes()) |
| 127 | .try_into() | 127 | .try_into() |
| 128 | .expect("base graph count to fit in 32-bits"); | 128 | .expect("base graph count to fit in 32-bits"); |
| 129 | if chunk_base_graph_count != u32::from(base_graph_count) { | 129 | if chunk_base_graph_count != u32::from(base_graph_count) { |
| @@ -141,7 +141,7 @@ impl TryFrom<&Path> for File { · 11 unmodified lines |
| 141 | chunks.validated_usize_offset_by_id(COMMIT_DATA_CHUNK_ID, |chunk_range| { | 141 | chunks.validated_usize_offset_by_id(COMMIT_DATA_CHUNK_ID, |chunk_range| { |
| 142 | let chunk_size = chunk_range.len(); | 142 | let chunk_size = chunk_range.len(); |
| 143 | | 143 | |
| 144 | let entry_size = hash_kind.len_in_bytes() + COMMIT_DATA_ENTRY_SIZE_SANS_HASH; | 144 | let entry_size = object_hash.len_in_bytes() + COMMIT_DATA_ENTRY_SIZE_SANS_HASH; |
| 145 | if chunk_size % entry_size != 0 { | 145 | if chunk_size % entry_size != 0 { |
| 146 | return Err(Error::InvalidChunkSize { | 146 | return Err(Error::InvalidChunkSize { |
| 147 | id: COMMIT_DATA_CHUNK_ID, | 147 | id: COMMIT_DATA_CHUNK_ID, |
| @@ -173,19 +173,19 @@ impl TryFrom<&Path> for File { · 25 unmodified lines |
| 173 | chunks.validated_usize_offset_by_id(OID_LOOKUP_CHUNK_ID, |chunk_range| { | 173 | chunks.validated_usize_offset_by_id(OID_LOOKUP_CHUNK_ID, |chunk_range| { |
| 174 | let chunk_size = chunk_range.len(); | 174 | let chunk_size = chunk_range.len(); |
| 175 | | 175 | |
| 176 | if chunk_size % hash_kind.len_in_bytes() != 0 { | 176 | if chunk_size % object_hash.len_in_bytes() != 0 { |
| 177 | return Err(Error::InvalidChunkSize { | 177 | return Err(Error::InvalidChunkSize { |
| 178 | id: OID_LOOKUP_CHUNK_ID, | 178 | id: OID_LOOKUP_CHUNK_ID, |
| 179 | msg: format!( | 179 | msg: format!( |
| 180 | "chunk size {} is not a multiple of {}", | 180 | "chunk size {} is not a multiple of {}", |
| 181 | chunk_size, | 181 | chunk_size, |
| 182 | hash_kind.len_in_bytes() | 182 | object_hash.len_in_bytes() |
| 183 | ), | 183 | ), |
| 184 | }); | 184 | }); |
| 185 | } | 185 | } |
| 186 | Ok(( | 186 | Ok(( |
| 187 | chunk_range.start, | 187 | chunk_range.start, |
| 188 | (chunk_size / hash_kind.len_in_bytes()) | 188 | (chunk_size / object_hash.len_in_bytes()) |
| 189 | .try_into() | 189 | .try_into() |
| 190 | .expect("number of commits in OIDL chunk to fit in 32 bits"), | 190 | .expect("number of commits in OIDL chunk to fit in 32 bits"), |
| 191 | )) | 191 | )) |
| @@ -194,10 +194,10 @@ impl TryFrom<&Path> for File { · 2 unmodified lines |
| 194 | let extra_edges_list_range = chunks.usize_offset_by_id(EXTENDED_EDGES_LIST_CHUNK_ID).ok(); | 194 | let extra_edges_list_range = chunks.usize_offset_by_id(EXTENDED_EDGES_LIST_CHUNK_ID).ok(); |
| 195 | | 195 | |
| 196 | let trailer = &data[chunks.highest_offset() as usize..]; | 196 | let trailer = &data[chunks.highest_offset() as usize..]; |
| 197 | if trailer.len() != hash_kind.len_in_bytes() { | 197 | if trailer.len() != object_hash.len_in_bytes() { |
| 198 | return Err(Error::Trailer(format!( | 198 | return Err(Error::Trailer(format!( |
| 199 | "Expected commit-graph trailer to contain {} bytes, got {}", | 199 | "Expected commit-graph trailer to contain {} bytes, got {}", |
| 200 | hash_kind.len_in_bytes(), | 200 | object_hash.len_in_bytes(), |
| 201 | trailer.len() | 201 | trailer.len() |
| 202 | ))); | 202 | ))); |
| 203 | } | 203 | } |
| @@ -235,7 +235,8 @@ impl TryFrom<&Path> for File { · 31 unmodified lines |
| 235 | fan, | 235 | fan, |
| 236 | oid_lookup_offset, | 236 | oid_lookup_offset, |
| 237 | path: path.to_owned(), | 237 | path: path.to_owned(), |
| 238 | hash_len: hash_kind.len_in_bytes(), | 238 | hash_len: object_hash.len_in_bytes(), |
| | 239 | object_hash, |
| 239 | }) | 240 | }) |
| 240 | } | 241 | } |
| 241 | } | 242 | } |