diffstat
Summarize diff output statistics
TLDR
Display changes in a histogram
Display inserted, deleted, and modified changes as a table
SYNOPSIS
diffstat [OPTION]... [diff-file]
PARAMETERS
-V, --version
Print version information
-h, --help
Display help and exit
-ffile, --output-file=file
Write output to file instead of stdout
-Cn, --context=n
Assume n context lines per hunk
-c, --cumulative
Produce cumulative reverse histogram
-Ddir, --directory=dir
Strip longest common directory prefix
-Fpat, --strip-file-prefix=pat
Strip pat from beginning of filenames
-Hn, --height-normal=n
Set height of normal histogram to n
-hn, --height-summary=n
Set height of summary histogram to n
-l, --list-only
List filenames without histogram
-mn, --max-line=n
Width of widest histogram line is n
-nn, --files=n
Limit to n most changed files
-rregex, --remove=regex
Omit files matching regex
-s, --stats
Print only summary statistics
-tchars, --types=chars
Use chars for file type symbols
-T, --topline
Print concise topline summary
-u, --omit-unmodified
Suppress unchanged files
-v, --verbose
Increase verbosity
-Wn, --width-total=n
Total histogram width n (default 80)
-wn, --width=n
Histogram width per file n chars
-a, --adjust-width
Adjust histogram widths proportionally
-k, --keep-widths
Keep original widths (non-proportional)
-q, --quiet
Suppress warnings
DESCRIPTION
diffstat is a command-line tool that analyzes the output of the diff utility and generates a concise histogram summarizing changes across files. Each bar in the histogram represents a file, with | for insertions, - for deletions, >> for modifications, and ++ for combined changes. It helps developers quickly assess the scope and impact of patches, especially in large projects or when reviewing git diffs, quilt patches, or kernel changelogs.
By default, diffstat reads from stdin or a single input file containing unified or context diff format. It strips common directory prefixes, sorts files alphabetically, and adjusts histogram widths dynamically. Options allow customization of output format, widths, heights, verbosity, and filtering. For example, it can omit unmodified files, limit file counts, or produce cumulative stats.
Common use cases include piping diff -u output through diffstat for visual summaries, integrating into build scripts, or enhancing git log --stat views. While powerful for overviews, it doesn't parse all diff variants perfectly and focuses on stats rather than applying changes.
CAVEATS
Best with unified/context diffs; may misparse non-standard formats. Histogram scales to fit, potentially truncating extreme changes. No color support by default.
EXAMPLE
diff -u old.c new.c | diffstat
old.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
HISTORY
Developed by Thomas Koenig in 1991 at University of Heidelberg. First released publicly around 1993. Maintained sporadically; latest versions (1.64+) support more options. Widely used in Linux kernel development and open-source workflows since 1990s.


