DIFFSTAT(1)

โœจ DIFFSTAT โœจ

okay so bestie, let me put you onto diffstat โ€” it lives in the User commands section of the manual, and it's literally the glow-up your patch review routine has been missing ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

diffstat โ€” make histogram from diff-output

like, it turns your diff into a lil picture of bars. iconic behavior honestly.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

diffstat [options] [file-specifications]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so here's the tea: this program reads the output of diff and shows you a histogram of the insertions, deletions, and modifications per-file. diffstat is a program that's genuinely useful for reviewing large, complex patch files. it reads from one or more input files that contain output from diff, and it produces a histogram of the total lines changed for each file referenced. no cap.

if the input filename ends with .bz2, .gz, .lzma, .xz, .zst, .z or .Z, diffstat will read the uncompressed data via a pipe from the corresponding program. it can also infer the compression type from files piped via the standard input. so it's giving mind reader, lowkey ๐Ÿ”ฎ

diffstat recognizes the most popular types of output from diff:

  • unified โ€” preferred by the patch utility.
  • context โ€” best for readability, but not very compact.
  • default โ€” not good for much, but simple to generate.

diffstat detects the lines that are output by diff to tell which files are compared, and then counts the markers in the first column that denote the type of change (insertion, deletion or modification). these are shown in the histogram as +, - and ! characters. cute lil symbols fr.

if no filename is given on the command line, diffstat reads the differences from the standard input.


๐Ÿ’– OPTIONS ๐Ÿ’–

  • -b โ€” ignore lines matching Binary files XXX and YYY differ in the diff
  • -c โ€” prefix each line of output with #, making it a comment-line for shell scripts
  • -C โ€” add SGR color escape sequences to highlight the histogram. pretty privilege, activated ๐ŸŒˆ
  • -D destination โ€” specify a directory containing files which can be referred to as the result of applying the differences. diffstat will count the lines in the corresponding files (after adjusting the names by the -p option) to obtain the total number of lines in each file.

the remainder, after subtracting modified and deleted lines, is shown as unchanged lines.

  • -d โ€” the debug prints a lot of information. it is normally compiled-in, but can be suppressed. it's giving yapper ๐Ÿ—ฃ๏ธ
  • -e file โ€” redirect standard error to file.
  • -E โ€” strip out ANSI escape sequences on each line before parsing the differences. this allows diffstat to be used with colordiff. bestie said no more rainbow interference โœจ
  • -f format โ€” specify the format of the histogram.
    • 0 for concise, which shows only the value and a single histogram code for each of insert (+), delete (-) or modify (!)
    • 1 for normal output,
    • 2 to fill in the histogram with dots,
    • 4 to print each value with the histogram.

any nonzero value gives a histogram. the dots and individual values can be combined, e.g., -f6 gives both.

  • -h โ€” prints the usage message and exits.
  • -k โ€” suppress the merging of filenames in the report.
  • -K โ€” attempt to improve the annotation of only files by looking for a match in the resulting set of files and inferring whether the file was added or removed.
this does not currently work in combination with -R because diffstat maintains only the resulting set of files.
  • -l โ€” lists only the filenames. no histogram is generated. just names, no bars, minimalist era ๐ŸŽ€
  • -m โ€” merge insert/delete counts from each chunk of the patch file to approximate a count of the modified lines.
  • -n number โ€” specify the minimum width used for filenames. if you do not specify this, diffstat uses the length of the longest filename, after stripping common prefixes.
  • -N number โ€” specify the maximum width used for filenames. names longer than this limit are truncated on the left. if you do not specify this, diffstat next checks the -n option.
  • -o file โ€” redirect standard output to file.
  • -p number โ€” override the logic that strips common pathnames, simulating the patch -p option.

if you do not give a -p option, diffstat examines the differences and strips the common prefix from the pathnames. this is not what patch does. โš ๏ธ

  • -q โ€” suppress the 0 files changed message for empty diffs.
  • -r code โ€” provides optional rounding of the data shown in histogram, rather than truncating with error adjustments.
    • 0 is the default. no rounding is performed, but accumulated errors are added to following columns.
    • 1 rounds the data
    • 2 rounds the data and adjusts the histogram to ensure that it displays something if there are any differences even if those would normally be rounded to zero.
  • -R โ€” assume patch was created with old and new files swapped.
  • -s โ€” show only the summary line, e.g., number of insertions and deletions. tl;dr mode ๐Ÿ‘‘
  • -S source โ€” this is like the -D option, but specifies a location where the original files (before applying differences) can be found.
  • -t โ€” overrides the histogram, generates output of comma separated values for the number of changed lines found in the differences for each file: inserted, deleted and modified.

if -S or -D options are given, the number of unchanged lines precedes the number of changes.

  • -T โ€” prints the numbers that the -t option would show, between the pathname and histogram.

the width of the number of changes is determined by the largest value (but at least 3). the width given in the -w option is separate from the width of these numbers.

  • -u โ€” suppress the sorting of filenames in the report.
  • -v โ€” show progress, e.g., if the output is redirected to a file, write progress messages to the standard error.
  • -V โ€” prints the current version number and exits.
  • -w number โ€” specify the maximum width of the histogram. the histogram will never be shorter than 10 columns, just in case the filenames get too large.

the default is 80 columns, unless the output is to a terminal. in that case, the default width is the terminal's width.


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

diffstat runs in a POSIX environment.

you can override the compiled-in paths of programs used for decompressing input files by setting environment variables corresponding to their name:

  • DIFFSTAT_BZCAT_PATH
  • DIFFSTAT_BZIP2_PATH
  • DIFFSTAT_COMPRESS_PATH
  • DIFFSTAT_GZIP_PATH
  • DIFFSTAT_LZCAT_PATH
  • DIFFSTAT_PCAT_PATH
  • DIFFSTAT_UNCOMPRESS_PATH
  • DIFFSTAT_XZ_PATH
  • DIFFSTAT_ZCAT_PATH
  • DIFFSTAT_ZSTD_PATH

however, diffstat assumes that the resulting program uses the same command-line options, e.g., -c to decompress to the standard output. so swap wisely bestie ๐Ÿ’€


๐Ÿงš FILES ๐Ÿงš

diffstat is a single binary module, which uses no auxiliary files. self-contained queen, we stan ๐Ÿซถ


๐Ÿ™ˆ BUGS ๐Ÿ™ˆ

diffstat makes a lot of assumptions about the format of diff's output.

there is no way to obtain a filename from the standard diff between two files with no options. context diffs work, as well as unified diffs.

there's no easy way to determine the degree of overlap between the before and after displays of modified lines. diffstat simply counts the number of inserted and deleted lines to approximate modified lines for the -m option.


๐Ÿ’œ AUTHORS ๐Ÿ’œ

Thomas Dickey <dickey@invisible-island.net>.


โญ SEE ALSO โญ

diff(1), patch(1).


okay that's the whole vibe check, you're fully caught up ๐Ÿ’– this was diffstat, version 1.69, dated 2026-04-14, straight from the User commands section. go review some patches, you got this ๐ŸŒธโœจ

๐Ÿ“ฆ where this page comes from