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
46 .try_into()46 .try_into()
47 .expect("an architecture able to hold 32 bits of integer");47 .expect("an architecture able to hold 32 bits of integer");
48 let start = self.oid_lookup_offset + (pos * self.hash_len);48 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])
50 }50 }
51 51
52 /// Return an iterator over all object hashes stored in the base graph.52 /// Return an iterator over all object hashes stored in the base graph.
@@ -55,7 +55,7 @@ impl File { · 2 unmodified lines
55 let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)];55 let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)];
56 base_graphs_list56 base_graphs_list
57 .chunks(self.hash_len)57 .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))
59 }59 }
60 60
61 /// return an iterator over all commits in this file.61 /// 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
43 Commit {43 Commit {
44 file,44 file,
45 pos,45 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]),
47 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len..][..4])),47 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len..][..4])),
48 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len + 4..][..4])),48 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len + 4..][..4])),
49 generation: BigEndian::read_u32(&bytes[file.hash_len + 8..][..4]) >> 2,49 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
65impl File {65impl File {
66 /// Returns the trailing checksum over the entire content of this file.66 /// Returns the trailing checksum over the entire content of this file.
67 pub fn checksum(&self) -> &git_hash::oid {67 pub fn checksum(&self) -> &git_hash::oid {
68 git_hash::oid::try_from(&self.data[self.data.len() - self.hash_len..])68 git_hash::oid::from_bytes_unchecked(&self.data[self.data.len() - self.hash_len..])
69 .expect("file to be large enough for a hash")
70 }69 }
71 70
72 /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it.71 /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it.