Skip to main content

packed_full_object_slice

Function packed_full_object_slice 

Source
pub fn packed_full_object_slice(
    objects_dir: &Path,
    oid: &ObjectId,
) -> Result<Option<Vec<u8>>>
Expand description

When oid is stored as a full (non-delta) object in a local pack, return its verbatim packed bytes: the varint type+size header followed by the zlib stream.

The header of a non-delta pack entry is position-independent, so the returned slice can be copied into a new pack unchanged — skipping both inflate and deflate. This is Git pack-objects’ object reuse for objects that stay full in the output pack.

§Parameters

  • objects_dir — the repository’s objects/ directory.
  • oid — the object to look up.

Returns None when the object is loose only, stored as a delta, or the repository uses a hash width other than SHA-1.

§Errors

Returns Error::Io when pack files cannot be read; a malformed candidate entry is skipped rather than reported so another pack (or the recompression path) can serve the object.