Skip to main content

write_patch_resolved

Function write_patch_resolved 

Source
pub fn write_patch_resolved<W: Write>(
    repo: &Repository,
    files: &[PatchResolvedSide],
    opts: &PatchTextOptions,
    out: &mut W,
) -> Result<()>
Expand description

Write git diff --binary-compatible patch text for files whose sides may live in memory, the object database, or the work tree (index and work-tree diffs).

Binary files are written as GIT binary patch sections. Their index line always carries full ids of the content actually written, hashed from the bytes for PatchSide::Bytes and PatchSide::Worktree sides, because git apply refuses a binary patch without one and work-tree entries often carry no blob id for the work-tree side.

§Parameters

  • repo: repository for objects, config, and (for PatchSide::Worktree) the work tree and index.
  • files: files to write, in output order.
  • opts: hunk and abbreviation settings.
  • out: destination for patch bytes.

§Errors

Returns Error::RequiresWorkTree when a PatchSide::Worktree side is requested in a bare repository, and propagates index, ODB, work-tree, hashing and I/O errors.