Newshot

Dffy: A fast terminal-native Git diff viewer, written in Rust

Original text(via Hacker News)

dffy

A terminal diff viewer for git, written in Rust.

Built for large repositories, up to the size of the Linux kernel.


        dffy                   # everything you haven't committed
dffy main..HEAD        # any revision git understands
      
dffy reviewing the Linux v6.0..v6.1 diff
dffy reviewing the Linux v6.0..v6.1 diff

Install


        brew install --cask amalucelli/tap/dffy
# or
curl -fsSL https://raw.githubusercontent.com/amalucelli/dffy/main/install.sh | sh
# plus the experimental Markdown renderer: … | sh -s -- --plugin markdown
      

docs/install.md covers mise, building from source and the renderer plugins. Then try it in any repository: dffy HEAD~10.

About

dffy is a diff viewer for the terminal. Run it in a git repository and it opens a full-screen view of your changes: a file tree on the left, the diff on the right, split or unified. Pipe it, and it prints the diff instead.

It's built for big diffs. Instead of computing the whole diff up front, dffy shows the first files as soon as it finds them and works on the rest in the background, so a 13,000-file change opens as fast as a one-line fix.

It fits into how you already work. Every action is a single key, the layout adapts from a wide monitor down to a phone over SSH, and dffy can stand in for git's pager, git add -p filter and difftool. Settings live in a plain config file you can keep with your dotfiles.

Why dffy

dffy builds on tools I like: the terminal review flow of lumen, the review UX of hunk, and the rendering of diffs.com (Pierre's @pierre/diffs). None of them fit how I work. lumen centers on AI features I didn't want in a diff viewer. hunk is TypeScript on a JavaScript runtime, and I wanted a single native binary that stays fast on huge repos. diffs.com runs in the browser. So I built a native terminal diff viewer that works the same on a laptop and over SSH from a phone.

Features

  • ⚡ Opens the Linux v6.0..v6.1 diff in 9.5ms and loads the rest in the background.
  • 👀 --watch repaints as you edit, stage and commit.

Reading diffs

  • 🪟 Split or unified, picked by terminal width.
  • 🌈 Syntax highlighting for 18 languages, with changed words emphasized.
  • 🌳 A syntax-aware diff (d) that marks reformatted (~) and moved (») code.
  • 🔁 Renames detected the way git detects them.
  • 🗂️ A file tree, a fuzzy file picker and search across the diff.
  • 🎯 Each file opens at its first change, and n/N jump between changes.
  • ⌨️ Single-key actions, with a command panel on space.
  • 🧾 Staged, unstaged and untracked changes in one view, or any revision.
  • 📟 Works as git's pager, git add -p filter and difftool.
  • 📁 Compares files and folders outside a repository too.
  • 📱 Works on phones over SSH, with plain-letter keys and a frameless layout.
  • 🖱️ Mouse selection that copies over SSH.
  • 🎨 16 themes and a config file for your dotfiles.
  • 🧩 Renderer plugins (experimental), such as Markdown diffed as rendered text.

Usage


        dffy                        # staged, unstaged and untracked changes
dffy --staged               # what's staged (git diff --cached)
dffy HEAD~3                 # a revision against the working tree
dffy main...feature         # changes since the merge base
dffy show HEAD              # a commit with its message
dffy main.. -- src/         # limited to paths
dffy a.txt b.txt            # two files or folders, no repository needed
dffy --watch                # refresh on every change
dffy --syntax v6.0 v6.1     # diff by syntax
dffy --stat main..          # also --name-only, --name-status, --exit-code
      

        git config --global core.pager dffy
git config --global interactive.diffFilter "dffy --color-only"
      

In the viewer, n/N move between changes, f/F between files, / searches, o finds a file, space lists commands and q quits. ~/.config/dffy/config holds key = value lines; dffy config --default lists every key with its default.

Comparison

dffyhunklumendifftasticdeltadiff-so-fancydiff
Interactive viewer with a file tree✅✅✅❌❌❌❌
Watch mode✅✅✅❌❌❌❌
git's pager (reads a diff on stdin)✅✅❌❌✅✅❌
git add -p filter✅❌❌❌✅✅❌
Syntax highlighting✅✅✅✅✅❌❌
Changed-word emphasis✅✅✅✅✅🟡❌
Syntax-aware diff✅❌❌✅❌❌❌
Split and unified, picked by width✅✅❌🟡🟡❌🟡
Mouse✅✅✅❌❌❌❌
Compares files outside a repository✅🟡❌✅✅🟡✅
Plugins or extensions🟡🟡❌❌❌❌❌
Single native binary✅🟡✅✅✅❌✅
AI or agent annotations❌✅🟡❌❌❌❌
Other VCSs (Jujutsu, Mercurial, Sapling)❌✅✅✅✅🟡—

🟡 means partial support; docs/benchmarks.md explains each one. All seven are open source. GNU diff is GPL-3.0-or-later and the rest are MIT. Checked against hunk 0.25.0, lumen 2.32.0, difftastic 0.72.0, delta 0.20.1, diff-so-fancy 1.4.14 and GNU diffutils 3.10; docs/benchmarks.md links the source for every cell.

Benchmarks

Opening Linux v6.0..v6.1 (13,168 changed files, a 48MB patch) in a viewer, time until the first changed line is on screen:

dffylumen 2.32.0hunk 0.25.0
The v6.0..v6.1 range9.5ms12.4s17.7s
The working tree (5 files changed)63ms1.12s790ms
As a pager, git diff v6.0 v6.1 │ …217msn/a15.3s
Memory, opening the range90MB676MB4.26GB

As git's pager, dffy streams the whole 48MB patch in 3.0MB of its own memory, about as fast as plain git diff.

docs/benchmarks.md has the machine, the method, every command and the full results, including printed output against delta, diff-so-fancy and difftastic.

Architecture

dffy is written in Rust. docs/architecture.md covers the crates, the data flow and the engine.

  • 🧮 Its own diff engine: histogram and syntax-aware diffs, renames matching git's.
  • 🖼️ Its own terminal renderer, with no TUI framework. A full frame takes about 200µs.
  • 🌊 Streamed input and output, so the first screen doesn't wait for the whole diff.
  • 🛰️ One shared watcher per repository, however many views are open.

Docs

docs/ covers every key, flag and setting: usage, the viewer, keys, configuration, themes, git integration, watch mode, renderer plugins, troubleshooting, architecture and benchmarks.

License

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Hacker News
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