summaryrefslogtreecommitdiffstats
path: root/vendor/gix-hash/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-hash/src')
-rw-r--r--vendor/gix-hash/src/lib.rs6
-rw-r--r--vendor/gix-hash/src/object_id.rs2
-rw-r--r--vendor/gix-hash/src/oid.rs11
-rw-r--r--vendor/gix-hash/src/prefix.rs2
4 files changed, 15 insertions, 6 deletions
diff --git a/vendor/gix-hash/src/lib.rs b/vendor/gix-hash/src/lib.rs
index f4a8d3f23..7dda8eb4c 100644
--- a/vendor/gix-hash/src/lib.rs
+++ b/vendor/gix-hash/src/lib.rs
@@ -3,10 +3,10 @@
//! These are provided in [borrowed versions][oid] as well as an [owned one][ObjectId].
//! ## Feature Flags
#![cfg_attr(
- feature = "document-features",
- cfg_attr(doc, doc = ::document_features::document_features!())
+ all(doc, feature = "document-features"),
+ doc = ::document_features::document_features!()
)]
-#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
+#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
#[path = "oid.rs"]
diff --git a/vendor/gix-hash/src/object_id.rs b/vendor/gix-hash/src/object_id.rs
index 4234d63b5..4738116a3 100644
--- a/vendor/gix-hash/src/object_id.rs
+++ b/vendor/gix-hash/src/object_id.rs
@@ -55,7 +55,7 @@ pub mod decode {
ObjectId::Sha1({
let mut buf = [0; 20];
faster_hex::hex_decode(buffer, &mut buf).map_err(|err| match err {
- faster_hex::Error::InvalidChar => Error::Invalid,
+ faster_hex::Error::InvalidChar | faster_hex::Error::Overflow => Error::Invalid,
faster_hex::Error::InvalidLength(_) => {
unreachable!("BUG: This is already checked")
}
diff --git a/vendor/gix-hash/src/oid.rs b/vendor/gix-hash/src/oid.rs
index b105621cb..f9c74adfe 100644
--- a/vendor/gix-hash/src/oid.rs
+++ b/vendor/gix-hash/src/oid.rs
@@ -1,6 +1,6 @@
use std::{convert::TryInto, fmt, hash};
-use crate::{ObjectId, SIZE_OF_SHA1_DIGEST};
+use crate::{Kind, ObjectId, SIZE_OF_SHA1_DIGEST};
/// A borrowed reference to a hash identifying objects.
///
@@ -137,6 +137,15 @@ impl oid {
hex_len: self.bytes.len() * 2,
}
}
+
+ /// Returns `true` if this hash consists of all null bytes.
+ #[inline]
+ #[doc(alias = "is_zero", alias = "git2")]
+ pub fn is_null(&self) -> bool {
+ match self.kind() {
+ Kind::Sha1 => &self.bytes == oid::null_sha1().as_bytes(),
+ }
+ }
}
/// Sha1 specific methods
diff --git a/vendor/gix-hash/src/prefix.rs b/vendor/gix-hash/src/prefix.rs
index c8e1b1847..b9d3849ab 100644
--- a/vendor/gix-hash/src/prefix.rs
+++ b/vendor/gix-hash/src/prefix.rs
@@ -115,7 +115,7 @@ impl Prefix {
faster_hex::hex_decode(src, &mut out).map(move |_| out)
}
.map_err(|e| match e {
- faster_hex::Error::InvalidChar => from_hex::Error::Invalid,
+ faster_hex::Error::InvalidChar | faster_hex::Error::Overflow => from_hex::Error::Invalid,
faster_hex::Error::InvalidLength(_) => panic!("This is already checked"),
})?;