Skip to content

Commit d69c617

Browse files
authored
Merge pull request #1566 from Byron/merge
octopus-merge (part 1: tree-editing)
2 parents 9bddeeb + b91d909 commit d69c617

File tree

42 files changed

+2889
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2889
-357
lines changed

Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
license = "MIT OR Apache-2.0"
1010
version = "0.38.0"
1111
default-run = "gix"
12-
include = ["src/**/*", "LICENSE-*", "README.md"]
12+
include = ["src/**/*", "/build.rs", "LICENSE-*", "README.md"]
1313
resolver = "2"
1414

1515
[[bin]]

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,20 @@ There are various build configurations, all of them are [documented here](https:
198198
for packagers who need to tune external dependencies.
199199

200200
```
201-
# A certain way to install `gitoxide` with just Rust and a C compiler installed.
201+
# A way to install `gitoxide` with just Rust and a C compiler installed.
202202
# If there are problems with SSL certificates during clones, try to omit `--locked`.
203203
cargo install gitoxide --locked --no-default-features --features max-pure
204204
205-
# The default installation, 'max', is the fastest, but also needs some libraries available to build successfully.
206-
# Installing these is platform-dependent and thus can't be explained here.
205+
# The default installation, 'max', is the fastest, but also needs `cmake` to build successfully.
206+
# Installing it is platform-dependent.
207207
cargo install gitoxide
208208
209-
# For smaller binaries and even faster build times that are traded for a less fancy CLI implementation, use `lean`
210-
# or `lean-termion` respectively.
209+
# For smaller binaries and even faster build times that are traded for a less fancy CLI implementation,
210+
# use the `lean` feature.
211211
cargo install gitoxide --locked --no-default-features --features lean
212212
```
213213

214-
The following installs the latest unpublished release directly from git:
214+
The following installs the latest unpublished `max` release directly from git:
215215

216216
```sh
217217
cargo install --git https://github.com/Byron/gitoxide gitoxide

gix-features/src/hash.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Otherwise, a minimal yet performant implementation is used instead for a decent trade-off between compile times and run-time performance.
66
#[cfg(all(feature = "rustsha1", not(feature = "fast-sha1")))]
77
mod _impl {
8-
use super::Sha1Digest;
8+
use super::Digest;
99

1010
/// A implementation of the Sha1 hash, which can be used once.
1111
#[derive(Default, Clone)]
@@ -17,22 +17,20 @@ mod _impl {
1717
self.0.update(bytes);
1818
}
1919
/// Finalize the hash and produce a digest.
20-
pub fn digest(self) -> Sha1Digest {
20+
pub fn digest(self) -> Digest {
2121
self.0.digest().bytes()
2222
}
2323
}
2424
}
2525

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

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

34-
use super::Sha1Digest;
35-
3634
/// A implementation of the Sha1 hash, which can be used once.
3735
#[derive(Default, Clone)]
3836
pub struct Sha1(sha1::Sha1);
@@ -43,14 +41,14 @@ mod _impl {
4341
self.0.update(bytes);
4442
}
4543
/// Finalize the hash and produce a digest.
46-
pub fn digest(self) -> Sha1Digest {
44+
pub fn digest(self) -> super::Digest {
4745
self.0.finalize().into()
4846
}
4947
}
5048
}
5149

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

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

7775
/// Produce a hasher suitable for the given kind of hash.
7876
#[cfg(any(feature = "rustsha1", feature = "fast-sha1"))]
79-
pub fn hasher(kind: gix_hash::Kind) -> Sha1 {
77+
pub fn hasher(kind: gix_hash::Kind) -> Hasher {
8078
match kind {
81-
gix_hash::Kind::Sha1 => Sha1::default(),
79+
gix_hash::Kind::Sha1 => Hasher::default(),
8280
}
8381
}
8482

@@ -127,7 +125,7 @@ pub fn bytes(
127125
pub fn bytes_with_hasher(
128126
read: &mut dyn std::io::Read,
129127
num_bytes_from_start: u64,
130-
mut hasher: Sha1,
128+
mut hasher: Hasher,
131129
progress: &mut dyn crate::progress::Progress,
132130
should_interrupt: &std::sync::atomic::AtomicBool,
133131
) -> std::io::Result<gix_hash::ObjectId> {
@@ -160,12 +158,12 @@ pub fn bytes_with_hasher(
160158

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

165163
/// A utility to automatically generate a hash while writing into an inner writer.
166164
pub struct Write<T> {
167165
/// The hash implementation.
168-
pub hash: Sha1,
166+
pub hash: Hasher,
169167
/// The inner writer.
170168
pub inner: T,
171169
}
@@ -194,7 +192,7 @@ mod write {
194192
match object_hash {
195193
gix_hash::Kind::Sha1 => Write {
196194
inner,
197-
hash: Sha1::default(),
195+
hash: Hasher::default(),
198196
},
199197
}
200198
}

gix-features/tests/hash.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
use gix_features::hash::Sha1;
1+
use gix_features::hash::Hasher;
22

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

99
#[cfg(feature = "fast-sha1")]
1010
#[test]
1111
fn size_of_sha1() {
1212
assert_eq!(
13-
std::mem::size_of::<Sha1>(),
13+
std::mem::size_of::<Hasher>(),
1414
if cfg!(target_arch = "x86") { 96 } else { 104 }
1515
);
1616
}

gix-object/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ name = "decode-objects"
1919
harness = false
2020
path = "./benches/decode_objects.rs"
2121

22+
[[bench]]
23+
name = "edit-tree"
24+
harness = false
25+
path = "./benches/edit_tree.rs"
26+
2227

2328
[features]
2429
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
@@ -41,6 +46,7 @@ gix-features = { version = "^0.38.2", path = "../gix-features", features = [
4146
"progress",
4247
] }
4348
gix-hash = { version = "^0.14.2", path = "../gix-hash" }
49+
gix-hashtable = { version = "^0.5.2", path = "../gix-hashtable" }
4450
gix-validate = { version = "^0.9.0", path = "../gix-validate" }
4551
gix-actor = { version = "^0.32.0", path = "../gix-actor" }
4652
gix-date = { version = "^0.9.0", path = "../gix-date" }
@@ -64,6 +70,8 @@ document-features = { version = "0.2.0", optional = true }
6470
criterion = "0.5.1"
6571
pretty_assertions = "1.0.0"
6672
gix-testtools = { path = "../tests/tools" }
73+
gix-odb = { path = "../gix-odb" }
74+
termtree = "0.5.1"
6775

6876
[package.metadata.docs.rs]
6977
all-features = true

0 commit comments

Comments
 (0)