Skip to content
Latchkey

diffstat: Summarize a Diff as a Changed-Lines Histogram

diffstat reads a unified diff on stdin and prints a per-file histogram of how many lines were inserted, deleted, and changed.

diffstat turns a wall of diff into a scannable summary. In CI it is handy for surfacing the size and spread of a change without printing every line.

What it does

diffstat parses a diff (unified or context) and outputs one line per file with counts of insertions (+), deletions (-), and modifications (!), plus a total. It reads from stdin or a file; it does not compute the diff itself.

Common usage

Terminal
git diff | diffstat
diff -u a b | diffstat
# summarize a patch file with colors and totals
diffstat -C changes.patch

Options

FlagWhat it does
-CColorize insertions/deletions
-f <n>Output format (0 minimal, higher = more detail)
-p <n>Strip n path components from filenames
-w <n>Set the width of the histogram
-sPrint only the summary line (totals)

In CI

Pipe git diff into diffstat to post a compact "what changed" summary as a PR comment or job log line. You can also gate on size: git diff | diffstat -s gives totals you can parse to flag unexpectedly large or wide changes for review.

Common errors in CI

Empty output means the input was not a diff (e.g. you piped raw file contents, not diff output) or the diff was empty. "diffstat: command not found" means the package is not installed. If line counts look doubled, you likely fed it a diff that already had context expanded oddly, or two concatenated diffs of the same files.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →