git-unified-diff-parse
Parse unified git diff text into structured Python objects.
Install
pip install git-unified-diff-parse
Quickstart
from git_unified_diff_parse import DiffParser
files = DiffParser().parse(diff_text)
for f in files:
print(f.status, f.new_path)
for hunk in f.hunks:
print(hunk.patch)
What you get
DiffParser.parse() returns a list of ChangedFile objects:
| Field | Type | Description |
|---|---|---|
new_path |
str | None |
Path on the new side; None for deleted files |
old_path |
str | None |
Path on the old side; None for added files |
status |
FileStatus |
added, modified, removed, renamed, copied |
hunks |
List[DiffHunk] |
Each contiguous block of changes |
is_binary |
bool |
True for binary files |
old_ending_newline |
bool |
False if old file had no trailing newline |
new_ending_newline |
bool |
False if new file has no trailing newline |
Each DiffHunk has a patch property that renders the full unified diff block (header + prefixed lines), useful as LLM input.
Example usage
See examples/README.md for a full walkthrough — including how to run an explorer script against a built-in sample diff, a live git diff, or a saved diff file.
License
Metadata
Release files for git-unified-diff-parse 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_unified_diff_parse-0.1.1.tar.gz | 18.6 kB | With provenance | Details for git_unified_diff_parse-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_unified_diff_parse-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for git_unified_diff_parse-0.1.1-py3-none-any.whl |
Total release size: 30.0 kB
Release files / git_unified_diff_parse-0.1.1.tar.gz
| Download URL | git_unified_diff_parse-0.1.1.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fd0244e8db0e899e9e636c4a83bd689c0c6271db152d379222c85e5be29cddc
|
|
BLAKE2b-256 checksum How to use checksums |
a61aa61c28912a8e32a15b275c13904eee4159cd11679c45f44e65ff30d6bc64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logRelease files / git_unified_diff_parse-0.1.1-py3-none-any.whl
| Download URL | git_unified_diff_parse-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd410e9c8d9415fdaf7a93ff272a1c1389d735fc2a22437957b1f71d5c8a8e62
|
|
BLAKE2b-256 checksum How to use checksums |
88cd4c277612106ee5532be18c8ac3ecb5e7f41aac9f9a3344e8af8db4fa5764
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logSecurity for git-unified-diff-parse 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for git_unified_diff_parse-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.