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
2929 },
3030 #[error("{0}")]
3131 Corrupt(String),
32− #[error("Commit-graph file contains multiple {:?} chunks", .0.as_bstr())]
33− DuplicateChunk(ChunkId),
3432 // This error case is disabled, as git allows extra garbage in the extra edges list?
3533 // #[error("The last entry in commit-graph's extended edges list does is not marked as being terminal")]
3634 // ExtraEdgesOverflow,
37− #[error("Commit-graph chunk {:?} has invalid size: {msg}", .id.as_bstr())]
38− InvalidChunkSize { id: ChunkId, msg: String },
3935 #[error("Could not open commit-graph file at '{}'", .path.display())]
4036 Io {
4137 #[source]
4238 err: std::io::Error,
4339 path: std::path::PathBuf,
4440 },
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),
4941 #[error("{0}")]
5042 Trailer(String),
5143 #[error("Commit-graph file uses unsupported hash version: {0}")]
@@ -54,6 +46,10 @@ pub enum Error { · 2 unmodified lines
5446 UnsupportedVersion(u8),
5547 #[error(transparent)]
5648 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 },
5753 }
5854
5955 const TRAILER_LEN: usize = SHA1_SIZE;
@@ -211,7 +207,10 @@ impl TryFrom<&Path> for File { · 151 unmodified lines
211207 }
212208
213209 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());
215214 }
216215
217216 let (fan, _) = read_fan(&data[fan_offset..]);