Skip to content

Commit c42064d

Browse files
committed
feat: add revision component behind a feature toggle.
1 parent 397024b commit c42064d

File tree

22 files changed

+53
-27
lines changed

22 files changed

+53
-27
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ default = ["max-performance-safe", "comfort", "extras"]
5858
#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.
5959

6060
## Various additional features and capabilities that are not necessarily part of what most users would need.
61-
extras = ["worktree-stream", "worktree-archive", "blob-diff"]
61+
extras = ["worktree-stream", "worktree-archive", "blob-diff", "revision"]
6262

6363
## Various progress-related features that improve the look of progress message units.
6464
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
@@ -68,6 +68,9 @@ comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human
6868
#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
6969
#! Providers of libraries should only activate
7070

71+
## Make revspec parsing possible, as well describing revision.
72+
revision = ["gix-revision/describe"]
73+
7174
## Make it possible to diff blobs line by line. Note that this feature is integral for implementing tree-diffs as well due to the handling of rename-tracking,
7275
## which relies on line-by-line diffs in some cases.
7376
blob-diff = ["gix-diff/blob"]
@@ -187,7 +190,8 @@ gix-hash = { version = "^0.12.0", path = "../gix-hash" }
187190
gix-object = { version = "^0.35.0", path = "../gix-object" }
188191
gix-actor = { version = "^0.25.0", path = "../gix-actor" }
189192
gix-pack = { version = "^0.41.0", path = "../gix-pack", default-features = false, features = ["object-cache-dynamic"] }
190-
gix-revision = { version = "^0.20.0", path = "../gix-revision" }
193+
gix-revision = { version = "^0.20.0", path = "../gix-revision", default-features = false }
194+
gix-revwalk = { version = "^0.6.0", path = "../gix-revwalk" }
191195
gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate" }
192196

193197
gix-path = { version = "^0.9.0", path = "../gix-path" }

gix/src/commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub enum Error {
2222
}
2323

