Showing the changes to git-commitgraph (4 of 51 files). Show all
Unified · Split
| @@ -16,13 +16,13 @@ use std::{ · 15 unmodified lines | ||
| 16 | 16 | #[allow(missing_docs)] |
| 17 | 17 | pub enum Error { |
| 18 | 18 | #[error("commit {0}'s extra edges overflows the commit-graph file's extra edges list")] |
| 19 | − ExtraEdgesListOverflow(git_hash::Id), | |
| 19 | + ExtraEdgesListOverflow(git_hash::ObjectId), | |
| 20 | 20 | #[error("commit {0}'s first parent is an extra edge index, which is invalid")] |
| 21 | − FirstParentIsExtraEdgeIndex(git_hash::Id), | |
| 21 | + FirstParentIsExtraEdgeIndex(git_hash::ObjectId), | |
| 22 | 22 | #[error("commit {0} has extra edges, but commit-graph file has no extra edges list")] |
| 23 | − MissingExtraEdgesList(git_hash::Id), | |
| 23 | + MissingExtraEdgesList(git_hash::ObjectId), | |
| 24 | 24 | #[error("commit {0} has a second parent but not a first parent")] |
| 25 | − SecondParentWithoutFirstParent(git_hash::Id), | |
| 25 | + SecondParentWithoutFirstParent(git_hash::ObjectId), | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // Note that git's commit-graph-format.txt as of v2.28.0 gives an incorrect value 0x0700_0000 for |
| @@ -19,28 +19,31 @@ pub enum Error<E: std::error::Error + 'static> { · 18 unmodified lines | ||
| 19 | 19 | #[error(transparent)] |
| 20 | 20 | Commit(#[from] file::commit::Error), |
| 21 | 21 | #[error("commit at file position {pos} has invalid ID {id}")] |
| 22 | − CommitId { id: git_hash::Id, pos: file::Position }, | |
| 22 | + CommitId { | |
| 23 | + id: git_hash::ObjectId, | |
| 24 | + pos: file::Position, | |
| 25 | + }, | |
| 23 | 26 | #[error("commit at file position {pos} with ID {id} is out of order relative to its predecessor with ID {predecessor_id}")] |
| 24 | 27 | CommitsOutOfOrder { |
| 25 | − id: git_hash::Id, | |
| 28 | + id: git_hash::ObjectId, | |
| 26 | 29 | pos: file::Position, |
| 27 | − predecessor_id: git_hash::Id, | |
| 30 | + predecessor_id: git_hash::ObjectId, | |
| 28 | 31 | }, |
| 29 | 32 | #[error("commit-graph filename should be {0}")] |
| 30 | 33 | Filename(String), |
| 31 | 34 | #[error("commit {id} has invalid generation {generation}")] |
| 32 | − Generation { generation: u32, id: git_hash::Id }, | |
| 35 | + Generation { generation: u32, id: git_hash::ObjectId }, | |
| 33 | 36 | #[error("checksum mismatch: expected {expected}, got {actual}")] |
| 34 | 37 | Mismatch { |
| 35 | − actual: git_hash::Id, | |
| 36 | − expected: git_hash::Id, | |
| 38 | + actual: git_hash::ObjectId, | |
| 39 | + expected: git_hash::ObjectId, | |
| 37 | 40 | }, |
| 38 | 41 | #[error("{0}")] |
| 39 | 42 | Processor(#[source] E), |
| 40 | 43 | #[error("commit {id} has invalid root tree ID {root_tree_id}")] |
| 41 | 44 | RootTreeId { |
| 42 | − id: git_hash::Id, | |
| 43 | − root_tree_id: git_hash::Id, | |
| 45 | + id: git_hash::ObjectId, | |
| 46 | + root_tree_id: git_hash::ObjectId, | |
| 44 | 47 | }, |
| 45 | 48 | } |
| 46 | 49 | |
| @@ -142,7 +145,7 @@ impl File { · 95 unmodified lines | ||
| 142 | 145 | /// checksum itself. |
| 143 | 146 | /// |
| 144 | 147 | /// Return the actual checksum on success or `(actual checksum, expected checksum)` if there is a mismatch. |
| 145 | − pub fn verify_checksum(&self) -> Result<git_hash::Id, (git_hash::Id, git_hash::Id)> { | |
| 148 | + pub fn verify_checksum(&self) -> Result<git_hash::ObjectId, (git_hash::ObjectId, git_hash::ObjectId)> { | |
| 146 | 149 | // Even though we could use git_features::hash::bytes_of_file(…), this would require using our own |
| 147 | 150 | // Error type to support io::Error and Mismatch. As we only gain progress, there probably isn't much value |
| 148 | 151 | // as these files are usually small enough to process them in less than a second, even for the large ones. |
| @@ -150,7 +153,7 @@ impl File { · 1 unmodified line | ||
| 150 | 153 | let data_len_without_trailer = self.data.len() - SHA1_SIZE; |
| 151 | 154 | let mut hasher = git_features::hash::Sha1::default(); |
| 152 | 155 | hasher.update(&self.data[..data_len_without_trailer]); |
| 153 | − let actual = git_hash::Id::new_sha1(hasher.digest()); | |
| 156 | + let actual = git_hash::ObjectId::new_sha1(hasher.digest()); | |
| 154 | 157 | |
| 155 | 158 | let expected = self.checksum(); |
| 156 | 159 | if actual.to_borrowed() == expected { |
| @@ -172,8 +175,10 @@ fn verify_split_chain_filename_hash( · 15 unmodified lines | ||
| 172 | 175 | .and_then(|filename| filename.to_str()) |
| 173 | 176 | .and_then(|filename| filename.strip_suffix(".graph")) |
| 174 | 177 | .and_then(|stem| stem.strip_prefix("graph-")) |
| 175 | − .map_or(Ok(()), |hex| match git_hash::Id::from_40_bytes_in_hex(hex.as_bytes()) { | |
| 176 | − Ok(actual) if actual.to_borrowed() == expected => Ok(()), | |
| 177 | − _ => Err(format!("graph-{}.graph", expected.to_sha1_hex().as_bstr())), | |
| 178 | + .map_or(Ok(()), |hex| { | |
| 179 | + match git_hash::ObjectId::from_40_bytes_in_hex(hex.as_bytes()) { | |
| 180 | + Ok(actual) if actual.to_borrowed() == expected => Ok(()), | |
| 181 | + _ => Err(format!("graph-{}.graph", expected.to_sha1_hex().as_bstr())), | |
| 182 | + } | |
| 178 | 183 | }) |
| 179 | 184 | } |
| @@ -18,8 +18,8 @@ pub enum Error<E: std::error::Error + 'static> { · 17 unmodified lines | ||
| 18 | 18 | BaseGraphCount { actual: u8, expected: u8, path: PathBuf }, |
| 19 | 19 | #[error("'{}' base graph at index {index} should have ID {expected} but is {actual}", .path.display())] |
| 20 | 20 | BaseGraphId { |
| 21 | − actual: git_hash::Id, | |
| 22 | − expected: git_hash::Id, | |
| 21 | + actual: git_hash::ObjectId, | |
| 22 | + expected: git_hash::ObjectId, | |
| 23 | 23 | index: u8, |
| 24 | 24 | path: PathBuf, |
| 25 | 25 | }, |
| @@ -38,13 +38,13 @@ pub enum Error<E: std::error::Error + 'static> { · 12 unmodified lines | ||
| 38 | 38 | Generation { |
| 39 | 39 | actual: u32, |
| 40 | 40 | expected: u32, |
| 41 | − id: git_hash::Id, | |
| 41 | + id: git_hash::ObjectId, | |
| 42 | 42 | }, |
| 43 | 43 | #[error( |
| 44 | 44 | "Commit {id} has parent position {parent_pos} that is out of range (should be in range 0-{max_valid_pos})" |
| 45 | 45 | )] |
| 46 | 46 | ParentOutOfRange { |
| 47 | − id: git_hash::Id, | |
| 47 | + id: git_hash::ObjectId, | |
| 48 | 48 | max_valid_pos: graph::Position, |
| 49 | 49 | parent_pos: graph::Position, |
| 50 | 50 | }, |
| @@ -75,15 +75,15 @@ pub fn fixture_path(path: &str) -> PathBuf { · 74 unmodified lines | ||
| 75 | 75 | PathBuf::from("tests").join("fixtures").join(path) |
| 76 | 76 | } |
| 77 | 77 | |
| 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") | |
| 78 | +pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId { | |
| 79 | + git_hash::ObjectId::from_40_bytes_in_hex(hex).expect("40 bytes hex") | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | pub struct RefInfo { |
| 83 | − id: git_hash::Id, | |
| 84 | − parent_ids: Vec<git_hash::Id>, | |
| 83 | + id: git_hash::ObjectId, | |
| 84 | + parent_ids: Vec<git_hash::ObjectId>, | |
| 85 | 85 | pos: GraphPosition, |
| 86 | − root_tree_id: git_hash::Id, | |
| 86 | + root_tree_id: git_hash::ObjectId, | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | impl RefInfo { |
| @@ -124,11 +124,11 @@ pub fn inspect_refs(repo_dir: impl AsRef<Path>, refs: &[&'static str]) -> HashMa · 34 unmodified lines | ||
| 124 | 124 | let parts = x.trim_end().split(' ').collect::<Vec<_>>(); |
| 125 | 125 | ( |
| 126 | 126 | parts[0].to_string(), |
| 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"), | |
| 127 | + git_hash::ObjectId::from_40_bytes_in_hex(parts[1].as_bytes()).expect("40 bytes hex"), | |
| 128 | + git_hash::ObjectId::from_40_bytes_in_hex(parts[2].as_bytes()).expect("40 bytes hex"), | |
| 129 | 129 | parts[3..] |
| 130 | 130 | .iter() |
| 131 | − .map(|x| git_hash::Id::from_40_bytes_in_hex(x.as_bytes()).expect("40 bytes hex")) | |
| 131 | + .map(|x| git_hash::ObjectId::from_40_bytes_in_hex(x.as_bytes()).expect("40 bytes hex")) | |
| 132 | 132 | .collect(), |
| 133 | 133 | ) |
| 134 | 134 | }) |