MCPcopy Create free account
hub / github.com/git/git / oid_from_offset

Method oid_from_offset

src/loose.rs:467–478  ·  view source on GitHub ↗
(&self, offset: usize, algo: HashAlgorithm)

Source from the content-addressed store, hash-verified

465 }
466
467 fn oid_from_offset(&self, offset: usize, algo: HashAlgorithm) -> Option<ObjectID> {
468 let aparams = self.obj_formats.get(&algo)?;
469
470 let mut hash = [0u8; GIT_MAX_RAWSZ];
471 let len = algo.raw_len();
472 let oid_off = aparams.full_off + (offset * len);
473 hash[0..len].copy_from_slice(&self.memory[oid_off..oid_off + len]);
474 Some(ObjectID {
475 hash,
476 algo: algo as u32,
477 })
478 }
479
480 fn u32_at_offset(slice: &[u8], offset: usize) -> u32 {
481 u32::from_be_bytes(slice[offset..offset + 4].try_into().unwrap())

Callers 3

nextMethod · 0.80
map_objectMethod · 0.80
map_oidMethod · 0.80

Calls 1

raw_lenMethod · 0.80

Tested by

no test coverage detected