MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / git_object_oid

Function git_object_oid

atomic-repository/src/repository/projection_commit.rs:600–609  ·  view source on GitHub ↗
(kind: ObjectType, content: &[u8])

Source from the content-addressed store, hash-verified

598}
599
600pub(super) fn git_object_oid(kind: ObjectType, content: &[u8]) -> GitObjectId {
601 use sha1::Digest as _;
602 let mut hasher = sha1::Sha1::new();
603 let header = format!("{} {}\0", object_kind_name(kind), content.len());
604 hasher.update(header.as_bytes());
605 hasher.update(content);
606 let bytes: [u8; 20] = hasher.finalize().into();
607 GitObjectId::new(GitHashAlgorithm::Sha1, bytes.to_vec())
608 .expect("a SHA-1 digest is a valid 20-byte object id")
609}
610
611fn object_kind_name(kind: ObjectType) -> &'static str {
612 match kind {

Callers 2

build_projected_commitFunction · 0.70
write_raw_git_objectFunction · 0.70

Calls 3

updateMethod · 0.45
as_bytesMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected