diff --git a/src/database/indexer.rs b/src/database/indexer.rs
@@ -251,10 +251,12 @@ fn branch_index_update(
}
let commit = rev.object()?;
- let author = commit.author()?;
- let committer = commit.committer()?;
+ let oid = commit.id;
+ let commit = commit.decode()?;
+ let author = commit.author();
+ let committer = commit.committer();
- Commit::new(&commit, author, committer)?.insert(
+ Commit::new(oid, &commit, author, committer)?.insert(
&commit_tree,
tree_len + i,
&mut batch,
diff --git a/src/database/schema/commit.rs b/src/database/schema/commit.rs
@@ -1,7 +1,7 @@
use std::sync::Arc;
use anyhow::Context;
-use gix::{actor::SignatureRef, ObjectId};
+use gix::{actor::SignatureRef, objs::CommitRef, ObjectId};
use rkyv::{Archive, Serialize};
use rocksdb::{IteratorMode, ReadOptions, WriteBatch};
use time::{OffsetDateTime, UtcOffset};
@@ -25,18 +25,19 @@ pub struct Commit {
impl Commit {
pub fn new(
- commit: &gix::Commit<'_>,
+ oid: ObjectId,
+ commit: &CommitRef<'_>,
author: SignatureRef<'_>,
committer: SignatureRef<'_>,
) -> Result<Self, anyhow::Error> {
- let message = commit.message()?;
+ let message = commit.message();
Ok(Self {
summary: message.summary().to_string(),
message: message.body.map(ToString::to_string).unwrap_or_default(),
committer: committer.try_into()?,
author: author.try_into()?,
- hash: match commit.id().detach() {
+ hash: match oid {
ObjectId::Sha1(d) => d,
},
})
diff --git a/src/git.rs b/src/git.rs
@@ -739,11 +739,11 @@ impl<'a> TryFrom<SignatureRef<'a>> for CommitUser<'a> {
impl CommitUser<'_> {
pub fn name(&self) -> &BStr {
- &self.name
+ self.name
}
pub fn email(&self) -> &BStr {
- &self.email
+ self.email
}
pub fn time(&self) -> OffsetDateTime {
@@ -785,6 +785,7 @@ enum SmallVec<T> {
}
impl<T: Copy> SmallVec<T> {
+ #[allow(clippy::type_complexity)]
fn iter(
&self,
) -> Either<std::iter::Empty<T>, Either<std::iter::Once<T>, Copied<std::slice::Iter<T>>>> {
@@ -805,17 +806,16 @@ impl<'a> CommitInner<'a> {
committer: CommitUser::try_from(commit.committer)?,
oid,
tree: commit.tree,
- parents: commit
- .parents
- .into_inner()
- .map(|[v]| SmallVec::One(v))
- .unwrap_or_else(|inner| {
+ parents: commit.parents.into_inner().map_or_else(
+ |inner| {
if inner.is_empty() {
SmallVec::None
} else {
SmallVec::Many(inner.into_vec())
}
- }),
+ },
+ |[v]| SmallVec::One(v),
+ ),
summary: message.summary(),
body: message.body.unwrap_or_else(|| BStr::new("")),
@@ -839,7 +839,7 @@ impl CommitInner<'_> {
}
pub fn tree(&self) -> &BStr {
- &self.tree
+ self.tree
}
pub fn parents(&self) -> impl Iterator<Item = &BStr> {
@@ -851,7 +851,7 @@ impl CommitInner<'_> {
}
pub fn body(&self) -> &BStr {
- &self.body
+ self.body
}
}