Skip to content

Commit c28bcec

Browse files
committed
feat: support avoiding usage of fast-sha1 in git-features separately.
That way one has an angle on compile failures in client libraries, see o2sh/onefetch#752 for motivation.
1 parent bd02b39 commit c28bcec

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ check: ## Build all code in suitable configurations
124124
&& cargo check --no-default-features --features blocking-network-client,blocking-http-transport \
125125
&& cargo check --no-default-features --features one-stop-shop \
126126
&& cargo check --no-default-features --features max-performance \
127+
&& cargo check --no-default-features --features max-performance-safe \
127128
&& cargo check --no-default-features
128129
cd git-odb && cargo check --features serde1
129130
cd cargo-smart-release && cargo check --all

git-repository/Cargo.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,23 @@ serde1 = [ "serde",
6161
"git-mailmap/serde1",
6262
"git-attributes/serde1",
6363
"git-revision/serde1"]
64-
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
65-
## **Note** that
6664

67-
max-performance = [ "git-features/fast-sha1",
68-
"git-features/parallel",
69-
"git-features/zlib-ng-compat",
70-
"git-pack/pack-cache-lru-static",
71-
"git-pack/pack-cache-lru-dynamic"]
65+
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
66+
## Note that some platforms might suffer from compile failures, which is when `max-performance-safe` should be used.
67+
max-performance = [ "fast-sha1", "max-performance-safe" ]
68+
69+
## If enabled, use assembly versions of sha1 on supported platforms.
70+
## This might cause compile failures as well which is why it can be turned off separately.
71+
fast-sha1 = [ "git-features/fast-sha1" ]
72+
73+
## Activate features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases, skipping the ones known to cause compile failures
74+
## on some platforms.
75+
max-performance-safe = [
76+
"git-features/parallel",
77+
"git-features/zlib-ng-compat",
78+
"git-pack/pack-cache-lru-static",
79+
"git-pack/pack-cache-lru-dynamic"
80+
]
7281
## Re-export stability tier 2 crates for convenience and make `Repository` struct fields with types from these crates publicly accessible.
7382
## Doing so is less stable than the stability tier 1 that `git-repository` is a member of.
7483
unstable = ["git-mailmap", "git-credentials"]

git-repository/src/repository/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ impl crate::Repository {
4141
/// Use the `GITOXIDE_OBJECT_CACHE_MEMORY=16mb` to set the given amount of memory to store full objects, on a per-thread basis.
4242
pub fn apply_environment(self) -> Self {
4343
// We have no cache types available without this flag currently. Maybe this should change at some point.
44-
#[cfg(not(feature = "max-performance"))]
44+
#[cfg(not(feature = "max-performance-safe"))]
4545
return self;
46-
#[cfg(feature = "max-performance")]
46+
#[cfg(feature = "max-performance-safe")]
4747
{
4848
let pack_cache_disabled = std::env::var_os("GITOXIDE_DISABLE_PACK_CACHE").is_some();
4949
let mut this = self;
@@ -69,7 +69,7 @@ impl crate::Repository {
6969
}
7070
}
7171

72-
#[cfg(feature = "max-performance")]
72+
#[cfg(feature = "max-performance-safe")]
7373
fn parse_bytes_from_var(name: &str) -> Option<usize> {
7474
std::env::var(name)
7575
.ok()

git-repository/src/repository/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ impl crate::Repository {
1515
work_tree,
1616
common_dir,
1717
objects: {
18-
#[cfg(feature = "max-performance")]
18+
#[cfg(feature = "max-performance-safe")]
1919
{
2020
objects.with_pack_cache(|| Box::new(git_pack::cache::lru::StaticLinkedList::<64>::default()))
2121
}
22-
#[cfg(not(feature = "max-performance"))]
22+
#[cfg(not(feature = "max-performance-safe"))]
2323
{
2424
objects
2525
}

0 commit comments

Comments
 (0)