Remove redundant surf Oid conversions

radicle-surf 0.29 switched from radicle-git-ext to radicle-oid for
its Oid type, making radicle_surf::Oid and radicle::git::Oid the
same type. The crate::oid::{from_surf, into_surf} helpers were
therefore no-op round-trips through git2::Oid.
This commit is contained in:
Rūdolfs Ošiņš
2026-07-28 09:25:52 +02:00
parent 08060f9190
commit d559015e3d
9 changed files with 26 additions and 46 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ pub struct DiffFile {
impl From<surf::diff::DiffFile> for DiffFile {
fn from(value: surf::diff::DiffFile) -> Self {
Self {
oid: crate::oid::from_surf(value.oid),
oid: value.oid,
mode: value.mode.into(),
}
}
-1
View File
@@ -11,7 +11,6 @@ pub mod config;
pub mod diff;
pub mod domain;
pub mod error;
pub mod oid;
pub mod outbound;
pub mod repo;
pub mod source;
-10
View File
@@ -1,10 +0,0 @@
// `radicle_surf::Oid` and `radicle::git::Oid` are both aliases for
// `radicle_oid::Oid`, so these conversions are identities. They are kept as a
// single boundary in case the two crates diverge on their Oid type again.
pub(crate) fn from_surf(oid: radicle_surf::Oid) -> radicle::git::Oid {
oid
}
pub(crate) fn into_surf(oid: radicle::git::Oid) -> radicle_surf::Oid {
oid
}
+2 -6
View File
@@ -241,16 +241,12 @@ pub struct RepoRefs {
impl From<surf::Commit> for Commit {
fn from(value: surf::Commit) -> Self {
Self {
id: crate::oid::from_surf(value.id),
id: value.id,
author: value.author,
committer: value.committer,
message: value.message,
summary: value.summary,
parents: value
.parents
.into_iter()
.map(crate::oid::from_surf)
.collect(),
parents: value.parents,
}
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ impl Blob {
impl<T: AsRef<[u8]>> From<surf::blob::Blob<T>> for Blob {
fn from(blob: surf::blob::Blob<T>) -> Self {
Blob::new(
crate::oid::from_surf(blob.object_id()),
blob.object_id(),
blob.is_binary(),
blob.commit().clone().into(),
blob.content(),
+2 -6
View File
@@ -23,16 +23,12 @@ pub struct Commit {
impl From<surf::Commit> for Commit {
fn from(commit: surf::Commit) -> Self {
Commit {
id: crate::oid::from_surf(commit.id),
id: commit.id,
author: commit.author,
committer: commit.committer,
message: commit.message.to_string(),
summary: commit.summary.to_string(),
parents: commit
.parents
.into_iter()
.map(crate::oid::from_surf)
.collect::<Vec<_>>(),
parents: commit.parents,
}
}
}
+4 -4
View File
@@ -21,7 +21,7 @@ pub struct Tree {
impl Tree {
pub fn from_surf(tree: surf::tree::Tree, path: &std::path::Path) -> Self {
Tree {
id: crate::oid::from_surf(tree.object_id()),
id: tree.object_id(),
path: path.to_path_buf(),
entries: tree
.entries()
@@ -76,9 +76,9 @@ impl Entry {
impl Entry {
pub fn object_id(&self) -> Oid {
match self.kind {
surf::tree::EntryKind::Blob(id) => crate::oid::from_surf(id),
surf::tree::EntryKind::Tree(id) => crate::oid::from_surf(id),
surf::tree::EntryKind::Submodule { id, .. } => crate::oid::from_surf(id),
surf::tree::EntryKind::Blob(id) => id,
surf::tree::EntryKind::Tree(id) => id,
surf::tree::EntryKind::Submodule { id, .. } => id,
}
}
}
+8 -8
View File
@@ -716,8 +716,8 @@ impl ToPretty for surf::diff::Moved {
type Context = ();
fn pretty<R: Repo>(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output {
let old = Some((self.old_path.as_path(), crate::oid::from_surf(self.old.oid)));
let new = Some((self.new_path.as_path(), crate::oid::from_surf(self.new.oid)));
let old = Some((self.old_path.as_path(), self.old.oid));
let new = Some((self.new_path.as_path(), self.new.oid));
let blobs = Blobs::from_paths(old, new, repo);
types::diff::Moved {
@@ -736,7 +736,7 @@ impl ToPretty for surf::diff::Added {
fn pretty<R: Repo>(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output {
let old = None;
let new = Some((self.path.as_path(), crate::oid::from_surf(self.new.oid)));
let new = Some((self.path.as_path(), self.new.oid));
let blobs = Blobs::from_paths(old, new, repo);
types::diff::Added {
@@ -752,7 +752,7 @@ impl ToPretty for surf::diff::Deleted {
type Context = ();
fn pretty<R: Repo>(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output {
let old = Some((self.path.as_path(), crate::oid::from_surf(self.old.oid)));
let old = Some((self.path.as_path(), self.old.oid));
let new = None;
let blobs = Blobs::from_paths(old, new, repo);
@@ -769,8 +769,8 @@ impl ToPretty for surf::diff::Modified {
type Context = ();
fn pretty<R: Repo>(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output {
let old = Some((self.path.as_path(), crate::oid::from_surf(self.old.oid)));
let new = Some((self.path.as_path(), crate::oid::from_surf(self.new.oid)));
let old = Some((self.path.as_path(), self.old.oid));
let new = Some((self.path.as_path(), self.new.oid));
let blobs = Blobs::from_paths(old, new, repo);
types::diff::Modified {
@@ -787,8 +787,8 @@ impl ToPretty for surf::diff::Copied {
type Context = ();
fn pretty<R: Repo>(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output {
let old = Some((self.old_path.as_path(), crate::oid::from_surf(self.old.oid)));
let new = Some((self.new_path.as_path(), crate::oid::from_surf(self.new.oid)));
let old = Some((self.old_path.as_path(), self.old.oid));
let new = Some((self.new_path.as_path(), self.new.oid));
let blobs = Blobs::from_paths(old, new, repo);
types::diff::Copied {
+8 -9
View File
@@ -182,9 +182,9 @@ fn last_path_commit(
});
let commit = match fast {
Some(oid) => surf_repo.commit(crate::oid::into_surf(oid))?,
Some(oid) => surf_repo.commit(oid)?,
None => surf_repo
.last_commit(&path, crate::oid::into_surf(head))?
.last_commit(&path, head)?
.ok_or_else(|| git2::Error::from_str("no commit found for path"))?,
};
@@ -548,7 +548,7 @@ pub trait Repo: Profile {
Some(sha) => sha,
None => resolve_revision(&storage_repo, peer, revision)?,
};
let tree = repo.tree(crate::oid::into_surf(oid), &path)?;
let tree = repo.tree(oid, &path)?;
Ok(source::tree::Tree::from_surf(tree, &path))
}
@@ -565,7 +565,7 @@ pub trait Repo: Profile {
let oid = match sha {
Some(sha) => sha,
None => crate::oid::from_surf(surf_repo.head()?),
None => surf_repo.head()?,
};
// Resolve the blob via a direct tree lookup. `surf::Repository::blob`
@@ -642,8 +642,8 @@ pub trait Repo: Profile {
}
let repo = radicle_surf::Repository::open(&repo_path)?;
let base = repo.commit(crate::oid::into_surf(base))?;
let commit = repo.commit(crate::oid::into_surf(head))?;
let base = repo.commit(base)?;
let commit = repo.commit(head)?;
let diff = repo.diff(base.id, commit.id)?;
let stats = diff.stats();
@@ -830,8 +830,7 @@ pub trait Repo: Profile {
};
let repo = surf::Repository::open(storage_repo.path())?;
let head = crate::oid::into_surf(oid);
let commits = repo.history(head)?;
let commits = repo.history(oid)?;
let cursor = skip.unwrap_or(0);
match take {
@@ -927,7 +926,7 @@ pub trait Repo: Profile {
};
let repo = surf::Repository::open(storage_repo.path())?;
let commit = repo.commit(crate::oid::into_surf(oid))?;
let commit = repo.commit(oid)?;
Ok(commit.into())
}