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 (7 of 60 files). Show all

Unified · Split

7 files
  1. git-commitgraph/Cargo.toml +1 −2
  2. git-commitgraph/src/file/access.rs +2 −3
  3. git-commitgraph/src/file/commit.rs +4 −5
  4. git-commitgraph/src/file/verify.rs +15 −10
  5. git-commitgraph/src/graph/init.rs +2 −3
  6. git-commitgraph/src/graph/verify.rs +8 −5
  7. git-commitgraph/tests/commitgraph.rs +8 −9
git-commitgraph/Cargo.toml+1−2
@@ -13,11 +13,10 @@ include = ["src/**/*"] · 12 unmodified lines
1313 doctest = false
1414
1515 [features]
16−serde1 = ["serde", "git-object/serde1"]
16+serde1 = ["serde", "git-hash/serde1"]
1717
1818 [dependencies]
1919 git-features = { version = "^0.11.0", path = "../git-features" }
20−git-object = { version = "^0.6.0", path = "../git-object" }
2120 git-hash = { version = "^0.1.0", path = "../git-hash" }
2221
2322 bstr = { version = "0.2.13", default-features = false, features = ["std"] }
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 },
git-commitgraph/tests/commitgraph.rs+8−9
@@ -1,5 +1,4 @@
11 use git_commitgraph::{graph::Position as GraphPosition, Graph};
2−use git_object::{borrowed, owned};
32 use std::{
43 collections::{HashMap, HashSet},
54 convert::{TryFrom, TryInto},
@@ -76,15 +75,15 @@ pub fn fixture_path(path: &str) -> PathBuf { · 70 unmodified lines
7675 PathBuf::from("tests").join("fixtures").join(path)
7776 }
7877
79−pub fn hex_to_id(hex: &[u8]) -> owned::Id {
80− owned::Id::from_40_bytes_in_hex(hex).expect("40 bytes hex")
78+pub fn hex_to_id(hex: &[u8]) -> git_hash::Id {
79+ git_hash::Id::from_40_bytes_in_hex(hex).expect("40 bytes hex")
8180 }
8281
8382 pub struct RefInfo {
84− id: owned::Id,
85− parent_ids: Vec<owned::Id>,
83+ id: git_hash::Id,
84+ parent_ids: Vec<git_hash::Id>,
8685 pos: GraphPosition,
87− root_tree_id: owned::Id,
86+ root_tree_id: git_hash::Id,
8887 }
8988
9089 impl RefInfo {
@@ -125,11 +124,11 @@ pub fn inspect_refs(repo_dir: impl AsRef<Path>, refs: &[&'static str]) -> HashMa · 34 unmodified lines
125124 let parts = x.trim_end().split(' ').collect::<Vec<_>>();
126125 (
127126 parts[0].to_string(),
128− owned::Id::from_40_bytes_in_hex(parts[1].as_bytes()).expect("40 bytes hex"),
129− owned::Id::from_40_bytes_in_hex(parts[2].as_bytes()).expect("40 bytes hex"),
127+ git_hash::Id::from_40_bytes_in_hex(parts[1].as_bytes()).expect("40 bytes hex"),
128+ git_hash::Id::from_40_bytes_in_hex(parts[2].as_bytes()).expect("40 bytes hex"),
130129 parts[3..]
131130 .iter()
132− .map(|x| owned::Id::from_40_bytes_in_hex(x.as_bytes()).expect("40 bytes hex"))
131+ .map(|x| git_hash::Id::from_40_bytes_in_hex(x.as_bytes()).expect("40 bytes hex"))
133132 .collect(),
134133 )
135134 })

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t