Skip to content

Commit e82f795

Browse files
committed
Merge branch 'improvements'
2 parents 46cd1ae + dbb3576 commit e82f795

File tree

13 files changed

+190
-48
lines changed

13 files changed

+190
-48
lines changed

examples/log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clap::Parser;
88
use gix::{
99
bstr::{BString, ByteSlice},
1010
date::time::format,
11-
traverse::commit::simple::Sorting,
11+
revision::walk::Sorting,
1212
};
1313

1414
fn main() {

gitoxide-core/src/repository/commitgraph/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub(crate) mod function {
22
use std::{borrow::Cow, ffi::OsString};
33

44
use anyhow::{bail, Context};
5-
use gix::{prelude::ObjectIdExt, traverse::commit::simple::Sorting};
5+
use gix::{prelude::ObjectIdExt, revision::walk::Sorting};
66

77
use crate::OutputFormat;
88

gitoxide-core/src/repository/revision/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 0..=2;
1717

1818
pub(crate) mod function {
1919
use anyhow::{bail, Context};
20-
use gix::{hashtable::HashMap, traverse::commit::simple::Sorting, Progress};
20+
use gix::{hashtable::HashMap, revision::walk::Sorting, Progress};
2121
use layout::{
2222
backends::svg::SVGWriter,
2323
core::{base::Orientation, geometry::Point, style::StyleAttr},

gix-traverse/src/commit/topo/iter.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ where
180180

181181
fn collect_parents(&mut self, id: &oid) -> Result<SmallVec<[(ObjectId, GenAndCommitTime); 1]>, Error> {
182182
collect_parents(
183-
self.commit_graph.as_ref(),
183+
&mut self.commit_graph,
184184
&self.find,
185185
id,
186186
matches!(self.parents, Parents::First),
@@ -193,7 +193,7 @@ where
193193
&mut self,
194194
id: &oid,
195195
) -> Result<SmallVec<[(ObjectId, GenAndCommitTime); 1]>, Error> {
196-
collect_parents(self.commit_graph.as_ref(), &self.find, id, false, &mut self.buf)
196+
collect_parents(&mut self.commit_graph, &self.find, id, false, &mut self.buf)
197197
}
198198

199199
fn pop_commit(&mut self) -> Option<Result<Info, Error>> {
@@ -236,7 +236,7 @@ where
236236
}
237237

238238
fn collect_parents<Find>(
239-
cache: Option<&gix_commitgraph::Graph>,
239+
cache: &mut Option<gix_commitgraph::Graph>,
240240
f: Find,
241241
id: &oid,
242242
first_only: bool,
@@ -246,7 +246,7 @@ where
246246
Find: gix_object::Find,
247247
{
248248
let mut parents = SmallVec::<[(ObjectId, GenAndCommitTime); 1]>::new();
249-
match find(cache, &f, id, buf)? {
249+
match find(cache.as_ref(), &f, id, buf)? {
250250
Either::CommitRefIter(c) => {
251251
for token in c {
252252
use gix_object::commit::ref_iter::Token as T;
@@ -265,15 +265,21 @@ where
265265
// Need to check the cache again. That a commit is not in the cache
266266
// doesn't mean a parent is not.
267267
for (id, gen_time) in parents.iter_mut() {
268-
let commit = find(cache, &f, id, buf)?;
268+
let commit = find(cache.as_ref(), &f, id, buf)?;
269269
*gen_time = gen_and_commit_time(commit)?;
270270
}
271271
}
272272
Either::CachedCommit(c) => {
273273
for pos in c.iter_parents() {
274+
let Ok(pos) = pos else {
275+
// drop corrupt cache and use ODB from now on.
276+
*cache = None;
277+
return collect_parents(cache, f, id, first_only, buf);
278+
};
274279
let parent_commit = cache
280+
.as_ref()
275281
.expect("cache exists if CachedCommit was returned")
276-
.commit_at(pos?);
282+
.commit_at(pos);
277283
parents.push((
278284
parent_commit.id().into(),
279285
(parent_commit.generation(), parent_commit.committer_timestamp() as i64),

gix-traverse/src/commit/topo/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ pub enum Error {
1111
#[error("Internal state (bitflags) not found")]
1212
MissingStateUnexpected,
1313
#[error(transparent)]
14-
CommitGraphFile(#[from] gix_commitgraph::file::commit::Error),
15-
#[error(transparent)]
1614
ObjectDecode(#[from] gix_object::decode::Error),
1715
#[error(transparent)]
1816
Find(#[from] gix_object::find::existing_iter::Error),

gix/src/repository/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ mod object;
6767
mod pathspec;
6868
mod reference;
6969
mod remote;
70-
#[cfg(feature = "revision")]
7170
mod revision;
7271
mod shallow;
7372
mod state;

gix/src/repository/revision.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::{bstr::BStr, revision, Id};
1+
use crate::revision;
2+
#[cfg(feature = "revision")]
3+
use crate::{bstr::BStr, Id};
24

35
/// Methods for resolving revisions by spec or working with the commit graph.
46
impl crate::Repository {
@@ -9,6 +11,7 @@ impl crate::Repository {
911
/// - `@` actually stands for `HEAD`, whereas `git` resolves it to the object pointed to by `HEAD` without making the
1012
/// `HEAD` ref available for lookups.
1113
#[doc(alias = "revparse", alias = "git2")]
14+
#[cfg(feature = "revision")]
1215
pub fn rev_parse<'a>(&self, spec: impl Into<&'a BStr>) -> Result<revision::Spec<'_>, revision::spec::parse::Error> {
1316
revision::Spec::from_bstr(
1417
spec,
@@ -22,6 +25,7 @@ impl crate::Repository {
2225

2326
/// Parse a revision specification and return single object id as represented by this instance.
2427
#[doc(alias = "revparse_single", alias = "git2")]
28+
#[cfg(feature = "revision")]
2529
pub fn rev_parse_single<'repo, 'a>(
2630
&'repo self,
2731
spec: impl Into<&'a BStr>,

gix/src/revision/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub use gix_revision as plumbing;
88
///
99
#[allow(clippy::empty_docs)]
1010
pub mod walk;
11-
pub use walk::iter::Walk;
11+
pub use walk::iter_impl::Walk;
1212

1313
///
1414
#[cfg(feature = "revision")]

gix/src/revision/spec/parse/delegate/navigate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
192192
match oid
193193
.attach(repo)
194194
.ancestors()
195-
.sorting(gix_traverse::commit::simple::Sorting::ByCommitTimeNewestFirst)
195+
.sorting(crate::revision::walk::Sorting::ByCommitTimeNewestFirst)
196196
.all()
197197
{
198198
Ok(iter) => {
@@ -245,7 +245,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
245245
.filter(|r| r.id().header().ok().map_or(false, |obj| obj.kind().is_commit()))
246246
.filter_map(|r| r.detach().peeled),
247247
)
248-
.sorting(gix_traverse::commit::simple::Sorting::ByCommitTimeNewestFirst)
248+
.sorting(crate::revision::walk::Sorting::ByCommitTimeNewestFirst)
249249
.all()
250250
{
251251
Ok(iter) => {

gix/src/revision/spec/parse/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub enum Error {
189189
next: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
190190
},
191191
#[error(transparent)]
192-
Traverse(#[from] gix_traverse::commit::simple::Error),
192+
Traverse(#[from] crate::revision::walk::iter::Error),
193193
#[error(transparent)]
194194
Walk(#[from] crate::revision::walk::Error),
195195
#[error("Spec does not contain a single object id")]

0 commit comments

Comments
 (0)