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

Method read_git_object_id

atomic-core/src/operation/codec.rs:1248–1267  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

1246 }
1247
1248 fn read_git_object_id(&mut self) -> Result<GitObjectId, OperationCodecError> {
1249 let (algorithm, width) = match self.read_u8()? {
1250 0 => (GitHashAlgorithm::Sha1, 20),
1251 1 => (GitHashAlgorithm::Sha256, 32),
1252 tag => {
1253 return Err(OperationCodecError::new(format!(
1254 "unsupported Git hash algorithm tag {tag}"
1255 )))
1256 }
1257 };
1258 let end = self
1259 .offset
1260 .checked_add(width)
1261 .ok_or_else(|| OperationCodecError::new("Git object ID length overflow"))?;
1262 let bytes = self.bytes.get(self.offset..end).ok_or_else(|| {
1263 OperationCodecError::new("canonical object is truncated while reading Git object ID")
1264 })?;
1265 self.offset = end;
1266 GitObjectId::new(algorithm, bytes.to_vec())
1267 }
1268
1269 fn read_git_index(&mut self) -> Result<GitIndexState, OperationCodecError> {
1270 let digest = self.read_hash()?;

Callers 5

read_git_headMethod · 0.80
read_git_indexMethod · 0.80
read_git_ref_targetMethod · 0.80
read_effect_targetMethod · 0.80
read_effect_valueMethod · 0.80

Calls 2

read_u8Method · 0.80
getMethod · 0.65

Tested by

no test coverage detected