valsov / git-diff

Git diff algorithms implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitDiff

Git diff algorithm implementation. The program structure allows for easy addition of diff algorithms.

Currently, only Myers diff is implemented.

Example use

input1 := `DELETED
UNCHANGED
UNCHANGED`
previous := gitdiff.NewDocument(input1)

input2 := `ADDED
UNCHANGED
UNCHANGED
ADDED`
current := gitdiff.NewDocument(input2)

differ, _ := gitdiff.NewDiffProducer(gitdiff.MYERS_DIFF)
diffs, err := differ.ComputeDiff(previous, current, -1) // -1 to include all lines, not only changed ones

The diffs can then be handled as you like, or printed using the printer utility. The above example would produce this:

- 1               DELETED
+       1         ADDED
  2     2         UNCHANGED
  3     3         UNCHANGED
+       4         ADDED

About

Git diff algorithms implementation


Languages

Language:Go 100.0%