Billy Keyes cbd3915448 Add final tests for git header parsing functions
This gets 100% test coverage for the functions involved in parsing
Git-style file headers. Whether that actually makes it correct remains
to be seen.
2019-03-19 21:50:50 -07:00
2019-03-11 22:47:04 -07:00
2019-03-10 21:51:13 -07:00

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 anything 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.

Known Issues and Differences From Git

  1. Certain types of invalid input that I believe are accepted by git apply generate errors in this library. These include:

    • Numbers immediately followed by non-numeric characters
    • Trailing characters on a line after valid or expected content
  2. The translation from C to Go may have introduced inconsistencies in the way Unicode file names are handled; these are bugs, so please report any issues of this type.

  3. When reading headers, object IDs are always loaded from index lines, regardless of their length. Git calls these fields {new,old}_oid_prefix but appears to only load full-length OIDs, ignoring abbreviations.

S
Description
Automated archival mirror of github.com/bluekeyes/go-gitdiff
Readme MIT 4.1 MiB
Languages
Go 100%