History

Remove all public exports of git-hash types in git-object (#63)

Sebastian Thiel committed 5 years ago

Commit accf89d1 parent a3f281660 files · +262 −252Browse files

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

Unified · Split

5 files
  1. git-commitgraph/src/file/access.rs +2 −3
  2. git-commitgraph/src/file/commit.rs +4 −5
  3. git-commitgraph/src/file/verify.rs +15 −10
  4. git-commitgraph/src/graph/init.rs +2 −3
  5. git-commitgraph/src/graph/verify.rs +8 −5
git-commitgraph/src/file/access.rs+2−3
@@ -1,6 +1,5 @@
11 use crate::file::{self, commit::Commit, File, COMMIT_DATA_ENTRY_SIZE};
22 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
3−use git_object::HashKind;
43 use std::{
54 convert::{TryFrom, TryInto},
65 fmt::{Debug, Formatter},
@@ -28,8 +27,8 @@ impl File { · 21 unmodified lines
2827 /// The kind of hash used in this File.
2928 ///
3029 /// Note that it is always conforming to the hash used in the owning repository.
31− pub fn hash_kind(&self) -> HashKind {
32− HashKind::Sha1
30+ pub fn hash_kind(&self) -> git_hash::Kind {
31+ git_hash::Kind::Sha1
3332 }
3433
3534 /// Returns 20 bytes sha1 at the given index in our list of (sorted) sha1 hashes.
git-commitgraph/src/file/commit.rs+4−5
@@ -5,7 +5,6 @@ use crate::{ · 4 unmodified lines
55 };
66 use byteorder::{BigEndian, ByteOrder};
77 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
8−use git_object::owned;
98 use std::{
109 convert::{TryFrom, TryInto},
1110 fmt::{Debug, Formatter},
@@ -17,13 +16,13 @@ use std::{ · 5 unmodified lines
1716 #[allow(missing_docs)]
1817 pub enum Error {
1918 #[error("commit {0}'s extra edges overflows the commit-graph file's extra edges list")]
20− ExtraEdgesListOverflow(owned::Id),
19+ ExtraEdgesListOverflow(git_hash::Id),
2120 #[error("commit {0}'s first parent is an extra edge index, which is invalid")]
22− FirstParentIsExtraEdgeIndex(owned::Id),
21+ FirstParentIsExtraEdgeIndex(git_hash::Id),
2322 #[error("commit {0} has extra edges, but commit-graph file has no extra edges list")]
24− MissingExtraEdgesList(owned::Id),
23+ MissingExtraEdgesList(git_hash::Id),
2524 #[error("commit {0} has a second parent but not a first parent")]
26− SecondParentWithoutFirstParent(owned::Id),
25+ SecondParentWithoutFirstParent(git_hash::Id),
2726 }
2827
2928 // Note that git's commit-graph-format.txt as of v2.28.0 gives an incorrect value 0x0700_0000 for
git-commitgraph/src/file/verify.rs+15−10
@@ -5,7 +5,6 @@ use crate::{ · 4 unmodified lines
55 };
66 use bstr::ByteSlice;
77 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
8−use git_object::owned;
98 use std::{
109 cmp::{max, min},
1110 collections::HashMap,
@@ -20,23 +19,29 @@ pub enum Error<E: std::error::Error + 'static> { · 8 unmodified lines
2019 #[error(transparent)]
2120 Commit(#[from] file::commit::Error),
2221 #[error("commit at file position {pos} has invalid ID {id}")]
23− CommitId { id: owned::Id, pos: file::Position },
22+ CommitId { id: git_hash::Id, pos: file::Position },
2423 #[error("commit at file position {pos} with ID {id} is out of order relative to its predecessor with ID {predecessor_id}")]
2524 CommitsOutOfOrder {
26− id: owned::Id,
25+ id: git_hash::Id,
2726 pos: file::Position,
28− predecessor_id: owned::Id,
27+ predecessor_id: git_hash::Id,
2928 },
3029 #[error("commit-graph filename should be {0}")]
3130 Filename(String),
3231 #[error("commit {id} has invalid generation {generation}")]
33− Generation { generation: u32, id: owned::Id },
32+ Generation { generation: u32, id: git_hash::Id },
3433 #[error("checksum mismatch: expected {expected}, got {actual}")]
35− Mismatch { actual: owned::Id, expected: owned::Id },
34+ Mismatch {
35+ actual: git_hash::Id,
36+ expected: git_hash::Id,
37+ },
3638 #[error("{0}")]
3739 Processor(#[source] E),
3840 #[error("commit {id} has invalid root tree ID {root_tree_id}")]
39− RootTreeId { id: owned::Id, root_tree_id: owned::Id },
41+ RootTreeId {
42+ id: git_hash::Id,
43+ root_tree_id: git_hash::Id,
44+ },
4045 }
4146
4247 /// The positive result of [`File::traverse()`] providing some statistical information.
@@ -137,7 +142,7 @@ impl File { · 94 unmodified lines
137142 /// checksum itself.
138143 ///
139144 /// Return the actual checksum on success or `(actual checksum, expected checksum)` if there is a mismatch.
140− pub fn verify_checksum(&self) -> Result<owned::Id, (owned::Id, owned::Id)> {
145+ pub fn verify_checksum(&self) -> Result<git_hash::Id, (git_hash::Id, git_hash::Id)> {
141146 // Even though we could use git_features::hash::bytes_of_file(…), this would require using our own
142147 // Error type to support io::Error and Mismatch. As we only gain progress, there probably isn't much value
143148 // as these files are usually small enough to process them in less than a second, even for the large ones.
@@ -145,7 +150,7 @@ impl File { · 1 unmodified line
145150 let data_len_without_trailer = self.data.len() - SHA1_SIZE;
146151 let mut hasher = git_features::hash::Sha1::default();
147152 hasher.update(&self.data[..data_len_without_trailer]);
148− let actual = owned::Id::new_sha1(hasher.digest());
153+ let actual = git_hash::Id::new_sha1(hasher.digest());
149154
150155 let expected = self.checksum();
151156 if actual.to_borrowed() == expected {
@@ -167,7 +172,7 @@ fn verify_split_chain_filename_hash( · 15 unmodified lines
167172 .and_then(|filename| filename.to_str())
168173 .and_then(|filename| filename.strip_suffix(".graph"))
169174 .and_then(|stem| stem.strip_prefix("graph-"))
170− .map_or(Ok(()), |hex| match owned::Id::from_40_bytes_in_hex(hex.as_bytes()) {
175+ .map_or(Ok(()), |hex| match git_hash::Id::from_40_bytes_in_hex(hex.as_bytes()) {
171176 Ok(actual) if actual.to_borrowed() == expected => Ok(()),
172177 _ => Err(format!("graph-{}.graph", expected.to_sha1_hex().as_bstr())),
173178 })
git-commitgraph/src/graph/init.rs+2−3
@@ -2,7 +2,6 @@ use crate::{ · 1 unmodified line
22 file::{self, File},
33 Graph, MAX_COMMITS,
44 };
5−use git_object::HashKind;
65 use std::{
76 convert::TryFrom,
87 io::{BufRead, BufReader},
@@ -22,9 +21,9 @@ pub enum Error { · 13 unmodified lines
2221 #[error("Commit-graph files mismatch: '{}' uses hash {hash1:?}, but '{}' uses hash {hash2:?}", .path1.display(), .path2.display())]
2322 HashVersionMismatch {
2423 path1: PathBuf,
25− hash1: HashKind,
24+ hash1: git_hash::Kind,
2625 path2: PathBuf,
27− hash2: HashKind,
26+ hash2: git_hash::Kind,
2827 },
2928 #[error("Did not find any files that look like commit graphs at '{}'", .0.display())]
3029 InvalidPath(PathBuf),
git-commitgraph/src/graph/verify.rs+8−5
@@ -3,7 +3,6 @@ use crate::{ · 2 unmodified lines
33 file::{self, commit},
44 graph, Graph, GENERATION_NUMBER_MAX,
55 };
6−use git_object::owned;
76 use std::{
87 cmp::{max, min},
98 collections::BTreeMap,
@@ -19,8 +18,8 @@ pub enum Error<E: std::error::Error + 'static> { · 9 unmodified lines
1918 BaseGraphCount { actual: u8, expected: u8, path: PathBuf },
2019 #[error("'{}' base graph at index {index} should have ID {expected} but is {actual}", .path.display())]
2120 BaseGraphId {
22− actual: owned::Id,
23− expected: owned::Id,
21+ actual: git_hash::Id,
22+ expected: git_hash::Id,
2423 index: u8,
2524 path: PathBuf,
2625 },
@@ -36,12 +35,16 @@ pub enum Error<E: std::error::Error + 'static> { · 9 unmodified lines
3635 path: PathBuf,
3736 },
3837 #[error("Commit {id}'s generation should be {expected} but is {actual}")]
39− Generation { actual: u32, expected: u32, id: owned::Id },
38+ Generation {
39+ actual: u32,
40+ expected: u32,
41+ id: git_hash::Id,
42+ },
4043 #[error(
4144 "Commit {id} has parent position {parent_pos} that is out of range (should be in range 0-{max_valid_pos})"
4245 )]
4346 ParentOutOfRange {
44− id: owned::Id,
47+ id: git_hash::Id,
4548 max_valid_pos: graph::Position,
4649 parent_pos: graph::Position,
4750 },