This program reads the output of diff and displays a histogram of the insertions, deletions, and modifications per-file. Diffstat is a program that is useful for reviewing large, complex patch files. It reads from one or more input files which contain output from diff, producing a histogram of the total lines changed for each file referenced.
If the input filename ends with .bz2, .gz, .lzma, .z or .Z, diffstat will read the uncompressed data via a pipe from the corresponding program. It also can infer the compression type from files piped via the standard input.
Diffstat recognizes the most popular types of output from diff:
- preferred by the patch utility.
- best for readability, but not very compact.
- 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.
If no filename is given on the command line, diffstat reads the differences from the standard input.
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
However, diffstat assumes that the resulting program uses the same command-line options, e.g., "-c" to decompress to the standard output.
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.