Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octopus-merge (part 1: tree-editing) #1566

Merged
merged 17 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"
version = "0.38.0"
default-run = "gix"
include = ["src/**/*", "LICENSE-*", "README.md"]
include = ["src/**/*", "/build.rs", "LICENSE-*", "README.md"]
resolver = "2"

[[bin]]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ There are various build configurations, all of them are [documented here](https:
for packagers who need to tune external dependencies.

```
# A certain way to install `gitoxide` with just Rust and a C compiler installed.
# A way to install `gitoxide` with just Rust and a C compiler installed.
# If there are problems with SSL certificates during clones, try to omit `--locked`.
cargo install gitoxide --locked --no-default-features --features max-pure

# The default installation, 'max', is the fastest, but also needs some libraries available to build successfully.
# Installing these is platform-dependent and thus can't be explained here.
# The default installation, 'max', is the fastest, but also needs `cmake` to build successfully.
# Installing it is platform-dependent.
cargo install gitoxide

# For smaller binaries and even faster build times that are traded for a less fancy CLI implementation, use `lean`
# or `lean-termion` respectively.
# For smaller binaries and even faster build times that are traded for a less fancy CLI implementation,
# use the `lean` feature.
cargo install gitoxide --locked --no-default-features --features lean
```

The following installs the latest unpublished release directly from git:
The following installs the latest unpublished `max` release directly from git:

```sh
cargo install --git https://github.com/Byron/gitoxide gitoxide
Expand Down
26 changes: 12 additions & 14 deletions gix-features/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Otherwise, a minimal yet performant implementation is used instead for a decent trade-off between compile times and run-time performance.
#[cfg(all(feature = "rustsha1", not(feature = "fast-sha1")))]
mod _impl {
use super::Sha1Digest;
use super::Digest;

/// A implementation of the Sha1 hash, which can be used once.
#[derive(Default, Clone)]
Expand All @@ -17,22 +17,20 @@ mod _impl {
self.0.update(bytes);
}
/// Finalize the hash and produce a digest.
pub fn digest(self) -> Sha1Digest {
pub fn digest(self) -> Digest {
self.0.digest().bytes()
}
}
}

/// A 20 bytes digest produced by a [`Sha1`] hash implementation.
/// A hash-digest produced by a [`Hasher`] hash implementation.
#[cfg(any(feature = "fast-sha1", feature = "rustsha1"))]
pub type Sha1Digest = [u8; 20];
pub type Digest = [u8; 20];

#[cfg(feature = "fast-sha1")]
mod _impl {
use sha1::Digest;

use super::Sha1Digest;

/// A implementation of the Sha1 hash, which can be used once.
#[derive(Default, Clone)]
pub struct Sha1(sha1::Sha1);
Expand All @@ -43,14 +41,14 @@ mod _impl {
self.0.update(bytes);
}
/// Finalize the hash and produce a digest.
pub fn digest(self) -> Sha1Digest {
pub fn digest(self) -> super::Digest {
self.0.finalize().into()
}
}
}

#[cfg(any(feature = "rustsha1", feature = "fast-sha1"))]
pub use _impl::Sha1;
pub use _impl::Sha1 as Hasher;

/// Compute a CRC32 hash from the given `bytes`, returning the CRC32 hash.
///
Expand All @@ -76,9 +74,9 @@ pub fn crc32(bytes: &[u8]) -> u32 {

/// Produce a hasher suitable for the given kind of hash.
#[cfg(any(feature = "rustsha1", feature = "fast-sha1"))]
pub fn hasher(kind: gix_hash::Kind) -> Sha1 {
pub fn hasher(kind: gix_hash::Kind) -> Hasher {
match kind {
gix_hash::Kind::Sha1 => Sha1::default(),
gix_hash::Kind::Sha1 => Hasher::default(),
}
}

Expand Down Expand Up @@ -127,7 +125,7 @@ pub fn bytes(
pub fn bytes_with_hasher(
read: &mut dyn std::io::Read,
num_bytes_from_start: u64,
mut hasher: Sha1,
mut hasher: Hasher,
progress: &mut dyn crate::progress::Progress,
should_interrupt: &std::sync::atomic::AtomicBool,
) -> std::io::Result<gix_hash::ObjectId> {
Expand Down Expand Up @@ -160,12 +158,12 @@ pub fn bytes_with_hasher(

#[cfg(any(feature = "rustsha1", feature = "fast-sha1"))]
mod write {
use crate::hash::Sha1;
use crate::hash::Hasher;

/// A utility to automatically generate a hash while writing into an inner writer.
pub struct Write<T> {
/// The hash implementation.
pub hash: Sha1,
pub hash: Hasher,
/// The inner writer.
pub inner: T,
}
Expand Down Expand Up @@ -194,7 +192,7 @@ mod write {
match object_hash {
gix_hash::Kind::Sha1 => Write {
inner,
hash: Sha1::default(),
hash: Hasher::default(),
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions gix-features/tests/hash.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use gix_features::hash::Sha1;
use gix_features::hash::Hasher;

#[cfg(not(feature = "fast-sha1"))]
#[test]
fn size_of_sha1() {
assert_eq!(std::mem::size_of::<Sha1>(), 96);
assert_eq!(std::mem::size_of::<Hasher>(), 96);
}

#[cfg(feature = "fast-sha1")]
#[test]
fn size_of_sha1() {
assert_eq!(
std::mem::size_of::<Sha1>(),
std::mem::size_of::<Hasher>(),
if cfg!(target_arch = "x86") { 96 } else { 104 }
);
}
8 changes: 8 additions & 0 deletions gix-object/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ name = "decode-objects"
harness = false
path = "./benches/decode_objects.rs"

[[bench]]
name = "edit-tree"
harness = false
path = "./benches/edit_tree.rs"


[features]
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
Expand All @@ -41,6 +46,7 @@ gix-features = { version = "^0.38.2", path = "../gix-features", features = [
"progress",
] }
gix-hash = { version = "^0.14.2", path = "../gix-hash" }
gix-hashtable = { version = "^0.5.2", path = "../gix-hashtable" }
gix-validate = { version = "^0.9.0", path = "../gix-validate" }
gix-actor = { version = "^0.32.0", path = "../gix-actor" }
gix-date = { version = "^0.9.0", path = "../gix-date" }
Expand All @@ -64,6 +70,8 @@ document-features = { version = "0.2.0", optional = true }
criterion = "0.5.1"
pretty_assertions = "1.0.0"
gix-testtools = { path = "../tests/tools" }
gix-odb = { path = "../gix-odb" }
termtree = "0.5.1"

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading
Loading