Skip to content

Commit 1a0778e

Browse files
committed
feat: allow disabling the blob-diff capability
This also removes all diff capabilities.
1 parent 553d535 commit 1a0778e

File tree

11 files changed

+33
-7
lines changed

11 files changed

+33
-7
lines changed

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"]
61+
extras = ["worktree-stream", "worktree-archive", "blob-diff"]
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,10 @@ 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 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,
72+
## which relies on line-by-line diffs in some cases.
73+
blob-diff = ["gix-diff/blob"]
74+
7175
## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.
7276
worktree-stream = ["gix-worktree-stream"]
7377

@@ -189,7 +193,7 @@ gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate" }
189193
gix-path = { version = "^0.9.0", path = "../gix-path" }
190194
gix-url = { version = "^0.22.0", path = "../gix-url" }
191195
gix-traverse = { version = "^0.31.0", path = "../gix-traverse" }
192-
gix-diff = { version = "^0.34.0", path = "../gix-diff" }
196+
gix-diff = { version = "^0.34.0", path = "../gix-diff", default-features = false }
193197
gix-mailmap = { version = "^0.17.0", path = "../gix-mailmap" }
194198
gix-features = { version = "^0.33.0", path = "../gix-features", features = ["progress", "once_cell"] }
195199
gix-trace = { version = "^0.1.3", path = "../gix-trace" }

