History

refactor (#279)

Sebastian Thiel committed 4 years ago

Commit 8c9c7fc1 parent 0cd7f3b4 files · +34 −30Browse files

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

Unified · Split

git-commitgraph/src/file/init.rs+8−9
@@ -29,23 +29,15 @@ pub enum Error { · 28 unmodified lines
29 },29 },
30 #[error("{0}")]30 #[error("{0}")]
31 Corrupt(String),31 Corrupt(String),
32 #[error("Commit-graph file contains multiple {:?} chunks", .0.as_bstr())]
33 DuplicateChunk(ChunkId),
34 // This error case is disabled, as git allows extra garbage in the extra edges list?32 // This error case is disabled, as git allows extra garbage in the extra edges list?
35 // #[error("The last entry in commit-graph's extended edges list does is not marked as being terminal")]33 // #[error("The last entry in commit-graph's extended edges list does is not marked as being terminal")]
36 // ExtraEdgesOverflow,34 // ExtraEdgesOverflow,
37 #[error("Commit-graph chunk {:?} has invalid size: {msg}", .id.as_bstr())]
38 InvalidChunkSize { id: ChunkId, msg: String },
39 #[error("Could not open commit-graph file at '{}'", .path.display())]35 #[error("Could not open commit-graph file at '{}'", .path.display())]
40 Io {36 Io {
41 #[source]37 #[source]
42 err: std::io::Error,38 err: std::io::Error,
43 path: std::path::PathBuf,39 path: std::path::PathBuf,
44 },40 },
45 #[error("Missing required chunk {:?}", .0.as_bstr())]
46 MissingChunk(ChunkId),
47 #[error(transparent)]
48 MissingChunk2(#[from] git_chunk::file::index::offset_by_kind::Error),
49 #[error("{0}")]41 #[error("{0}")]
50 Trailer(String),42 Trailer(String),
51 #[error("Commit-graph file uses unsupported hash version: {0}")]43 #[error("Commit-graph file uses unsupported hash version: {0}")]
@@ -54,6 +46,10 @@ pub enum Error { · 2 unmodified lines
54 UnsupportedVersion(u8),46 UnsupportedVersion(u8),
55 #[error(transparent)]47 #[error(transparent)]
56 ChunkFileDecode(#[from] git_chunk::file::decode::Error),48 ChunkFileDecode(#[from] git_chunk::file::decode::Error),
49 #[error(transparent)]
50 MissingChunk(#[from] git_chunk::file::index::offset_by_kind::Error),
51 #[error("Commit-graph chunk {:?} has invalid size: {msg}", .id.as_bstr())]
52 InvalidChunkSize { id: ChunkId, msg: String },
57}53}
58 54
59const TRAILER_LEN: usize = SHA1_SIZE;55const TRAILER_LEN: usize = SHA1_SIZE;
@@ -211,7 +207,10 @@ impl TryFrom<&Path> for File { · 151 unmodified lines
211 }207 }
212 208
213 if base_graph_count > 0 && base_graphs_list_offset.is_none() {209 if base_graph_count > 0 && base_graphs_list_offset.is_none() {
214 return Err(Error::MissingChunk(BASE_GRAPHS_LIST_CHUNK_ID));210 return Err(git_chunk::file::index::offset_by_kind::Error {
211 kind: BASE_GRAPHS_LIST_CHUNK_ID,
212 }
213 .into());
215 }214 }
216 215
217 let (fan, _) = read_fan(&data[fan_offset..]);216 let (fan, _) = read_fan(&data[fan_offset..]);