2424
///
25+
#[cfg(feature = "revision")]
2526
pub mod describe {
2627
use std::borrow::Cow;
2728

@@ -197,7 +198,7 @@ pub mod describe {
197198
/// to save ~40% of time.
198199
pub fn try_resolve(&self) -> Result<Option<Resolution<'repo>>, Error> {
199200
// TODO: dirty suffix with respective dirty-detection
200-
let mut graph = gix_revision::Graph::new(
201+
let mut graph = gix_revwalk::Graph::new(
201202
|id, buf| {
202203
self.repo
203204
.objects

gix/src/config/cache/init.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl Cache {
151151
true,
152152
lenient_config,
153153
)?;
154+
#[cfg(feature = "revision")]
154155
let object_kind_hint = util::disambiguate_hint(&config, lenient_config)?;
155156
let (static_pack_cache_limit_bytes, pack_cache_bytes, object_cache_bytes) =
156157
util::parse_object_caches(&config, lenient_config, filter_config_section)?;
@@ -159,6 +160,7 @@ impl Cache {
159160
resolved: config.into(),
160161
use_multi_pack_index,
161162
object_hash,
163+
#[cfg(feature = "revision")]
162164
object_kind_hint,
163165
static_pack_cache_limit_bytes,
164166
pack_cache_bytes,
@@ -213,12 +215,16 @@ impl Cache {
213215
false,
214216
self.lenient_config,
215217
)?;
216-
let object_kind_hint = util::disambiguate_hint(config, self.lenient_config)?;
218+
219+
#[cfg(feature = "revision")]
220+
{
221+
let object_kind_hint = util::disambiguate_hint(config, self.lenient_config)?;
222+
self.object_kind_hint = object_kind_hint;
223+
}
217224
let reflog = util::query_refupdates(config, self.lenient_config)?;
218225

219226
self.hex_len = hex_len;
220227
self.ignore_case = ignore_case;
221-
self.object_kind_hint = object_kind_hint;
222228
self.reflog = reflog;
223229

224230
self.user_agent = Default::default();

gix/src/config/cache/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use super::Error;
33
use crate::{
44
config,
55
config::tree::{gitoxide, Core},
6-
revision::spec::parse::ObjectKindHint,
76
};
87

98
pub(crate) fn interpolate_context<'a>(
@@ -103,10 +102,11 @@ pub(crate) fn parse_core_abbrev(
103102
.flatten())
104103
}
105104

105+
#[cfg(feature = "revision")]
106106
pub(crate) fn disambiguate_hint(
107107
config: &gix_config::File<'static>,
108108
lenient_config: bool,
109-
) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> {
109+
) -> Result<Option<crate::revision::spec::parse::ObjectKindHint>, config::key::GenericErrorWithValue> {
110110
match config.string_by_key("core.disambiguate") {
111111
None => Ok(None),
112112
Some(value) => Core::DISAMBIGUATE

gix/src/config/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub use gix_config::*;
22
use gix_features::threading::OnceCell;
33

4-
use crate::{bstr::BString, repository::identity, revision::spec, Repository};
4+
use crate::{bstr::BString, repository::identity, Repository};
55

66
pub(crate) mod cache;
77
mod snapshot;
@@ -513,7 +513,8 @@ pub(crate) struct Cache {
513513
/// The config section filter from the options used to initialize this instance. Keep these in sync!
514514
filter_config_section: fn(&gix_config::file::Metadata) -> bool,
515515
/// The object kind to pick if a prefix is ambiguous.
516-
pub object_kind_hint: Option<spec::parse::ObjectKindHint>,
516+
#[cfg(feature = "revision")]
517+
pub object_kind_hint: Option<crate::revision::spec::parse::ObjectKindHint>,
517518
/// If true, we are on a case-insensitive file system.
518519
pub ignore_case: bool,
519520
/// If true, we should default what's possible if something is misconfigured, on case by case basis, to be more resilient.

gix/src/config/tree/sections/core.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ mod autocrlf {
270270
}
271271
}
272272

273+
#[cfg(feature = "revision")]
273274
mod disambiguate {
274275
use std::borrow::Cow;
275276

@@ -425,7 +426,9 @@ mod validate {
425426

426427
pub struct Disambiguate;
427428
impl keys::Validate for Disambiguate {
429+
#[cfg_attr(not(feature = "revision"), allow(unused_variables))]
428430
fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
431+
#[cfg(feature = "revision")]
429432
super::Core::DISAMBIGUATE.try_into_object_kind_hint(value.into())?;
430433
Ok(())
431434
}

gix/src/ext/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
pub use object_id::ObjectIdExt;
22
pub use reference::ReferenceExt;
3+
#[cfg(feature = "revision")]
34
pub use rev_spec::RevSpecExt;
45
pub use tree::{TreeEntryExt, TreeEntryRefExt, TreeIterExt};
56

67
mod object_id;
78
mod reference;
9+
#[cfg(feature = "revision")]
810
mod rev_spec;
911
mod tree;

gix/src/id.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ops::Deref;
33

44
use gix_hash::{oid, ObjectId};
55

6-
use crate::{object::find, revision, Id, Object};
6+
use crate::{object::find, Id, Object};
77

88
/// An [object id][ObjectId] infused with a [`Repository`][crate::Repository].
99
impl<'repo> Id<'repo> {
@@ -103,9 +103,8 @@ impl<'repo> Id<'repo> {
103103

104104
impl<'repo> Id<'repo> {
105105
/// Obtain a platform for traversing ancestors of this commit.
106-
///
107-
pub fn ancestors(&self) -> revision::walk::Platform<'repo> {
108-
revision::walk::Platform::new(Some(self.inner), self.repo)
106+
pub fn ancestors(&self) -> crate::revision::walk::Platform<'repo> {
107+
crate::revision::walk::Platform::new(Some(self.inner), self.repo)
109108
}
110109
}
111110

gix/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ pub use gix_prompt as prompt;
105105
pub use gix_protocol as protocol;
106106
pub use gix_ref as refs;
107107
pub use gix_refspec as refspec;
108+
pub use gix_revwalk as revwalk;
108109
pub use gix_sec as sec;
109110
pub use gix_tempfile as tempfile;
110111
pub use gix_trace as trace;

0 commit comments

Comments
 (0)