radicle-heartwood-lfs/radicle-fetch/src/git.rs

24 lines
609 B
Rust

pub(crate) mod mem;
pub(crate) mod packfile;
pub(crate) mod repository;
pub mod refs;
pub(crate) mod oid {
//! Helper functions for converting to/from [`radicle::git::Oid`] and
//! [`ObjectId`].
use gix_hash::ObjectId;
use radicle::git::Oid;
/// Convert from an [`ObjectId`] to an [`Oid`].
pub fn to_oid(oid: ObjectId) -> Oid {
Oid::try_from(oid.as_bytes()).expect("invalid gix Oid")
}
/// Convert from an [`Oid`] to an [`ObjectId`].
pub fn to_object_id(oid: Oid) -> ObjectId {
ObjectId::from(gix_hash::oid::from_bytes_unchecked(oid.as_ref()))
}
}