LinuxCommandLibrary

interdiff

Compare two patch files

TLDR

Compare diff files

$ interdiff [old_file] [new_file]
copy

Compare diff files, ignoring whitespace
$ interdiff [[-w|--ignore-all-space]] [old_file] [new_file]
copy

SYNOPSIS

interdiff [options] <diff1> <diff2>

PARAMETERS

-q, --quiet
    Suppresses diagnostic messages and non-essential output, only showing the final diff.

-z, --gunzip
    Decompresses the input patch files using gunzip before processing. Useful if patches are compressed (e.g., .gz files).

--no-timestamps
    Omits timestamp information from the output diff header lines.

--strip-comments
    Removes any comment lines (typically starting with # or specific patch-related syntax) from the output diff.

--no-headers
    Suppresses the output of header lines (e.g., --- a/file, +++ b/file) for the files that are not changed by the *interdiff* itself.

--version
    Displays the version information of the interdiff utility and exits.

--help
    Prints a summary of command-line options and exits.

DESCRIPTION

The interdiff command is a powerful utility from the patchutils suite designed to compute and display the difference between two existing patch files. Instead of comparing two source files, interdiff compares two diffs (patches).

When you have a base file, and two different patches (say, patch_v1.diff and patch_v2.diff) that apply to it, interdiff can generate a new patch that, when applied to patch_v1.diff, would result in patch_v2.diff. In essence, it shows you what changes were made *between* the two patch versions.

This is incredibly useful in development workflows, especially when maintaining or reviewing a series of patches. It allows developers to quickly see what modifications were introduced or removed in an updated version of a patch, without having to manually compare the contents of the patch files line by line.

CAVEATS

interdiff primarily expects and works best with unified diff format. While it might attempt to process other formats, its accuracy and reliability are highest with unified diffs. It operates on the changes described within the diffs, not directly on the original source files, meaning the input files must be valid diffs.

COMMON USE CASE

A typical scenario involves comparing two versions of a patch. For example, if you have patch_v1.diff and an updated version patch_v2.diff, you can see the exact changes between them by running:
interdiff patch_v1.diff patch_v2.diff > changes_v1_to_v2.diff
The resulting changes_v1_to_v2.diff can then be reviewed or applied to patch_v1.diff to transform it into patch_v2.diff.

OUTPUT FORMAT

The output of interdiff is itself a unified diff, making it easy to pipe to other diff-processing tools or apply with the patch(1) command to another diff file.

HISTORY

interdiff is part of the patchutils project, a collection of utilities for manipulating patches, developed by Andreas Gruenbacher. The patchutils suite has been a staple in Linux and open-source development environments for many years, providing essential tools for managing the creation, application, and comparison of patches, especially critical in large projects like the Linux kernel where patch submission and review workflows are extensive.

SEE ALSO

diff(1), patch(1), diffstat(1), combinediff(1)

Copied to clipboard