Home

Awesome

Riff, the Refining Diff

Riff is a wrapper around diff that highlights which parts of lines have changed.

Screenshot of riff in action

Unchanged parts of changed lines are shown in yellow.

riff also helpfully highlights conflicts and merge commits.

Much like git, Riff sends its output to a pager, trying these in order:

  1. Whatever is specified in the $PAGER environment variable
  2. moar because it is nice
  3. less because it is ubiquitous

Usage

git diff | riff

Or if you do...

git config --global pager.diff riff
git config --global pager.show riff
git config --global pager.log riff
git config --global interactive.diffFilter "riff --color=on"

... then all future git diff, git show and git log --patch output will be refined.

Or you can use riff as an alias for diff:

riff file1.txt file2.txt

Configuration

You can configure riff by setting the RIFF environment variable to one or more (space separated) command line options.

For example, set RIFF=--no-adds-only-special to disable adds-only special highlighting.

Installation

With Homebrew

brew install riff

With Archlinux User Repository (AUR)

paru -S riffdiff

From the Rust Crate

cargo install riffdiff

Manual Install

  1. Go here and download the correct binary for your platform

    • If no binary exists for your platform, please report it
  2. chmod a+x riff-*

  3. mv riff-* /usr/local/bin/riff

  4. Optionally followed by this to have riff highlight git output by default:

git config --global pager.diff riff
git config --global pager.show riff
git config --global pager.log riff
git config --global interactive.diffFilter "riff --color=on"

See Also

This VSCode extension for improved Git commit message editing is nice. Yes, I wrote it and I'm tooting my own horn here.

Good choice if you (like me!) are using VSCode for Git commit message editing.

More Features

riff can highlight conflict markers created by git:

Screenshot of riff highlighting conflict markers

riff highlighting a git merge commits highlighting

Screenshot of riff highlighting merge commits

Development

If you put example input and output in the testdata directory, then cargo test will verify that they match.

On mismatches, you can run testdata-examples.sh to compare current output to the expected output for all examples, and optionally update expectations.

Invoke ci.sh to run the same thing as CI.

Invoke benchmark.py to get numbers for how fast your current source code is versus earlier releases.

Invoke git log -p | cargo run -- to demo highlighting.

Making a new release

Just invoke ./release.sh and follow instructions.

If you want to test the release script without actually releasing anything, do:

./release.sh --dry

TODO

Misc

TODO future

DONE