History

adapt to changes in git-hash (#279)

Sebastian Thiel committed 4 years ago

Commit 5eb02301 parent 79dc0d54 files · +6 −7Browse files

Showing the changes to git-commitgraph/src (3 of 4 files). Show all

Unified · Split

3 files
  1. git-commitgraph/src/file/access.rs +2 −2
  2. git-commitgraph/src/file/commit.rs +1 −1
  3. git-commitgraph/src/file/verify.rs +1 −2
git-commitgraph/src/file/access.rs+2−2
@@ -46,7 +46,7 @@ impl File { · 45 unmodified lines
4646 .try_into()
4747 .expect("an architecture able to hold 32 bits of integer");
4848 let start = self.oid_lookup_offset + (pos * self.hash_len);
49− git_hash::oid::try_from(&self.data[start..][..self.hash_len]).expect("hash bytes to be alright")
49+ git_hash::oid::from_bytes_unchecked(&self.data[start..][..self.hash_len])
5050 }
5151
5252 /// Return an iterator over all object hashes stored in the base graph.
@@ -55,7 +55,7 @@ impl File { · 2 unmodified lines
5555 let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)];
5656 base_graphs_list
5757 .chunks(self.hash_len)
58− .map(|bytes| git_hash::oid::try_from(bytes).expect("hash bytes to be alright"))
58+ .map(|bytes| git_hash::oid::from_bytes_unchecked(bytes))
5959 }
6060
6161 /// return an iterator over all commits in this file.
git-commitgraph/src/file/commit.rs+1−1
@@ -43,7 +43,7 @@ impl<'a> Commit<'a> { · 42 unmodified lines
4343 Commit {
4444 file,
4545 pos,
46− root_tree_id: git_hash::oid::try_from(&bytes[..file.hash_len]).expect("hash bytes to be alright"),
46+ root_tree_id: git_hash::oid::from_bytes_unchecked(&bytes[..file.hash_len]),
4747 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len..][..4])),
4848 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len + 4..][..4])),
4949 generation: BigEndian::read_u32(&bytes[file.hash_len + 8..][..4]) >> 2,
git-commitgraph/src/file/verify.rs+1−2
@@ -65,8 +65,7 @@ pub struct Outcome { · 64 unmodified lines
6565 impl File {
6666 /// Returns the trailing checksum over the entire content of this file.
6767 pub fn checksum(&self) -> &git_hash::oid {
68− git_hash::oid::try_from(&self.data[self.data.len() - self.hash_len..])
69− .expect("file to be large enough for a hash")
68+ git_hash::oid::from_bytes_unchecked(&self.data[self.data.len() - self.hash_len..])
7069 }
7170
7271 /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it.