Fork me on GitHub
Delta

Delta is a command-line utility for text diffs. View split diffs in the browser with syntax highlighting (demo), or in the command-line using the --cli flag.

Screenshot

Installation

go get github.com/octavore/delta/delta

If $GOPATH/bin is on your $PATH, run delta -h for usage.

The last released binary (OS X only) is also available on Github.

Overview

Delta implements two diff algorithms: histogram diff and Smith-Waterman.

histogram diff is the default. It was first implemented in JGit and subsequently ported over to git, where it can be used with the git diff --histogram command. This implementation post processes the histogram diff in order to push down match regions as far as possible.

Smith-Waterman is a dynamic programming algorithm for aligning two sequences, in this case text sequences. It originates from bioinformatics, where it is used for aligning DNA sequences. In Delta, it is currently used for computing intra-line differences.

Git Integration

With a bit of configuration, you can invoke Delta directly from git using git difftool.

The delta binary must be on your $PATH in order for this work. The following are helpers for adding delta to your ~/.gitconfig file.

delta --install    # make delta the `git difftool` default
delta --uninstall  # remove delta from your gitconfig

The underlying git commands will be printed out to the terminal when you run one of the above helpers.

Browser Shortcuts

d    toggle file drawer
j    next diff
k    previous diff
0    expand all folded code
<n>  show only n levels of context (1 ≤ n ≤ 6)

Requirements

Delta works best in Chrome and Safari and has only been tested on OS X. You will see a separate tab open for each diff file, and then the tabs will consolidate into a single tab. git invokes the difftool once for each file, so the logic for joining subsequent invocations of delta into a single view lives on the client side.

In Firefox, each diff will remain in separate tabs. This is because each local file receives its own IndexedDB instance in Firefox, instead of a shared instance.

Credits

License

MIT