combinediff
Combine unified diff patches into one
SYNOPSIS
combinediff [OPTION...] FILE1 FILE2
PARAMETERS
-h, --help
display this help and exit
--version
output version information and exit
-o FILE, --output=FILE
place resulting patch into FILE (default: stdout)
-p NUM, --strip-match=NUM
strip NUM leading path components from filenames
-L STRING, --label=STRING
use STRING as label in patch header instead of filename
-i FILE, --include-from=FILE
include hunks from FILE before processing FILE1
-s, --stats
print summary statistics on hunks combined
DESCRIPTION
combinediff is a utility from the GNU diffutils package that combines two patch files (typically generated by diff) into a single patch representing the cumulative changes. It processes FILE1, a diff from original to intermediate version (A→B), and FILE2, a diff from intermediate to final (B→C), producing output equivalent to A→C.
This tool shines in collaborative development, allowing merger of incremental patches without reapplying them sequentially via patch. It handles overlapping changes intelligently, resolving conflicts where possible, and supports common formats like unified diffs (-u, -U) and context diffs (-c).
Key capabilities include path stripping for portable patches, custom headers, statistics on hunk processing, and inclusion of extra hunks. Most diff formatting options are supported for flexible output control. By default, output goes to stdout; use -o for files.
Ideal for pre-Git workflows or patch-based systems, it ensures clean, applyable diffs but requires input patches to be compatible—FILE2 must base on FILE1's result.
CAVEATS
Patches must be compatible (FILE2 based on FILE1's result); mismatches cause errors or invalid output. Supports unified/context formats; mixing may fail.
EXAMPLE
combinediff orig-v1.patch v1-v2.patch -o orig-v2.patch
Combines incremental patches into direct orig→v2 patch.
FORMAT CONTROL
Use -u or -U 3 (like diff) for unified output; -c for context.
HISTORY
Added to GNU diffutils 2.7 (1999) by David S. Miller; evolved with diffutils for better patch handling in collaborative coding.


