summaryrefslogtreecommitdiffstats
path: root/vendor/gix-object
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/gix-object
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/gix-object/.cargo-checksum.json2
-rw-r--r--vendor/gix-object/CHANGELOG.md39
-rw-r--r--vendor/gix-object/Cargo.toml13
-rw-r--r--vendor/gix-object/src/blob.rs6
-rw-r--r--vendor/gix-object/src/commit/write.rs12
-rw-r--r--vendor/gix-object/src/encode.rs2
-rw-r--r--vendor/gix-object/src/lib.rs29
-rw-r--r--vendor/gix-object/src/object/mod.rs34
-rw-r--r--vendor/gix-object/src/tag/write.rs12
-rw-r--r--vendor/gix-object/src/traits.rs4
-rw-r--r--vendor/gix-object/src/tree/write.rs10
11 files changed, 114 insertions, 49 deletions
diff --git a/vendor/gix-object/.cargo-checksum.json b/vendor/gix-object/.cargo-checksum.json
index 1c2d578fd..53b817439 100644
--- a/vendor/gix-object/.cargo-checksum.json
+++ b/vendor/gix-object/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"df234e21d8d0bc316a0ac6adeacbd901b965acd9bdad0b9454ac36e19567ffbb","Cargo.toml":"778daa8a0e3e036dce919a051c716d0138326a771922a3d6f7c048ef3ed1e013","LICENSE-APACHE":"cb4780590812826851ba250f90bed0ed19506ec98f6865a0e2e20bbf62391ff9","LICENSE-MIT":"49df47913ab2beafe8dc45607877ae64198bf0eee64aaad3e82ed9e4d27424e8","src/blob.rs":"498e4d4d54c2ba9455614f3e0b06b6b9bbfcfd1fab2b4a18371f791114ba494c","src/commit/decode.rs":"d63699485135c2100459cf3683f24c24edf9f8b214076585a1423747d0ea5efc","src/commit/message/body.rs":"3ada2e797423756202e86db398fefc704fcaf6e42b4d8fe42ca839b14863b883","src/commit/message/decode.rs":"df0dd08b400c030dbf3a9da3733c2e5199423c643db4f3bfd4f58832c2d9d4ff","src/commit/message/mod.rs":"3c88e53583cbbc8606ba400bba3d54f2ce6fa75ce4c78d73e2d8bae2b8f45046","src/commit/mod.rs":"81b8f7305945de51cc4d828d53837b7e013e68c4a8d896d445fe29972a6bca03","src/commit/ref_iter.rs":"3f1216d00b7bcfd0bd9eff3ee767f706b42472aa429246375fc770b543dbac84","src/commit/write.rs":"18df601baab03e03ab414b91631087c46dab63f6d6a46fd1fbf04b6b55f1edb8","src/data.rs":"fd1f9281274855d26570d866335ebf5f27709a80308f3c4e5da26a0e7db4be5c","src/encode.rs":"cac3ac7a9263f31e2b19a434938607500ac3256b6bd3bf9ffa24dd6ef401b3a3","src/kind.rs":"f6af54494ddf2e42d07e1ebbc2aad25a3e291f0e7275618ab0758d8802963ca5","src/lib.rs":"509f5326ae54c9f5ad0d65bf701d44b98c57fe735604a55d6c45519bee2b83cd","src/object/convert.rs":"5fa061ce08c12cd59cc5e6975c9e6b57a5ac596c5fe63eeb5758080e7dd7a328","src/object/mod.rs":"81ec0da8639b2339c809a84057582efaf5776d48e39e9b00a2af6bbb794eab1c","src/parse.rs":"3e4095cd579aa216e42dc3bb63d01b21c8e8b12d07faa09786fac0950a3d138e","src/tag/decode.rs":"090a128e1c1bebb69633e6e6bda9cf501b606e491be5bb7f9c3ce3f6bd8ab4c1","src/tag/mod.rs":"9532c15c6e90428dffe7dd80bcfe8bea2fd3210e43e0d4b583f7813a8bae4fe5","src/tag/ref_iter.rs":"b7df75f1555dacddaf0b83777e2281679163b52f3cf086b33b24af4b0b582caa","src/tag/write.rs":"61f92cfe525137da564b24816b806da65f45168a0880de1fbbd4899929460d5e","src/tag/write/tests.rs":"e3c3674d73d3436f10c268154b9362eb380ff9c014b6db2a141bd0a0747c4aff","src/traits.rs":"279302ec53f7bfce2aefba1967acd1c033b66199df622c589c65f146e5036ce6","src/tree/mod.rs":"2e3c330b0947d2e24fa7b5ad58690261d313a705671fd97834278fa72a10e39f","src/tree/ref_iter.rs":"2c2c106550cdd21f6a5340abfb8e95661f240130cc4a5346989b67c1c1d6ace8","src/tree/write.rs":"02c68d954428805f59e4407586337c6fe8265e7a80e20bb83f8fe88fe0e0cf9a"},"package":"1e7e19616c67967374137bae83e950e9b518a9ea8a605069bd6716ada357fd6f"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"93395b1678cd57b2a3e591784eff127cb99ffc75fd0e26b6256607d685f41197","Cargo.toml":"14691a203f35c395cd41a78b7b95effefffe6373804a10f5e9481f704bb2d7b3","LICENSE-APACHE":"cb4780590812826851ba250f90bed0ed19506ec98f6865a0e2e20bbf62391ff9","LICENSE-MIT":"49df47913ab2beafe8dc45607877ae64198bf0eee64aaad3e82ed9e4d27424e8","src/blob.rs":"37877b2a784f556140b4096fcfd9512da59028869ce6d77fb498a1fffd36f7ed","src/commit/decode.rs":"d63699485135c2100459cf3683f24c24edf9f8b214076585a1423747d0ea5efc","src/commit/message/body.rs":"3ada2e797423756202e86db398fefc704fcaf6e42b4d8fe42ca839b14863b883","src/commit/message/decode.rs":"df0dd08b400c030dbf3a9da3733c2e5199423c643db4f3bfd4f58832c2d9d4ff","src/commit/message/mod.rs":"3c88e53583cbbc8606ba400bba3d54f2ce6fa75ce4c78d73e2d8bae2b8f45046","src/commit/mod.rs":"81b8f7305945de51cc4d828d53837b7e013e68c4a8d896d445fe29972a6bca03","src/commit/ref_iter.rs":"3f1216d00b7bcfd0bd9eff3ee767f706b42472aa429246375fc770b543dbac84","src/commit/write.rs":"3ab066802c522c2e91344fcf13c46bb62261d7e60fdb62c1b5d24e3a9ba3b37b","src/data.rs":"fd1f9281274855d26570d866335ebf5f27709a80308f3c4e5da26a0e7db4be5c","src/encode.rs":"ef9eab5c54ac8d3dc88908004c1cac0242c17cc72bbaaad132a616785637286d","src/kind.rs":"f6af54494ddf2e42d07e1ebbc2aad25a3e291f0e7275618ab0758d8802963ca5","src/lib.rs":"591e192b8ee456e72d935ba633e20983f2d4b05b6099d964b940afe4c91f4455","src/object/convert.rs":"5fa061ce08c12cd59cc5e6975c9e6b57a5ac596c5fe63eeb5758080e7dd7a328","src/object/mod.rs":"f6017649d479fd4e4869e358993db8e7820f6303e8496c88a5bda3995acf4cb4","src/parse.rs":"3e4095cd579aa216e42dc3bb63d01b21c8e8b12d07faa09786fac0950a3d138e","src/tag/decode.rs":"090a128e1c1bebb69633e6e6bda9cf501b606e491be5bb7f9c3ce3f6bd8ab4c1","src/tag/mod.rs":"9532c15c6e90428dffe7dd80bcfe8bea2fd3210e43e0d4b583f7813a8bae4fe5","src/tag/ref_iter.rs":"b7df75f1555dacddaf0b83777e2281679163b52f3cf086b33b24af4b0b582caa","src/tag/write.rs":"19ef152a3b7e7bf1f2f260b53e21e34499e952ff6bebafdb0d2894c1123f85ea","src/tag/write/tests.rs":"e3c3674d73d3436f10c268154b9362eb380ff9c014b6db2a141bd0a0747c4aff","src/traits.rs":"b3188ab649098677c4075ed0e8c19a1b103eccf21368d3e1cb3f3809d653d3a7","src/tree/mod.rs":"2e3c330b0947d2e24fa7b5ad58690261d313a705671fd97834278fa72a10e39f","src/tree/ref_iter.rs":"2c2c106550cdd21f6a5340abfb8e95661f240130cc4a5346989b67c1c1d6ace8","src/tree/write.rs":"d71db3581d5c5b130ed826a12c16ae0baf62ed710f5c3d0ee1a2c1b18ca06ec3"},"package":"740f2a44267f58770a1cb3a3d01d14e67b089c7136c48d4bddbb3cfd2bf86a51"} \ No newline at end of file
diff --git a/vendor/gix-object/CHANGELOG.md b/vendor/gix-object/CHANGELOG.md
index c88bda31d..5f444025b 100644
--- a/vendor/gix-object/CHANGELOG.md
+++ b/vendor/gix-object/CHANGELOG.md
@@ -5,6 +5,42 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## 0.38.0 (2023-10-12)
+
+### New Features
+
+ - <csr-id-5bb55decbab55f0480165a756893b0af111e485c/> add `compute_stream_hash` method as lower-level way of hashing objects.
+
+### Bug Fixes (BREAKING)
+
+ - <csr-id-9283a9d2ec460c1380cf6c40d876f477cb552826/> `encode::loose_header()` now supports large objects even on 32 bit systems.
+ Previously, larger than 4GB files wouldn't be supported, which causes problems when
+ genrating hashes even when streaming data.
+
+### Commit Statistics
+
+<csr-read-only-do-not-edit/>
+
+ - 6 commits contributed to the release over the course of 8 calendar days.
+ - 17 days passed between releases.
+ - 2 commits were understood as [conventional](https://www.conventionalcommits.org).
+ - 0 issues like '(#ID)' were seen in commit messages
+
+### Commit Details
+
+<csr-read-only-do-not-edit/>
+
+<details><summary>view details</summary>
+
+ * **Uncategorized**
+ - Prepare changelogs prior to release ([`1347a54`](https://github.com/Byron/gitoxide/commit/1347a54f84599d8f0aa935d6e64b16c2298d25cf))
+ - Merge branch 'improvements' ([`429e7b2`](https://github.com/Byron/gitoxide/commit/429e7b25f93c8a7947db19bafa74babf199a1aa6))
+ - Add `compute_stream_hash` method as lower-level way of hashing objects. ([`5bb55de`](https://github.com/Byron/gitoxide/commit/5bb55decbab55f0480165a756893b0af111e485c))
+ - Fix docs ([`995bc84`](https://github.com/Byron/gitoxide/commit/995bc840664cbd4aeb7f95592e3125dee63bdcd4))
+ - Merge branch 'reset' ([`b842691`](https://github.com/Byron/gitoxide/commit/b8426919a491dc3a7df01ee3f258fc0d8a3a327c))
+ - `encode::loose_header()` now supports large objects even on 32 bit systems. ([`9283a9d`](https://github.com/Byron/gitoxide/commit/9283a9d2ec460c1380cf6c40d876f477cb552826))
+</details>
+
## 0.37.0 (2023-09-24)
A maintenance release without user-facing changes.
@@ -13,7 +49,7 @@ A maintenance release without user-facing changes.
<csr-read-only-do-not-edit/>
- - 1 commit contributed to the release.
+ - 2 commits contributed to the release.
- 16 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
@@ -25,6 +61,7 @@ A maintenance release without user-facing changes.
<details><summary>view details</summary>
* **Uncategorized**
+ - Release gix-features v0.35.0, gix-actor v0.27.0, gix-object v0.37.0, gix-glob v0.13.0, gix-attributes v0.19.0, gix-filter v0.5.0, gix-fs v0.7.0, gix-commitgraph v0.21.0, gix-revwalk v0.8.0, gix-traverse v0.33.0, gix-worktree-stream v0.5.0, gix-archive v0.5.0, gix-tempfile v10.0.0, gix-lock v10.0.0, gix-ref v0.37.0, gix-config v0.30.0, gix-url v0.24.0, gix-credentials v0.20.0, gix-diff v0.36.0, gix-discover v0.25.0, gix-ignore v0.8.0, gix-index v0.25.0, gix-mailmap v0.19.0, gix-negotiate v0.8.0, gix-pack v0.43.0, gix-odb v0.53.0, gix-pathspec v0.3.0, gix-transport v0.37.0, gix-protocol v0.40.0, gix-revision v0.22.0, gix-refspec v0.18.0, gix-status v0.1.0, gix-submodule v0.4.0, gix-worktree v0.26.0, gix-worktree-state v0.3.0, gix v0.54.0, gitoxide-core v0.32.0, gitoxide v0.30.0, safety bump 37 crates ([`7891fb1`](https://github.com/Byron/gitoxide/commit/7891fb17348ec2f4c997665f9a25be36e2713da4))
- Prepare changelogs prior to release ([`8a60d5b`](https://github.com/Byron/gitoxide/commit/8a60d5b80877c213c3b646d3061e8a33e0e433ec))
</details>
diff --git a/vendor/gix-object/Cargo.toml b/vendor/gix-object/Cargo.toml
index 2d1142e20..db0fd4819 100644
--- a/vendor/gix-object/Cargo.toml
+++ b/vendor/gix-object/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2021"
rust-version = "1.65"
name = "gix-object"
-version = "0.37.0"
+version = "0.38.0"
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
include = [
"src/**/*",
@@ -56,17 +56,20 @@ version = "0.2.0"
optional = true
[dependencies.gix-actor]
-version = "^0.27.0"
+version = "^0.28.0"
[dependencies.gix-date]
version = "^0.8.0"
[dependencies.gix-features]
-version = "^0.35.0"
-features = ["rustsha1"]
+version = "^0.36.0"
+features = [
+ "rustsha1",
+ "progress",
+]
[dependencies.gix-hash]
-version = "^0.13.0"
+version = "^0.13.1"
[dependencies.gix-validate]
version = "^0.8.0"
diff --git a/vendor/gix-object/src/blob.rs b/vendor/gix-object/src/blob.rs
index d0a42092c..57db54758 100644
--- a/vendor/gix-object/src/blob.rs
+++ b/vendor/gix-object/src/blob.rs
@@ -12,8 +12,8 @@ impl<'a> crate::WriteTo for BlobRef<'a> {
Kind::Blob
}
- fn size(&self) -> usize {
- self.data.len()
+ fn size(&self) -> u64 {
+ self.data.len() as u64
}
}
@@ -27,7 +27,7 @@ impl crate::WriteTo for Blob {
Kind::Blob
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
self.to_ref().size()
}
}
diff --git a/vendor/gix-object/src/commit/write.rs b/vendor/gix-object/src/commit/write.rs
index 667d25763..efad2b6db 100644
--- a/vendor/gix-object/src/commit/write.rs
+++ b/vendor/gix-object/src/commit/write.rs
@@ -27,9 +27,9 @@ impl crate::WriteTo for Commit {
Kind::Commit
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
let hash_in_hex = self.tree.kind().len_in_hex();
- b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */
+ (b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */
+ self.parents.iter().count() * (b"parent".len() + 1 + hash_in_hex + 1)
+ b"author".len() + 1 /* space */ + self.author.size() + 1 /* nl */
+ b"committer".len() + 1 /* space */ + self.committer.size() + 1 /* nl */
@@ -46,7 +46,7 @@ impl crate::WriteTo for Commit {
})
.sum::<usize>()
+ 1 /* nl */
- + self.message.len()
+ + self.message.len()) as u64
}
}
@@ -73,9 +73,9 @@ impl<'a> crate::WriteTo for CommitRef<'a> {
Kind::Commit
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
let hash_in_hex = self.tree().kind().len_in_hex();
- b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */
+ (b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */
+ self.parents.iter().count() * (b"parent".len() + 1 /* space */ + hash_in_hex + 1 /* nl */)
+ b"author".len() + 1 /* space */ + self.author.size() + 1 /* nl */
+ b"committer".len() + 1 /* space */ + self.committer.size() + 1 /* nl */
@@ -92,6 +92,6 @@ impl<'a> crate::WriteTo for CommitRef<'a> {
})
.sum::<usize>()
+ 1 /* nl */
- + self.message.len()
+ + self.message.len()) as u64
}
}
diff --git a/vendor/gix-object/src/encode.rs b/vendor/gix-object/src/encode.rs
index 3ba7db0b5..04a791948 100644
--- a/vendor/gix-object/src/encode.rs
+++ b/vendor/gix-object/src/encode.rs
@@ -19,7 +19,7 @@ macro_rules! check {
};
}
/// Generates a loose header buffer
-pub fn loose_header(kind: crate::Kind, size: usize) -> smallvec::SmallVec<[u8; 28]> {
+pub fn loose_header(kind: crate::Kind, size: u64) -> smallvec::SmallVec<[u8; 28]> {
let mut v = smallvec::SmallVec::new();
check!(v.write_all(kind.as_bytes()));
check!(v.write_all(SPACE));
diff --git a/vendor/gix-object/src/lib.rs b/vendor/gix-object/src/lib.rs
index 56e0019fd..a07502917 100644
--- a/vendor/gix-object/src/lib.rs
+++ b/vendor/gix-object/src/lib.rs
@@ -98,7 +98,7 @@ pub struct CommitRef<'a> {
pub extra_headers: Vec<(&'a BStr, Cow<'a, BStr>)>,
}
-/// Like [`CommitRef`][crate::CommitRef], but as `Iterator` to support (up to) entirely allocation free parsing.
+/// Like [`CommitRef`], but as `Iterator` to support (up to) entirely allocation free parsing.
/// It's particularly useful to traverse the commit graph without ever allocating arrays for parents.
#[derive(Copy, Clone)]
pub struct CommitRefIter<'a> {
@@ -345,7 +345,7 @@ pub mod decode {
/// ([`kind`](super::Kind), `size`, `consumed bytes`).
///
/// `size` is the uncompressed size of the payload in bytes.
- pub fn loose_header(input: &[u8]) -> Result<(super::Kind, usize, usize), LooseHeaderDecodeError> {
+ pub fn loose_header(input: &[u8]) -> Result<(super::Kind, u64, usize), LooseHeaderDecodeError> {
use LooseHeaderDecodeError::*;
let kind_end = input.find_byte(0x20).ok_or(InvalidHeader {
message: "Expected '<type> <size>'",
@@ -364,9 +364,10 @@ pub mod decode {
}
}
-/// A standalone function to compute a hash of kind `hash_kind` for an object of `object_kind` and its `data`.
+/// A function to compute a hash of kind `hash_kind` for an object of `object_kind` and its `data`.
+#[doc(alias = "hash_object", alias = "git2")]
pub fn compute_hash(hash_kind: gix_hash::Kind, object_kind: Kind, data: &[u8]) -> gix_hash::ObjectId {
- let header = encode::loose_header(object_kind, data.len());
+ let header = encode::loose_header(object_kind, data.len() as u64);
let mut hasher = gix_features::hash::hasher(hash_kind);
hasher.update(&header);
@@ -374,3 +375,23 @@ pub fn compute_hash(hash_kind: gix_hash::Kind, object_kind: Kind, data: &[u8]) -
hasher.digest().into()
}
+
+/// A function to compute a hash of kind `hash_kind` for an object of `object_kind` and its data read from `stream`
+/// which has to yield exactly `stream_len` bytes.
+/// Use `progress` to learn about progress in bytes processed and `should_interrupt` to be able to abort the operation
+/// if set to `true`.
+#[doc(alias = "hash_file", alias = "git2")]
+pub fn compute_stream_hash(
+ hash_kind: gix_hash::Kind,
+ object_kind: Kind,
+ stream: &mut dyn std::io::Read,
+ stream_len: u64,
+ progress: &mut dyn gix_features::progress::Progress,
+ should_interrupt: &std::sync::atomic::AtomicBool,
+) -> std::io::Result<gix_hash::ObjectId> {
+ let header = encode::loose_header(object_kind, stream_len);
+ let mut hasher = gix_features::hash::hasher(hash_kind);
+
+ hasher.update(&header);
+ gix_features::hash::bytes_with_hasher(stream, stream_len, hasher, progress, should_interrupt)
+}
diff --git a/vendor/gix-object/src/object/mod.rs b/vendor/gix-object/src/object/mod.rs
index bebc1cc65..e7f775cd4 100644
--- a/vendor/gix-object/src/object/mod.rs
+++ b/vendor/gix-object/src/object/mod.rs
@@ -24,7 +24,7 @@ mod write {
self.kind()
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
use crate::ObjectRef::*;
match self {
Tree(v) => v.size(),
@@ -52,7 +52,7 @@ mod write {
self.kind()
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
use crate::Object::*;
match self {
Tree(v) => v.size(),
@@ -66,35 +66,35 @@ mod write {
/// Convenient extraction of typed object.
impl Object {
- /// Turns this instance into a [`Blob`][Blob], panic otherwise.
+ /// Turns this instance into a [`Blob`], panic otherwise.
pub fn into_blob(self) -> Blob {
match self {
Object::Blob(v) => v,
_ => panic!("BUG: not a blob"),
}
}
- /// Turns this instance into a [`Commit`][Commit] panic otherwise.
+ /// Turns this instance into a [`Commit`] panic otherwise.
pub fn into_commit(self) -> Commit {
match self {
Object::Commit(v) => v,
_ => panic!("BUG: not a commit"),
}
}
- /// Turns this instance into a [`Tree`][Tree] panic otherwise.
+ /// Turns this instance into a [`Tree`] panic otherwise.
pub fn into_tree(self) -> Tree {
match self {
Object::Tree(v) => v,
_ => panic!("BUG: not a tree"),
}
}
- /// Turns this instance into a [`Tag`][Tag] panic otherwise.
+ /// Turns this instance into a [`Tag`] panic otherwise.
pub fn into_tag(self) -> Tag {
match self {
Object::Tag(v) => v,
_ => panic!("BUG: not a tag"),
}
}
- /// Turns this instance into a [`Blob`][Blob] if it is one.
+ /// Turns this instance into a [`Blob`] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_blob(self) -> Result<Blob, Self> {
match self {
@@ -102,14 +102,14 @@ impl Object {
_ => Err(self),
}
}
- /// Turns this instance into a [`BlobRef`][BlobRef] if it is a blob.
+ /// Turns this instance into a [`BlobRef`] if it is a blob.
pub fn try_into_blob_ref(&self) -> Option<BlobRef<'_>> {
match self {
Object::Blob(v) => Some(v.to_ref()),
_ => None,
}
}
- /// Turns this instance into a [`Commit`][Commit] if it is one.
+ /// Turns this instance into a [`Commit`] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_commit(self) -> Result<Commit, Self> {
match self {
@@ -117,7 +117,7 @@ impl Object {
_ => Err(self),
}
}
- /// Turns this instance into a [`Tree`][Tree] if it is one.
+ /// Turns this instance into a [`Tree`] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_tree(self) -> Result<Tree, Self> {
match self {
@@ -125,7 +125,7 @@ impl Object {
_ => Err(self),
}
}
- /// Turns this instance into a [`Tag`][Tag] if it is one.
+ /// Turns this instance into a [`Tag`] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_tag(self) -> Result<Tag, Self> {
match self {
@@ -134,28 +134,28 @@ impl Object {
}
}
- /// Returns a [`Blob`][Blob] if it is one.
+ /// Returns a [`Blob`] if it is one.
pub fn as_blob(&self) -> Option<&Blob> {
match self {
Object::Blob(v) => Some(v),
_ => None,
}
}
- /// Returns a [`Commit`][Commit] if it is one.
+ /// Returns a [`Commit`] if it is one.
pub fn as_commit(&self) -> Option<&Commit> {
match self {
Object::Commit(v) => Some(v),
_ => None,
}
}
- /// Returns a [`Tree`][Tree] if it is one.
+ /// Returns a [`Tree`] if it is one.
pub fn as_tree(&self) -> Option<&Tree> {
match self {
Object::Tree(v) => Some(v),
_ => None,
}
}
- /// Returns a [`Tag`][Tag] if it is one.
+ /// Returns a [`Tag`] if it is one.
pub fn as_tag(&self) -> Option<&Tag> {
match self {
Object::Tag(v) => Some(v),
@@ -185,6 +185,8 @@ pub enum LooseDecodeError {
InvalidHeader(#[from] LooseHeaderDecodeError),
#[error(transparent)]
InvalidContent(#[from] DecodeError),
+ #[error("Object sized {size} does not fit into memory - this can happen on 32 bit systems")]
+ OutOfMemory { size: u64 },
}
impl<'a> ObjectRef<'a> {
@@ -193,7 +195,7 @@ impl<'a> ObjectRef<'a> {
let (kind, size, offset) = loose_header(data)?;
let body = &data[offset..]
- .get(..size)
+ .get(..size.try_into().map_err(|_| LooseDecodeError::OutOfMemory { size })?)
.ok_or(LooseHeaderDecodeError::InvalidHeader {
message: "object data was shorter than its size declared in the header",
})?;
diff --git a/vendor/gix-object/src/tag/write.rs b/vendor/gix-object/src/tag/write.rs
index cee9e587c..dc8fd1ba3 100644
--- a/vendor/gix-object/src/tag/write.rs
+++ b/vendor/gix-object/src/tag/write.rs
@@ -44,8 +44,8 @@ impl crate::WriteTo for Tag {
Kind::Tag
}
- fn size(&self) -> usize {
- b"object".len() + 1 /* space */ + self.target.kind().len_in_hex() + 1 /* nl */
+ fn size(&self) -> u64 {
+ (b"object".len() + 1 /* space */ + self.target.kind().len_in_hex() + 1 /* nl */
+ b"type".len() + 1 /* space */ + self.target_kind.as_bytes().len() + 1 /* nl */
+ b"tag".len() + 1 /* space */ + self.name.len() + 1 /* nl */
+ self
@@ -53,7 +53,7 @@ impl crate::WriteTo for Tag {
.as_ref()
.map_or(0, |t| b"tagger".len() + 1 /* space */ + t.size() + 1 /* nl */)
+ 1 /* nl */ + self.message.len()
- + self.pgp_signature.as_ref().map_or(0, |m| 1 /* nl */ + m.len())
+ + self.pgp_signature.as_ref().map_or(0, |m| 1 /* nl */ + m.len())) as u64
}
}
@@ -81,8 +81,8 @@ impl<'a> crate::WriteTo for TagRef<'a> {
Kind::Tag
}
- fn size(&self) -> usize {
- b"object".len() + 1 /* space */ + self.target().kind().len_in_hex() + 1 /* nl */
+ fn size(&self) -> u64 {
+ (b"object".len() + 1 /* space */ + self.target().kind().len_in_hex() + 1 /* nl */
+ b"type".len() + 1 /* space */ + self.target_kind.as_bytes().len() + 1 /* nl */
+ b"tag".len() + 1 /* space */ + self.name.len() + 1 /* nl */
+ self
@@ -90,7 +90,7 @@ impl<'a> crate::WriteTo for TagRef<'a> {
.as_ref()
.map_or(0, |t| b"tagger".len() + 1 /* space */ + t.size() + 1 /* nl */)
+ 1 /* nl */ + self.message.len()
- + self.pgp_signature.as_ref().map_or(0, |m| 1 /* nl */ + m.len())
+ + self.pgp_signature.as_ref().map_or(0, |m| 1 /* nl */ + m.len())) as u64
}
}
diff --git a/vendor/gix-object/src/traits.rs b/vendor/gix-object/src/traits.rs
index c0c4adee2..ce0463c98 100644
--- a/vendor/gix-object/src/traits.rs
+++ b/vendor/gix-object/src/traits.rs
@@ -17,7 +17,7 @@ pub trait WriteTo {
/// the object, as such it's possible for [`size`](Self::size) to
/// return a sensible value but [`write_to`](Self::write_to) to
/// fail because the object was not actually valid in some way.
- fn size(&self) -> usize;
+ fn size(&self) -> u64;
/// Returns a loose object header based on the object's data
fn loose_header(&self) -> smallvec::SmallVec<[u8; 28]> {
@@ -37,7 +37,7 @@ where
<T as WriteTo>::kind(self)
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
<T as WriteTo>::size(self)
}
}
diff --git a/vendor/gix-object/src/tree/write.rs b/vendor/gix-object/src/tree/write.rs
index 91e1dc2e0..e1a82720f 100644
--- a/vendor/gix-object/src/tree/write.rs
+++ b/vendor/gix-object/src/tree/write.rs
@@ -57,10 +57,12 @@ impl crate::WriteTo for Tree {
Kind::Tree
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
self.entries
.iter()
- .map(|Entry { mode, filename, oid }| mode.as_bytes().len() + 1 + filename.len() + 1 + oid.as_bytes().len())
+ .map(|Entry { mode, filename, oid }| {
+ (mode.as_bytes().len() + 1 + filename.len() + 1 + oid.as_bytes().len()) as u64
+ })
.sum()
}
}
@@ -100,11 +102,11 @@ impl<'a> crate::WriteTo for TreeRef<'a> {
Kind::Tree
}
- fn size(&self) -> usize {
+ fn size(&self) -> u64 {
self.entries
.iter()
.map(|EntryRef { mode, filename, oid }| {
- mode.as_bytes().len() + 1 + filename.len() + 1 + oid.as_bytes().len()
+ (mode.as_bytes().len() + 1 + filename.len() + 1 + oid.as_bytes().len()) as u64
})
.sum()
}