pub fn write_indexed_with_scratch(
repository: &impl Repository,
order: Option<&[usize]>,
entries: &mut [IndexEntry],
scratch: &mut [u8],
pack_output: &mut impl Write,
index_output: &mut impl Write,
) -> Result<ObjectId>Expand description
Stream a stored-block pack and a version-2 index without buffering either.
order selects unique object indices or None selects the whole repository.
Metadata needs one slot per selected object; extra slots remain untouched.
Scratch must be nonempty for nonempty selections. The resulting pack matches
write_selected_with_scratch/write_with_scratch for every scratch size.
IDs, selection and metadata capacity are checked before output. The repository must satisfy its stable, accurate-ID contract (or be validated beforehand). Preflight IDs are retained, avoiding repeated provider hashing. Entries are collected while encoding each body once, then sorted in place without allocation in O(n log n) time. Index bytes follow after the pack’s trailer is written. On any error discard both outputs and used metadata; publish them together only after success. Returns the pack checksum.