Why Patdiff?

Patience diff algorithm

Based on Bram Cohen’s patience diff algorithm, patdiff is optimized for diffing code and config files.

Patdiff includes both an OCaml library (Patdiff_lib) as well as a command-line tool (patdiff).

Word-level refinement

Rather than displaying a small change to a line as a wholesale removal and addition of that line, patdiff shows the word-level diff of that line.

All the usual features

  • Recursive diffing of directories
  • Extensively configurable output (markers, colors, location format, context)
  • Whitespace-aware diffing

Getting Started

Installation

$ opam install patdiff

See here for Patdiff’s opam package file.

Usage

patdiff old-file new-file

If you don’t supply any arguments to patdiff, it will read diff-like text from stdin and color it in the normal patdiff way.

The file ~/.patdiff is used as a config file if it exists. You can write a sample config with the -make-config flag.

patdiff-git-wrapper

A simple wrapper is provided for using patdiff as git’s “external diff” tool. You can enable it with:

$ export GIT_EXTERNAL_DIFF=$(where patdiff-git-wrapper.sh)

or

$ git config --global diff.external $(where patdiff-git-wrapper.sh)

Documentation

More docs, including detailed API docs, are available here.

Learn More

Bram Cohen’s explanation of Patience Diff

Patience Diff Advantages

A more detailed explanation, with examples

The patience diff algorithm