Skip to main content

Module patch_ids

Module patch_ids 

Source
Expand description

Patch-ID computation for commit equivalence detection.

A patch-ID is a SHA-1 digest of the normalised diff a commit introduces. Whitespace is stripped from every changed line before hashing, so two commits whose diffs differ only in whitespace (spaces, tabs, newlines) produce identical patch-IDs. This is the semantics required by git cherry and git format-patch --ignore-if-in-upstream.

Two complementary entry points are provided:

  • compute_patch_id operates on a repository’s object database, computing the diff from the commit’s tree objects.
  • compute_patch_ids_from_text parses unified diff text from stdin (e.g. output of git log -p or git diff-tree --patch --stdin), matching the behaviour of git patch-id.

Enums§

PatchIdMode
How to compute a patch-ID from unified diff text.

Functions§

compute_patch_id
Compute the patch-ID for a single commit.
compute_patch_ids_from_text
Compute patch-IDs from unified diff text (e.g. git log -p output).