forked from mirrors/jj
git_backend: remove redundant error handling for invalid hash length
The only error that could be returned by libgit2 is invalid hash length, and we check that explicitly. If we switch the backends to gitoxide, there will be panicking constructor. https://docs.rs/git2/latest/git2/struct.Oid.html#method.from_bytes
This commit is contained in:
parent
8bc3f5fd67
commit
d1c71c05c9
2 changed files with 1 additions and 12 deletions
|
@ -247,12 +247,6 @@ pub enum BackendError {
|
|||
object_type: String,
|
||||
hash: String,
|
||||
},
|
||||
#[error("Invalid hash for object of type {object_type} with hash {hash}: {source}")]
|
||||
InvalidHash {
|
||||
object_type: String,
|
||||
hash: String,
|
||||
source: Box<dyn std::error::Error + Send + Sync>,
|
||||
},
|
||||
#[error("Invalid UTF-8 for object {hash} of type {object_type}: {source}")]
|
||||
InvalidUtf8 {
|
||||
object_type: String,
|
||||
|
|
|
@ -449,12 +449,7 @@ fn validate_git_object_id(id: &impl ObjectId) -> Result<git2::Oid, BackendError>
|
|||
hash: id.hex(),
|
||||
});
|
||||
}
|
||||
let oid = git2::Oid::from_bytes(id.as_bytes()).map_err(|err| BackendError::InvalidHash {
|
||||
object_type: id.object_type(),
|
||||
hash: id.hex(),
|
||||
source: Box::new(err),
|
||||
})?;
|
||||
Ok(oid)
|
||||
Ok(git2::Oid::from_bytes(id.as_bytes()).unwrap())
|
||||
}
|
||||
|
||||
fn map_not_found_err(err: git2::Error, id: &impl ObjectId) -> BackendError {
|
||||
|
|
Loading…
Reference in a new issue