gix/src/config/cache/access.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
config,
1010
config::{
1111
boolean,
12-
cache::util::{ApplyLeniency, ApplyLeniencyDefault, ApplyLeniencyDefaultValue},
12+
cache::util::{ApplyLeniency, ApplyLeniencyDefaultValue},
1313
checkout_options,
1414
tree::{gitoxide, Checkout, Core, Key},
1515
Cache,
@@ -21,7 +21,9 @@ use crate::{
2121

2222
/// Access
2323
impl Cache {
24+
#[cfg(feature = "blob-diff")]
2425
pub(crate) fn diff_algorithm(&self) -> Result<gix_diff::blob::Algorithm, config::diff::algorithm::Error> {
26+
use crate::config::cache::util::ApplyLeniencyDefault;
2527
use crate::config::diff::algorithm::Error;
2628
self.diff_algorithm
2729
.get_or_try_init(|| {
@@ -82,6 +84,7 @@ impl Cache {
8284
})
8385
}
8486

87+
#[cfg(feature = "blob-diff")]
8588
pub(crate) fn diff_renames(
8689
&self,
8790
) -> Result<Option<crate::object::tree::diff::Rewrites>, crate::object::tree::diff::rewrites::Error> {

gix/src/config/cache/init.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ impl Cache {
174174
user_agent: Default::default(),
175175
personas: Default::default(),
176176
url_rewrite: Default::default(),
177+
#[cfg(feature = "blob-diff")]
177178
diff_renames: Default::default(),
178179
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
179180
url_scheme: Default::default(),
181+
#[cfg(feature = "blob-diff")]
180182
diff_algorithm: Default::default(),
181183
})
182184
}
@@ -222,8 +224,11 @@ impl Cache {
222224
self.user_agent = Default::default();
223225
self.personas = Default::default();
224226
self.url_rewrite = Default::default();
225-
self.diff_renames = Default::default();
226-
self.diff_algorithm = Default::default();
227+
#[cfg(feature = "blob-diff")]
228+
{
229+
self.diff_renames = Default::default();
230+
self.diff_algorithm = Default::default();
231+
}
227232
(
228233
self.static_pack_cache_limit_bytes,
229234
self.pack_cache_bytes,

gix/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,13 @@ pub(crate) struct Cache {
495495
/// A lazily loaded rewrite list for remote urls
496496
pub(crate) url_rewrite: OnceCell<crate::remote::url::Rewrite>,
497497
/// The lazy-loaded rename information for diffs.
498+
#[cfg(feature = "blob-diff")]
498499
pub(crate) diff_renames: OnceCell<Option<crate::object::tree::diff::Rewrites>>,
499500
/// A lazily loaded mapping to know which url schemes to allow
500501
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
501502
pub(crate) url_scheme: OnceCell<crate::remote::url::SchemePermission>,
502503
/// The algorithm to use when diffing blobs
504+
#[cfg(feature = "blob-diff")]
503505
pub(crate) diff_algorithm: OnceCell<gix_diff::blob::Algorithm>,
504506
/// The amount of bytes to use for a memory backed delta pack cache. If `Some(0)`, no cache is used, if `None`
505507
/// a standard cache is used which costs near to nothing and always pays for itself.

gix/src/config/tree/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub(crate) mod root {
3131
/// The `credential` section.
3232
pub const CREDENTIAL: sections::Credential = sections::Credential;
3333
/// The `diff` section.
34+
#[cfg(feature = "blob-diff")]
3435
pub const DIFF: sections::Diff = sections::Diff;
3536
/// The `extensions` section.
3637
pub const EXTENSIONS: sections::Extensions = sections::Extensions;
@@ -69,6 +70,7 @@ pub(crate) mod root {
6970
&Self::COMMITTER,
7071
&Self::CORE,
7172
&Self::CREDENTIAL,
73+
#[cfg(feature = "blob-diff")]
7274
&Self::DIFF,
7375
&Self::EXTENSIONS,
7476
&Self::FETCH,
@@ -90,10 +92,12 @@ pub(crate) mod root {
9092

9193
mod sections;
9294
pub use sections::{
93-
branch, checkout, core, credential, diff, extensions, fetch, gitoxide, http, index, protocol, remote, ssh, Author,
94-
Branch, Checkout, Clone, Committer, Core, Credential, Diff, Extensions, Fetch, Gitoxide, Http, Index, Init, Pack,
95+
branch, checkout, core, credential, extensions, fetch, gitoxide, http, index, protocol, remote, ssh, Author,
96+
Branch, Checkout, Clone, Committer, Core, Credential, Extensions, Fetch, Gitoxide, Http, Index, Init, Pack,
9597
Protocol, Remote, Safe, Ssh, Url, User,
9698
};
99+
#[cfg(feature = "blob-diff")]
100+
pub use sections::{diff, Diff};
97101

98102
/// Generic value implementations for static instantiation.
99103
pub mod keys;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ pub mod credential;
3737

3838
/// The `diff` top-level section.
3939
#[derive(Copy, Clone, Default)]
40+
#[cfg(feature = "blob-diff")]
4041
pub struct Diff;
42+
#[cfg(feature = "blob-diff")]
4143
pub mod diff;
4244

4345
/// The `extension` top-level section.

gix/src/object/blob.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
///
2+
#[cfg(feature = "blob-diff")]
23
pub mod diff {
34
use std::ops::Range;
45

gix/src/object/tree/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ impl<'repo> Tree<'repo> {
168168
}
169169

170170
///
171+
#[cfg(feature = "blob-diff")]
171172
pub mod diff;
172173

173174
///

gix/tests/config/tree.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ mod fetch {
204204
}
205205
}
206206

207+
#[cfg(feature = "blob-diff")]
207208
mod diff {
208209
use gix::{
209210
config::tree::{Diff, Key},

gix/tests/object/tree/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::util::{named_repo, named_subrepo_opts};
22

3+
#[cfg(feature = "blob-diff")]
34
mod diff;
45

56
#[test]

justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ check:
4242
if cargo check -p gix-packetline --all-features 2>/dev/null; then false; else true; fi
4343
if cargo check -p gix-transport --all-features 2>/dev/null; then false; else true; fi
4444
if cargo check -p gix-protocol --all-features 2>/dev/null; then false; else true; fi
45+
if cargo tree -p gix --no-default-features -i imara-diff 2>/dev/null; then false; else true; fi
4546
cargo check --no-default-features --features lean
4647
cargo check --no-default-features --features lean-async
4748
cargo check --no-default-features --features max
@@ -111,6 +112,7 @@ check:
111112
cargo check -p gix --no-default-features --features max-performance
112113
cargo check -p gix --no-default-features --features max-performance-safe
113114
cargo check -p gix --no-default-features --features progress-tree
115+
cargo check -p gix --no-default-features --features blob-diff
114116
cargo check -p gix --no-default-features
115117
cargo check -p gix-odb --features serde
116118
cargo check --no-default-features --features max-control

0 commit comments

Comments
 (0)