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_idoperates on a repository’s object database, computing the diff from the commit’s tree objects.compute_patch_ids_from_textparses unified diff text from stdin (e.g. output ofgit log -porgit diff-tree --patch --stdin), matching the behaviour ofgit patch-id.
Enums§
- Patch
IdMode - 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 -poutput).