History

feat: allow disabling the `blob-diff` capability

This also removes all diff capabilities.

Sebastian Thiel committed 3 years ago

Commit fea044e1 parent c5ec24411 files · +33 −7Browse files

Unified · Split

11 files
  1. gix/Cargo.toml +6 −2
  2. gix/src/config/cache/access.rs +4 −1
  3. gix/src/config/cache/init.rs +7 −2
  4. gix/src/config/mod.rs +2 −0
  5. gix/src/config/tree/mod.rs +6 −2
  6. gix/src/config/tree/sections/mod.rs +2 −0
  7. gix/src/object/blob.rs +1 −0
  8. gix/src/object/tree/mod.rs +1 −0
  9. gix/tests/config/tree.rs +1 −0
  10. gix/tests/object/tree/mod.rs +1 −0
  11. justfile +2 −0
gix/Cargo.toml+6−2
@@ -58,7 +58,7 @@ default = ["max-performance-safe", "comfort", "extras"] · 57 unmodified lines
58#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.58#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.
59 59
60## Various additional features and capabilities that are not necessarily part of what most users would need.60## Various additional features and capabilities that are not necessarily part of what most users would need.
61extras = ["worktree-stream", "worktree-archive"]61extras = ["worktree-stream", "worktree-archive", "blob-diff"]
62 62
63## Various progress-related features that improve the look of progress message units.63## Various progress-related features that improve the look of progress message units.
64comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]64comfort = ["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 · 3 unmodified lines
68#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.68#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
69#! Providers of libraries should only activate69#! Providers of libraries should only activate
70 70
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.
73blob-diff = ["gix-diff/blob"]
74
71## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.75## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.
72worktree-stream = ["gix-worktree-stream"]76worktree-stream = ["gix-worktree-stream"]
73 77
@@ -189,7 +193,7 @@ gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate" } · 115 unmodified lines
189gix-path = { version = "^0.9.0", path = "../gix-path" }193gix-path = { version = "^0.9.0", path = "../gix-path" }
190gix-url = { version = "^0.22.0", path = "../gix-url" }194gix-url = { version = "^0.22.0", path = "../gix-url" }
191gix-traverse = { version = "^0.31.0", path = "../gix-traverse" }195gix-traverse = { version = "^0.31.0", path = "../gix-traverse" }
192gix-diff = { version = "^0.34.0", path = "../gix-diff" }196gix-diff = { version = "^0.34.0", path = "../gix-diff", default-features = false }
193gix-mailmap = { version = "^0.17.0", path = "../gix-mailmap" }197gix-mailmap = { version = "^0.17.0", path = "../gix-mailmap" }
194gix-features = { version = "^0.33.0", path = "../gix-features", features = ["progress", "once_cell"] }198gix-features = { version = "^0.33.0", path = "../gix-features", features = ["progress", "once_cell"] }
195gix-trace = { version = "^0.1.3", path = "../gix-trace" }199gix-trace = { version = "^0.1.3", path = "../gix-trace" }
gix/src/config/cache/access.rs+4−1
@@ -9,7 +9,7 @@ use crate::{ · 8 unmodified lines
9 config,9 config,
10 config::{10 config::{
11 boolean,11 boolean,
12 cache::util::{ApplyLeniency, ApplyLeniencyDefault, ApplyLeniencyDefaultValue},12 cache::util::{ApplyLeniency, ApplyLeniencyDefaultValue},
13 checkout_options,13 checkout_options,
14 tree::{gitoxide, Checkout, Core, Key},14 tree::{gitoxide, Checkout, Core, Key},
15 Cache,15 Cache,
@@ -21,7 +21,9 @@ use crate::{ · 5 unmodified lines
21 21
22/// Access22/// Access
23impl Cache {23impl Cache {
24 #[cfg(feature = "blob-diff")]
24 pub(crate) fn diff_algorithm(&self) -> Result<gix_diff::blob::Algorithm, config::diff::algorithm::Error> {25 pub(crate) fn diff_algorithm(&self) -> Result<gix_diff::blob::Algorithm, config::diff::algorithm::Error> {
26 use crate::config::cache::util::ApplyLeniencyDefault;
25 use crate::config::diff::algorithm::Error;27 use crate::config::diff::algorithm::Error;
26 self.diff_algorithm28 self.diff_algorithm
27 .get_or_try_init(|| {29 .get_or_try_init(|| {
@@ -82,6 +84,7 @@ impl Cache { · 54 unmodified lines
82 })84 })
83 }85 }
84 86
87 #[cfg(feature = "blob-diff")]
85 pub(crate) fn diff_renames(88 pub(crate) fn diff_renames(
86 &self,89 &self,
87 ) -> Result<Option<crate::object::tree::diff::Rewrites>, crate::object::tree::diff::rewrites::Error> {90 ) -> Result<Option<crate::object::tree::diff::Rewrites>, crate::object::tree::diff::rewrites::Error> {
gix/src/config/cache/init.rs+7−2
@@ -174,9 +174,11 @@ impl Cache { · 173 unmodified lines
174 user_agent: Default::default(),174 user_agent: Default::default(),
175 personas: Default::default(),175 personas: Default::default(),
176 url_rewrite: Default::default(),176 url_rewrite: Default::default(),
177 #[cfg(feature = "blob-diff")]
177 diff_renames: Default::default(),178 diff_renames: Default::default(),
178 #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]179 #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
179 url_scheme: Default::default(),180 url_scheme: Default::default(),
181 #[cfg(feature = "blob-diff")]
180 diff_algorithm: Default::default(),182 diff_algorithm: Default::default(),
181 })183 })
182 }184 }
@@ -222,8 +224,11 @@ impl Cache { · 39 unmodified lines
222 self.user_agent = Default::default();224 self.user_agent = Default::default();
223 self.personas = Default::default();225 self.personas = Default::default();
224 self.url_rewrite = Default::default();226 self.url_rewrite = Default::default();
225 self.diff_renames = Default::default();227 #[cfg(feature = "blob-diff")]
226 self.diff_algorithm = Default::default();228 {
229 self.diff_renames = Default::default();
230 self.diff_algorithm = Default::default();
231 }
227 (232 (
228 self.static_pack_cache_limit_bytes,233 self.static_pack_cache_limit_bytes,
229 self.pack_cache_bytes,234 self.pack_cache_bytes,
gix/src/config/mod.rs+2−0
@@ -495,11 +495,13 @@ pub(crate) struct Cache { · 494 unmodified lines
495 /// A lazily loaded rewrite list for remote urls495 /// A lazily loaded rewrite list for remote urls
496 pub(crate) url_rewrite: OnceCell<crate::remote::url::Rewrite>,496 pub(crate) url_rewrite: OnceCell<crate::remote::url::Rewrite>,
497 /// The lazy-loaded rename information for diffs.497 /// The lazy-loaded rename information for diffs.
498 #[cfg(feature = "blob-diff")]
498 pub(crate) diff_renames: OnceCell<Option<crate::object::tree::diff::Rewrites>>,499 pub(crate) diff_renames: OnceCell<Option<crate::object::tree::diff::Rewrites>>,
499 /// A lazily loaded mapping to know which url schemes to allow500 /// A lazily loaded mapping to know which url schemes to allow
500 #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]501 #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
501 pub(crate) url_scheme: OnceCell<crate::remote::url::SchemePermission>,502 pub(crate) url_scheme: OnceCell<crate::remote::url::SchemePermission>,
502 /// The algorithm to use when diffing blobs503 /// The algorithm to use when diffing blobs
504 #[cfg(feature = "blob-diff")]
503 pub(crate) diff_algorithm: OnceCell<gix_diff::blob::Algorithm>,505 pub(crate) diff_algorithm: OnceCell<gix_diff::blob::Algorithm>,
504 /// The amount of bytes to use for a memory backed delta pack cache. If `Some(0)`, no cache is used, if `None`506 /// The amount of bytes to use for a memory backed delta pack cache. If `Some(0)`, no cache is used, if `None`
505 /// a standard cache is used which costs near to nothing and always pays for itself.507 /// a standard cache is used which costs near to nothing and always pays for itself.
gix/src/config/tree/mod.rs+6−2
@@ -31,6 +31,7 @@ pub(crate) mod root { · 30 unmodified lines
31 /// The `credential` section.31 /// The `credential` section.
32 pub const CREDENTIAL: sections::Credential = sections::Credential;32 pub const CREDENTIAL: sections::Credential = sections::Credential;
33 /// The `diff` section.33 /// The `diff` section.
34 #[cfg(feature = "blob-diff")]
34 pub const DIFF: sections::Diff = sections::Diff;35 pub const DIFF: sections::Diff = sections::Diff;
35 /// The `extensions` section.36 /// The `extensions` section.
36 pub const EXTENSIONS: sections::Extensions = sections::Extensions;37 pub const EXTENSIONS: sections::Extensions = sections::Extensions;
@@ -69,6 +70,7 @@ pub(crate) mod root { · 32 unmodified lines
69 &Self::COMMITTER,70 &Self::COMMITTER,
70 &Self::CORE,71 &Self::CORE,
71 &Self::CREDENTIAL,72 &Self::CREDENTIAL,
73 #[cfg(feature = "blob-diff")]
72 &Self::DIFF,74 &Self::DIFF,
73 &Self::EXTENSIONS,75 &Self::EXTENSIONS,
74 &Self::FETCH,76 &Self::FETCH,
@@ -90,10 +92,12 @@ pub(crate) mod root { · 15 unmodified lines
90 92
91mod sections;93mod sections;
92pub use sections::{94pub use sections::{
93 branch, checkout, core, credential, diff, extensions, fetch, gitoxide, http, index, protocol, remote, ssh, Author,95 branch, checkout, core, credential, extensions, fetch, gitoxide, http, index, protocol, remote, ssh, Author,
94 Branch, Checkout, Clone, Committer, Core, Credential, Diff, Extensions, Fetch, Gitoxide, Http, Index, Init, Pack,96 Branch, Checkout, Clone, Committer, Core, Credential, Extensions, Fetch, Gitoxide, Http, Index, Init, Pack,
95 Protocol, Remote, Safe, Ssh, Url, User,97 Protocol, Remote, Safe, Ssh, Url, User,
96};98};
99#[cfg(feature = "blob-diff")]
100pub use sections::{diff, Diff};
97 101
98/// Generic value implementations for static instantiation.102/// Generic value implementations for static instantiation.
99pub mod keys;103pub mod keys;
gix/src/config/tree/sections/mod.rs+2−0
@@ -37,7 +37,9 @@ pub mod credential; · 36 unmodified lines
37 37
38/// The `diff` top-level section.38/// The `diff` top-level section.
39#[derive(Copy, Clone, Default)]39#[derive(Copy, Clone, Default)]
40#[cfg(feature = "blob-diff")]
40pub struct Diff;41pub struct Diff;
42#[cfg(feature = "blob-diff")]
41pub mod diff;43pub mod diff;
42 44
43/// The `extension` top-level section.45/// The `extension` top-level section.
gix/src/object/blob.rs+1−0
@@ -1,4 +1,5 @@
1///1///
2#[cfg(feature = "blob-diff")]
2pub mod diff {3pub mod diff {
3 use std::ops::Range;4 use std::ops::Range;
4 5
gix/src/object/tree/mod.rs+1−0
@@ -168,6 +168,7 @@ impl<'repo> Tree<'repo> { · 167 unmodified lines
168}168}
169 169
170///170///
171#[cfg(feature = "blob-diff")]
171pub mod diff;172pub mod diff;
172 173
173///174///
gix/tests/config/tree.rs+1−0
@@ -204,6 +204,7 @@ mod fetch { · 203 unmodified lines
204 }204 }
205}205}
206 206
207#[cfg(feature = "blob-diff")]
207mod diff {208mod diff {
208 use gix::{209 use gix::{
209 config::tree::{Diff, Key},210 config::tree::{Diff, Key},
gix/tests/object/tree/mod.rs+1−0
@@ -1,5 +1,6 @@
1use crate::util::{named_repo, named_subrepo_opts};1use crate::util::{named_repo, named_subrepo_opts};
2 2
3#[cfg(feature = "blob-diff")]
3mod diff;4mod diff;
4 5
5#[test]6#[test]
justfile+2−0
@@ -42,6 +42,7 @@ check: · 41 unmodified lines
42 if cargo check -p gix-packetline --all-features 2>/dev/null; then false; else true; fi42 if cargo check -p gix-packetline --all-features 2>/dev/null; then false; else true; fi
43 if cargo check -p gix-transport --all-features 2>/dev/null; then false; else true; fi43 if cargo check -p gix-transport --all-features 2>/dev/null; then false; else true; fi
44 if cargo check -p gix-protocol --all-features 2>/dev/null; then false; else true; fi44 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
45 cargo check --no-default-features --features lean46 cargo check --no-default-features --features lean
46 cargo check --no-default-features --features lean-async47 cargo check --no-default-features --features lean-async
47 cargo check --no-default-features --features max48 cargo check --no-default-features --features max
@@ -111,6 +112,7 @@ check: · 63 unmodified lines
111 cargo check -p gix --no-default-features --features max-performance112 cargo check -p gix --no-default-features --features max-performance
112 cargo check -p gix --no-default-features --features max-performance-safe113 cargo check -p gix --no-default-features --features max-performance-safe
113 cargo check -p gix --no-default-features --features progress-tree114 cargo check -p gix --no-default-features --features progress-tree
115 cargo check -p gix --no-default-features --features blob-diff
114 cargo check -p gix --no-default-features116 cargo check -p gix --no-default-features
115 cargo check -p gix-odb --features serde117 cargo check -p gix-odb --features serde
116 cargo check --no-default-features --features max-control118 cargo check --no-default-features --features max-control