Skip to content

Commit 56f4d30

Browse files
committed
adapt to changes in gix-revision
1 parent ed258da commit 56f4d30

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate-status.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ Make it the best-performing implementation and the most convenient one.
469469

470470
### gix-revision
471471
* [x] `describe()` (similar to `git name-rev`)
472+
* [x] primitives to help with graph traversal, along with commit-graph acceleration.
472473
* parse specifications
473474
* [x] parsing and navigation
474475
* [x] revision ranges
@@ -638,7 +639,7 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/gix-lock/README.
638639
* **Id**
639640
* [x] short hashes with detection of ambiguity.
640641
* **Commit**
641-
* [x] `describe()` like functionality
642+
* [x] `git describe` like functionality, with optional commit-graph acceleration
642643
* [x] create new commit from tree
643644
* **Objects**
644645
* [x] lookup

gitoxide-core/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ async-client = ["gix/async-network-client-async-std", "gix-transport-configurati
3333

3434
#! ### Other
3535
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
36-
serde = ["gix-commitgraph/serde", "gix/serde", "serde_json", "dep:serde", "bytesize/serde"]
36+
serde = ["gix/serde", "serde_json", "dep:serde", "bytesize/serde"]
3737

3838

3939
[dependencies]
4040
# deselect everything else (like "performance") as this should be controllable by the parent application.
4141
gix = { version = "^0.44.1", path = "../gix", default-features = false }
4242
gix-pack-for-configuration-only = { package = "gix-pack", version = "^0.35.0", path = "../gix-pack", default-features = false, features = ["pack-cache-lru-dynamic", "pack-cache-lru-static"] }
4343
gix-transport-configuration-only = { package = "gix-transport", version = "^0.31.0", path = "../gix-transport", default-features = false }
44-
gix-commitgraph = { version = "^0.14.0", path = "../gix-commitgraph" }
4544
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }
4645
anyhow = "1.0.42"
4746
thiserror = "1.0.34"

gitoxide-core/src/commitgraph/verify.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io, path::Path};
22

33
use anyhow::{Context as AnyhowContext, Result};
4-
use gix_commitgraph::Graph;
4+
use gix::commitgraph::Graph;
55

66
use crate::OutputFormat;
77

@@ -31,15 +31,15 @@ pub fn graph_or_file<W1, W2>(
3131
mut out,
3232
output_statistics,
3333
}: Context<W1, W2>,
34-
) -> Result<gix_commitgraph::verify::Outcome>
34+
) -> Result<gix::commitgraph::verify::Outcome>
3535
where
3636
W1: io::Write,
3737
W2: io::Write,
3838
{
3939
let g = Graph::at(path).with_context(|| "Could not open commit graph")?;
4040

4141
#[allow(clippy::unnecessary_wraps, unknown_lints)]
42-
fn noop_processor(_commit: &gix_commitgraph::file::Commit<'_>) -> std::result::Result<(), std::fmt::Error> {
42+
fn noop_processor(_commit: &gix::commitgraph::file::Commit<'_>) -> std::result::Result<(), std::fmt::Error> {
4343
Ok(())
4444
}
4545
let stats = g
@@ -57,7 +57,7 @@ where
5757
Ok(stats)
5858
}
5959

60-
fn print_human_output(out: &mut impl io::Write, stats: &gix_commitgraph::verify::Outcome) -> io::Result<()> {
60+
fn print_human_output(out: &mut impl io::Write, stats: &gix::commitgraph::verify::Outcome) -> io::Result<()> {
6161
writeln!(out, "number of commits with the given number of parents")?;
6262
let mut parent_counts: Vec<_> = stats.parent_counts.iter().map(|(a, b)| (*a, *b)).collect();
6363
parent_counts.sort_by_key(|e| e.0);

gix/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ serde = [ "dep:serde",
6868
"gix-ignore/serde",
6969
"gix-revision/serde",
7070
"gix-worktree/serde",
71+
"gix-commitgraph/serde",
7172
"gix-credentials/serde"]
7273

7374
## Re-export the progress tree root which allows to obtain progress from various functions which take `impl gix::Progress`.
@@ -148,6 +149,7 @@ gix-prompt = { version = "^0.5.0", path = "../gix-prompt" }
148149
gix-index = { version = "^0.16.1", path = "../gix-index" }
149150
gix-worktree = { version = "^0.17.1", path = "../gix-worktree" }
150151
gix-hashtable = { version = "^0.2.0", path = "../gix-hashtable" }
152+
gix-commitgraph = { version = "^0.14.0", path = "../gix-commitgraph" }
151153

152154
prodash = { version = "23.1", optional = true, default-features = false, features = ["progress-tree"] }
153155
once_cell = "1.14.0"

gix/src/commit.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub mod describe {
5252
#[allow(missing_docs)]
5353
pub enum Error {
5454
#[error(transparent)]
55-
Describe(#[from] gix_revision::describe::Error<gix_odb::store::find::Error>),
55+
Describe(#[from] gix_revision::describe::Error),
5656
#[error("Could not produce an unambiguous shortened id for formatting.")]
5757
ShortId(#[from] crate::id::shorten::Error),
5858
#[error(transparent)]
@@ -201,15 +201,18 @@ pub mod describe {
201201
/// to save ~40% of time.
202202
pub fn try_resolve(&self) -> Result<Option<Resolution<'repo>>, Error> {
203203
// TODO: dirty suffix with respective dirty-detection
204-
let outcome = gix_revision::describe(
205-
&self.id,
204+
let mut graph = gix_revision::Graph::new(
206205
|id, buf| {
207-
Ok(self
208-
.repo
206+
self.repo
209207
.objects
210-
.try_find(id, buf)?
211-
.and_then(|d| d.try_into_commit_iter()))
208+
.try_find(id, buf)
209+
.map(|r| r.and_then(|d| d.try_into_commit_iter()))
212210
},
211+
gix_commitgraph::Graph::from_info_dir(self.repo.objects.store_ref().path().join("info")).ok(),
212+
);
213+
let outcome = gix_revision::describe(
214+
&self.id,
215+
&mut graph,
213216
gix_revision::describe::Options {
214217
name_by_oid: self.select.names(self.repo)?,
215218
fallback_to_oid: self.id_as_fallback,
@@ -218,7 +221,7 @@ pub mod describe {
218221
},
219222
)?;
220223

221-
Ok(outcome.map(|outcome| crate::commit::describe::Resolution {
224+
Ok(outcome.map(|outcome| Resolution {
222225
outcome,
223226
id: self.id.attach(self.repo),
224227
}))

gix/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
// APIs/instances anyway.
6969
pub use gix_actor as actor;
7070
pub use gix_attributes as attrs;
71+
pub use gix_commitgraph as commitgraph;
7172
pub use gix_credentials as credentials;
7273
pub use gix_date as date;
7374
pub use gix_features as features;

0 commit comments

Comments
 (0)