Function git_object::encode::loose_header
source · Expand description
Generates a loose header buffer
Examples found in repository?
More examples
src/data.rs (line 73)
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
pub fn verify_checksum(&self, desired: impl AsRef<git_hash::oid>) -> Result<(), Error> {
let desired = desired.as_ref();
let mut hasher = git_features::hash::hasher(desired.kind());
hasher.update(&crate::encode::loose_header(self.kind, self.data.len()));
hasher.update(self.data);
let actual_id = git_hash::ObjectId::from(hasher.digest());
if desired != actual_id {
return Err(Error::ChecksumMismatch {
desired: desired.into(),
actual: actual_id,
});
}
Ok(())
}