fork of go-gitdiff with jj support
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Go 100.0%
14 2 19

Clone this repository

https://tangled.org/oppi.li/go-gitdiff https://tangled.org/did:plc:qfpnj4og54vl56wngdriaxug/go-gitdiff
git@tangled.org:oppi.li/go-gitdiff git@tangled.org:did:plc:qfpnj4og54vl56wngdriaxug/go-gitdiff

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

go-gitdiff#

A Go library for parsing and applying patches generated by git diff, git show, and git format-patch. It can also parse and apply unified diffs generated by the standard diff tool.

It supports both standard line-oriented / text patches and Git binary patches.

Status#

In development, most functionality is currently missing, incomplete, or broken.

Why another git/unified diff parser?#

Several packages with similar functionality exist, so why did I write another?

  1. No other packages I found support binary diffs, as generated with the --binary flag. This is the main reason for writing a new packages, as the format is pretty different from line-oriented diffs and is unique to Git.

  2. Most other packages only parse patches, so you need another package to apply them (and if they do support applies, it is only for text files.)

  3. This package aims to accept anything1 that git apply accepts, and closely follows the logic in apply.c.

  4. It seemed like a fun thing to write and a good way to learn more about Git.

1: In practice this library is stricter than git apply when given certain types of invalid input, particularly lines that contain garbage following the valid content. Git seems to ignore this, while this library will usually return an error.