Showing the changes to git-commitgraph/src (5 of 60 files). Show all
Unified · Split
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | use crate::file::{self, commit::Commit, File, COMMIT_DATA_ENTRY_SIZE}; |
| 2 | 2 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 3 | −use git_object::HashKind; | |
| 4 | 3 | use std::{ |
| 5 | 4 | convert::{TryFrom, TryInto}, |
| 6 | 5 | fmt::{Debug, Formatter}, |
| @@ -28,8 +27,8 @@ impl File { · 21 unmodified lines | ||
| 28 | 27 | /// The kind of hash used in this File. |
| 29 | 28 | /// |
| 30 | 29 | /// 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 | |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | /// Returns 20 bytes sha1 at the given index in our list of (sorted) sha1 hashes. |
| @@ -5,7 +5,6 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | }; |
| 6 | 6 | use byteorder::{BigEndian, ByteOrder}; |
| 7 | 7 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 8 | −use git_object::owned; | |
| 9 | 8 | use std::{ |
| 10 | 9 | convert::{TryFrom, TryInto}, |
| 11 | 10 | fmt::{Debug, Formatter}, |
| @@ -17,13 +16,13 @@ use std::{ · 5 unmodified lines | ||
| 17 | 16 | #[allow(missing_docs)] |
| 18 | 17 | pub enum Error { |
| 19 | 18 | #[error("commit {0}'s extra edges overflows the commit-graph file's extra edges list")] |
| 20 | − ExtraEdgesListOverflow(owned::Id), | |
| 19 | + ExtraEdgesListOverflow(git_hash::Id), | |
| 21 | 20 | #[error("commit {0}'s first parent is an extra edge index, which is invalid")] |
| 22 | − FirstParentIsExtraEdgeIndex(owned::Id), | |
| 21 | + FirstParentIsExtraEdgeIndex(git_hash::Id), | |
| 23 | 22 | #[error("commit {0} has extra edges, but commit-graph file has no extra edges list")] |
| 24 | − MissingExtraEdgesList(owned::Id), | |
| 23 | + MissingExtraEdgesList(git_hash::Id), | |
| 25 | 24 | #[error("commit {0} has a second parent but not a first parent")] |
| 26 | − SecondParentWithoutFirstParent(owned::Id), | |
| 25 | + SecondParentWithoutFirstParent(git_hash::Id), | |
| 27 | 26 | } |
| 28 | 27 | |
| 29 | 28 | // Note that git's commit-graph-format.txt as of v2.28.0 gives an incorrect value 0x0700_0000 for |
| @@ -5,7 +5,6 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | }; |
| 6 | 6 | use bstr::ByteSlice; |
| 7 | 7 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 8 | −use git_object::owned; | |
| 9 | 8 | use std::{ |
| 10 | 9 | cmp::{max, min}, |
| 11 | 10 | collections::HashMap, |
| @@ -20,23 +19,29 @@ pub enum Error<E: std::error::Error + 'static> { · 8 unmodified lines | ||
| 20 | 19 | #[error(transparent)] |
| 21 | 20 | Commit(#[from] file::commit::Error), |
| 22 | 21 | #[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 }, | |
| 24 | 23 | #[error("commit at file position {pos} with ID {id} is out of order relative to its predecessor with ID {predecessor_id}")] |
| 25 | 24 | CommitsOutOfOrder { |
| 26 | − id: owned::Id, | |
| 25 | + id: git_hash::Id, | |
| 27 | 26 | pos: file::Position, |
| 28 | − predecessor_id: owned::Id, | |
| 27 | + predecessor_id: git_hash::Id, | |
| 29 | 28 | }, |
| 30 | 29 | #[error("commit-graph filename should be {0}")] |
| 31 | 30 | Filename(String), |
| 32 | 31 | #[error("commit {id} has invalid generation {generation}")] |
| 33 | − Generation { generation: u32, id: owned::Id }, | |
| 32 | + Generation { generation: u32, id: git_hash::Id }, | |
| 34 | 33 | #[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 | + }, | |
| 36 | 38 | #[error("{0}")] |
| 37 | 39 | Processor(#[source] E), |
| 38 | 40 | #[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 | + }, | |
| 40 | 45 | } |
| 41 | 46 | |
| 42 | 47 | /// The positive result of [`File::traverse()`] providing some statistical information. |
| @@ -137,7 +142,7 @@ impl File { · 94 unmodified lines | ||
| 137 | 142 | /// checksum itself. |
| 138 | 143 | /// |
| 139 | 144 | /// 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)> { | |
| 141 | 146 | // Even though we could use git_features::hash::bytes_of_file(…), this would require using our own |
| 142 | 147 | // Error type to support io::Error and Mismatch. As we only gain progress, there probably isn't much value |
| 143 | 148 | // 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 | ||
| 145 | 150 | let data_len_without_trailer = self.data.len() - SHA1_SIZE; |
| 146 | 151 | let mut hasher = git_features::hash::Sha1::default(); |
| 147 | 152 | 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()); | |
| 149 | 154 | |
| 150 | 155 | let expected = self.checksum(); |
| 151 | 156 | if actual.to_borrowed() == expected { |
| @@ -167,7 +172,7 @@ fn verify_split_chain_filename_hash( · 15 unmodified lines | ||
| 167 | 172 | .and_then(|filename| filename.to_str()) |
| 168 | 173 | .and_then(|filename| filename.strip_suffix(".graph")) |
| 169 | 174 | .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()) { | |
| 171 | 176 | Ok(actual) if actual.to_borrowed() == expected => Ok(()), |
| 172 | 177 | _ => Err(format!("graph-{}.graph", expected.to_sha1_hex().as_bstr())), |
| 173 | 178 | }) |
| @@ -2,7 +2,6 @@ use crate::{ · 1 unmodified line | ||
| 2 | 2 | file::{self, File}, |
| 3 | 3 | Graph, MAX_COMMITS, |
| 4 | 4 | }; |
| 5 | −use git_object::HashKind; | |
| 6 | 5 | use std::{ |
| 7 | 6 | convert::TryFrom, |
| 8 | 7 | io::{BufRead, BufReader}, |
| @@ -22,9 +21,9 @@ pub enum Error { · 13 unmodified lines | ||
| 22 | 21 | #[error("Commit-graph files mismatch: '{}' uses hash {hash1:?}, but '{}' uses hash {hash2:?}", .path1.display(), .path2.display())] |
| 23 | 22 | HashVersionMismatch { |
| 24 | 23 | path1: PathBuf, |
| 25 | − hash1: HashKind, | |
| 24 | + hash1: git_hash::Kind, | |
| 26 | 25 | path2: PathBuf, |
| 27 | − hash2: HashKind, | |
| 26 | + hash2: git_hash::Kind, | |
| 28 | 27 | }, |
| 29 | 28 | #[error("Did not find any files that look like commit graphs at '{}'", .0.display())] |
| 30 | 29 | InvalidPath(PathBuf), |
| @@ -3,7 +3,6 @@ use crate::{ · 2 unmodified lines | ||
| 3 | 3 | file::{self, commit}, |
| 4 | 4 | graph, Graph, GENERATION_NUMBER_MAX, |
| 5 | 5 | }; |
| 6 | −use git_object::owned; | |
| 7 | 6 | use std::{ |
| 8 | 7 | cmp::{max, min}, |
| 9 | 8 | collections::BTreeMap, |
| @@ -19,8 +18,8 @@ pub enum Error<E: std::error::Error + 'static> { · 9 unmodified lines | ||
| 19 | 18 | BaseGraphCount { actual: u8, expected: u8, path: PathBuf }, |
| 20 | 19 | #[error("'{}' base graph at index {index} should have ID {expected} but is {actual}", .path.display())] |
| 21 | 20 | BaseGraphId { |
| 22 | − actual: owned::Id, | |
| 23 | − expected: owned::Id, | |
| 21 | + actual: git_hash::Id, | |
| 22 | + expected: git_hash::Id, | |
| 24 | 23 | index: u8, |
| 25 | 24 | path: PathBuf, |
| 26 | 25 | }, |
| @@ -36,12 +35,16 @@ pub enum Error<E: std::error::Error + 'static> { · 9 unmodified lines | ||
| 36 | 35 | path: PathBuf, |
| 37 | 36 | }, |
| 38 | 37 | #[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 | + }, | |
| 40 | 43 | #[error( |
| 41 | 44 | "Commit {id} has parent position {parent_pos} that is out of range (should be in range 0-{max_valid_pos})" |
| 42 | 45 | )] |
| 43 | 46 | ParentOutOfRange { |
| 44 | − id: owned::Id, | |
| 47 | + id: git_hash::Id, | |
| 45 | 48 | max_valid_pos: graph::Position, |
| 46 | 49 | parent_pos: graph::Position, |
| 47 | 50 | }, |