Skip to content

Commit 3832916

Browse files
committed
feat: add sha1 and sha256 features to gix.
This way one can control which hashes are compiled in exactly, while having reasonable defaults automatically.
1 parent e71c703 commit 3832916

34 files changed

Lines changed: 224 additions & 41 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ default = ["max"]
4242
##
4343
## When used in conjunction with `http-client-curl-rustls`, the `openssl` crates will still be compiled, but won't be used. To bypass this, disable
4444
## default dependencies and specify the features yourself.
45-
max = ["max-control", "fast", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-blocking-client", "http-client-curl-openssl"]
45+
max = ["hashes", "max-control", "fast", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-blocking-client", "http-client-curl-openssl"]
4646

4747
## Like `max`, but only Rust is allowed.
4848
##
@@ -51,22 +51,23 @@ max = ["max-control", "fast", "gitoxide-core-tools-query", "gitoxide-core-tools-
5151
## This uses Rust's HTTP implementation.
5252
##
5353
## As fast as possible, with TUI progress, progress line rendering with auto-configuration, all transports available but less mature pure Rust HTTP implementation, all `ein` tools, CLI colors and local-time support, JSON output, regex support for rev-specs.
54-
max-pure = ["max-control", "http-client-reqwest", "gitoxide-core-blocking-client"]
54+
max-pure = ["hashes", "max-control", "http-client-reqwest", "gitoxide-core-blocking-client"]
5555

5656
## Like `max`, but with more control for configuration. See the *Package Maintainers* headline for more information.
57+
## Needs to chose its own hash(es).
5758
max-control = ["tracing", "fast", "pretty-cli", "gitoxide-core-tools", "prodash-render-line", "prodash-render-tui", "prodash/render-line-autoconfigure", "gix/revparse-regex"]
5859

5960
## All the good stuff, with less fanciness for smaller binaries.
6061
##
6162
## As fast as possible, progress line rendering, all transports based on their most mature implementation (HTTP), all `ein` tools, CLI colors and local-time support, JSON output.
62-
lean = ["fast", "tracing", "pretty-cli", "http-client-curl-openssl", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line"]
63+
lean = ["hashes", "fast", "tracing", "pretty-cli", "http-client-curl-openssl", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line"]
6364

6465
## The smallest possible build, best suitable for small single-core machines.
6566
##
6667
## This build is essentially limited to local operations without any fanciness. It does not have `gix clone`.
6768
##
6869
## Optimized for size, no parallelism thus much slower, progress line rendering.
69-
small = ["pretty-cli", "prodash-render-line", "is-terminal"]
70+
small = ["hashes", "pretty-cli", "prodash-render-line", "is-terminal"]
7071

7172
## Like lean, but uses Rusts async implementations for networking.
7273
##
@@ -77,7 +78,7 @@ small = ["pretty-cli", "prodash-render-line", "is-terminal"]
7778
##
7879
## Due to async client-networking not being implemented for most transports, this one supports only the 'git+tcp' and HTTP transport.
7980
## It uses, however, a fully asynchronous networking implementation which can serve a real-world example on how to implement custom async transports.
80-
lean-async = ["fast", "tracing", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-async-client", "prodash-render-line"]
81+
lean-async = ["hashes", "fast", "tracing", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-tools-query", "gitoxide-core-tools-corpus", "gitoxide-core-async-client", "prodash-render-line"]
8182

8283
#! ### Package Maintainers
8384
#! `*-control` features leave it to you to configure C libraries, involving choices for HTTP transport implementation.
@@ -88,6 +89,11 @@ lean-async = ["fast", "tracing", "pretty-cli", "gitoxide-core-tools", "gitoxide-
8889
#! ### Building Blocks
8990
#! Typical combinations of features of our dependencies, some of which are referred to in the `gitoxide` crate's code for conditional compilation.
9091

92+
## Provide support for all known hashes. If this isn't enabled, select an individual hash algorithms.
93+
hashes = ["sha1"]
94+
## Enable support for the SHA-1 hash throughout the `gix` crate.
95+
sha1 = ["gix/sha1"]
96+
9197
## Makes the crate execute as fast as possible by supporting parallel computation of otherwise long-running functions.
9298
## If disabled, the binary will be visibly smaller.
9399
fast = ["gix/max-performance", "gix/comfort"]

gitoxide-core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ open = "5.0.0"
9595

9696
document-features = { version = "0.2.0", optional = true }
9797

98+
[dev-dependencies]
99+
gix = { path = "../gix", default-features = false, features = ["sha1"] }
100+
98101
[package.metadata.docs.rs]
99102
features = ["document-features", "blocking-client", "organize", "estimate-hours", "serde"]
100103

gix-archive/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ doctest = false
1616

1717
[features]
1818
default = ["tar", "tar_gz", "zip"]
19+
## Enable support for the SHA-1 hash by forwarding the feature to dependencies.
20+
sha1 = ["gix-worktree-stream/sha1", "gix-object/sha1"]
1921

2022
## Enable the `tar` archive format. It has support for all information, except for object ids.
2123
tar = ["dep:tar", "dep:gix-path"]
@@ -48,11 +50,11 @@ gix-odb = { path = "../gix-odb" }
4850
gix-worktree = { path = "../gix-worktree", default-features = false, features = [
4951
"attributes",
5052
] }
51-
gix-hash = { path = "../gix-hash" }
53+
gix-hash = { path = "../gix-hash", features = ["sha1"] }
5254
gix-attributes = { path = "../gix-attributes" }
5355
gix-object = { path = "../gix-object" }
5456
gix-filter = { path = "../gix-filter" }
5557

5658
[package.metadata.docs.rs]
5759
all-features = true
58-
features = ["document-features"]
60+
features = ["sha1", "document-features"]

gix-blame/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ authors = ["Christoph Rüßler <christoph.ruessler@mailbox.org>", "Sebastian Thi
1010
edition = "2021"
1111
rust-version = "1.82"
1212

13+
[features]
14+
## Enable support for the SHA-1 hash by forwarding the feature to dependencies.
15+
sha1 = [
16+
"gix-commitgraph/sha1",
17+
"gix-diff/sha1",
18+
"gix-hash/sha1",
19+
"gix-object/sha1",
20+
"gix-revwalk/sha1",
21+
"gix-traverse/sha1",
22+
"gix-worktree/sha1",
23+
]
24+
1325
[dependencies]
1426
gix-error = { version = "^0.2.0", path = "../gix-error" }
1527
gix-commitgraph = { version = "^0.34.0", path = "../gix-commitgraph" }
@@ -33,3 +45,6 @@ gix-index = { path = "../gix-index" }
3345
gix-odb = { path = "../gix-odb" }
3446
gix-testtools = { path = "../tests/tools" }
3547
pretty_assertions = "1.4.0"
48+
49+
[package.metadata.docs.rs]
50+
features = ["sha1"]

gix-commitgraph/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rust-version = "1.82"
1616
doctest = false
1717

1818
[features]
19-
## Support for SHA1 hashes and digests.
19+
## Enable support for the SHA-1 hash by enabling the respective feature in the `gix-hash` crate.
2020
sha1 = ["gix-hash/sha1"]
2121
## Data structures implement `serde::Serialize` and `serde::Deserialize`
2222
serde = ["dep:serde", "gix-hash/serde", "bstr/serde"]

gix-config/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rust-version = "1.82"
1515
autotests = false
1616

1717
[features]
18-
## Support for SHA1 hashes and digests.
18+
## Enable support for the SHA-1 hash by forwarding the feature to dependencies.
1919
sha1 = ["gix-ref/sha1"]
2020
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
2121
serde = ["dep:serde", "bstr/serde", "gix-sec/serde", "gix-ref/serde", "gix-glob/serde", "gix-config-value/serde"]
@@ -40,6 +40,7 @@ document-features = { version = "0.2.0", optional = true }
4040

4141
[dev-dependencies]
4242
criterion = "0.8.0"
43+
gix-config = { path = ".", features = ["sha1"] }
4344

4445
[[bench]]
4546
name = "large_config_file"

gix-diff/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ autotests = false
1414

1515
[features]
1616
default = ["blob", "index"]
17-
## Support for SHA1 hashes and digests.
17+
## Enable support for the SHA-1 hash by enabling the respective feature in the `gix-hash` crate.
1818
sha1 = ["gix-hash/sha1"]
1919
## Enable diffing of blobs using imara-diff.
2020
blob = [
@@ -73,6 +73,7 @@ document-features = { version = "0.2.0", optional = true }
7373
[dev-dependencies]
7474
criterion = "0.8.0"
7575
imara-diff-v2 = { version = "0.2.0", package = "imara-diff" }
76+
gix-hash = { path = "../gix-hash", features = ["sha1"] }
7677

7778
[package.metadata.docs.rs]
7879
all-features = true

gix-dir/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ rust-version = "1.82"
1414
doctest = false
1515
test = false
1616

17+
[features]
18+
## Enable support for the SHA-1 hash by forwarding the feature to dependencies.
19+
sha1 = ["gix-discover/sha1", "gix-index/sha1", "gix-object/sha1", "gix-worktree/sha1"]
20+
1721
[dependencies]
1822
gix-trace = { version = "^0.1.18", path = "../gix-trace" }
1923
gix-index = { version = "^0.48.0", path = "../gix-index" }
@@ -33,3 +37,6 @@ thiserror = "2.0.18"
3337
gix-testtools = { path = "../tests/tools" }
3438
gix-fs = { path = "../gix-fs" }
3539
pretty_assertions = "1.4.0"
40+
41+
[package.metadata.docs.rs]
42+
features = ["sha1"]

gix-discover/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ rust-version = "1.82"
1414
[lib]
1515
doctest = false
1616

17+
[features]
18+
## Enable support for the SHA-1 hash by forwarding the feature to dependencies.
19+
sha1 = ["gix-ref/sha1"]
20+
1721
[dependencies]
1822
gix-sec = { version = "^0.13.1", path = "../gix-sec" }
1923
gix-path = { version = "^0.11.1", path = "../gix-path" }
@@ -36,3 +40,6 @@ defer = "0.2.1"
3640

3741
[target.'cfg(any(unix, windows))'.dev-dependencies]
3842
tempfile = "3.24.0"
43+
44+
[package.metadata.docs.rs]
45+
features = ["sha1"]

0 commit comments

Comments
 (0)