.\"Generated by db2man.xsl. Don't modify this, modify the source. .de Sh \" Subsection .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH "FILTERDIFF" 1 "7 May 2004" "patchutils" "" .SH NAME filterdiff \- extract or exclude diffs from a diff file .SH "SYNOPSIS" .ad l .hy 0 .HP 11 \fBfilterdiff\fR [\-i\ \fIPATTERN\fR] [\-p\ \fIn\fR] [\-\-strip=\fIn\fR] [\-\-addprefix=\fIPREFIX\fR] [\-x\ \fIPATTERN\fR] [\-\-verbose] [\-v] [\-z] [\fB\-#\ \fIRANGE\fR\fR | \fB\-\-hunks=\fIRANGE\fR\fR] [\-\-lines=\fIRANGE\fR] [\-\-files=\fIRANGE\fR] [\-\-annotate] [\-\-format=\fIFORMAT\fR] [\-\-as\-numbered\-lines=\fIWHEN\fR] [\-\-remove\-timestamps] [\fIfile\fR...] .ad .hy .ad l .hy 0 .HP 11 \fBfilterdiff\fR {\fB\-\-help\fR | \fB\-\-version\fR | \fB\-\-list\fR | \fB\-\-grep\ \&.\&.\&.\fR} .ad .hy .SH "DESCRIPTION" .PP You can use filterdiff to obtain a patch that applies to files matching the shell wildcard \fIPATTERN\fR from a larger collection of patches\&. For example, to see the patches in \fIpatch\-2\&.4\&.3\&.gz\fR that apply to all files called \fIlp\&.c\fR: .IP filterdiff \-z \-i '*/lp\&.c' patch\-2\&.4\&.3\&.gz .PP If neither \fB\-i\fR nor \fB\-x\fR options are given, \fB\-i '*'\fR is assumed\&. This way \fBfilterdiff\fR can be used to clean up an existing diff file, removing redundant lines from the beginning (eg\&. the text from the mail body) or between the chunks (eg\&. in CVS diffs)\&. To extract pure patch data, use a command like this: .IP filterdiff message\-with\-diff\-in\-the\-body > patch .PP Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to \fBfnmatch\fR)\&. This is so that ``*/basename''\-type patterns can be given without limiting the number of pathname components\&. .PP You can use both unified and context format diffs with this program\&. .SH "OPTIONS" .TP \fB\-i\fR \fIPATTERN\fR Include only files matching \fIPATTERN\fR\&. All other lines in the input are suppressed\&. .TP \fB\-x\fR \fIPATTERN\fR Exclude files matching \fIPATTERN\fR\&. All other lines in the input are displayed\&. .TP \fB\-p\fR \fIn\fR When matching, ignore the first \fIn\fR components of the pathname\&. .TP \fB\-#\fR \fIRANGE\fR | \fB\-\-hunks\fR=\fIRANGE\fR Only include hunks within the specified \fIRANGE\fR\&. Hunks are numbered from 1, and the range is a comma\-separated list of numbers or ``first\-last'' spans; either the first or the last in the span may be omitted to indicate no limit in that direction\&. .TP \fB\-\-lines\fR=\fIRANGE\fR Only include hunks that contain lines from the original file that lie within the specified \fIRANGE\fR\&. Lines are numbered from 1, and the range is a comma\-separated list of numbers or ``first\-last'' spans; either the first or the last in the span may be omitted to indicate no limit in that direction\&. .TP \fB\-\-files\fR=\fIRANGE\fR Only include files indicated by the specified \fIRANGE\fR\&. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma\-separated list of numbers or ``first\-last'' spans; either the first or the last in the span may be omitted to indicate no limit in that direction\&. .TP \fB\-\-annotate\fR Annotate each hunk with the filename and hunk number\&. .TP \fB\-\-format\fR=unified|context Use specified output format\&. .TP \fB\-\-strip\fR=\fIn\fR Remove the first \fIn\fR components of pathnames in the output\&. .TP \fB\-\-addprefix\fR=\fIPREFIX\fR Prefix pathnames in the output by \fIPREFIX\fR\&. .TP \fB\-\-as\-numbered\-lines\fR=before|after Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line\&. Each hunk except the first will have a line consisting of ``\&.\&.\&.'' before it\&. .TP \fB\-\-remove\-timestamps\fR Do not include file timestamps in the output\&. .TP \fB\-v\fR, \fB\-\-verbose\fR Always show non\-diff lines in the output\&. By default, non\-diff lines are only shown when excluding a filename pattern\&. .TP \fB\-z\fR Decompress files with extensions \&.gz and \&.bz2\&. .TP \fB\-\-help\fR Display a short usage message\&. .TP \fB\-\-version\fR Display the version number of filterdiff\&. .TP \fB\-\-list\fR Behave like \fBlsdiff\fR(1) instead\&. .TP \fB\-\-grep\fR Behave like \fBgrepdiff\fR(1) instead\&. .SH "EXAMPLES" .PP To see all patch hunks that affect the first five lines of a C file: .IP filterdiff \-i '*\&.c' \-\-lines=\-5 < patch .PP To see the first hunk of each file patch, use: .IP filterdiff \-#1 patchfile .PP To see patches modifying a ChangeLog file in a subdirectory, use: .IP filterdiff \-p1 Changelog .PP To see the complete patches for each patch that modifies line 1 of the original file, use: .IP filterdiff \-\-lines=1 patchfile | lsdiff | \\ xargs \-rn1 filterdiff patchfile \-i .PP To see all but the first hunk of a particular patch, you might use: .IP filterdiff \-p1 \-i file\&.c \-#2\- foo\-patch .PP If you have a very specific list of hunks in a patch that you want to see, list them: .IP filterdiff \-#1,2,5\-8,10,12,27\- .PP To see the lines of the files that would be patched as they will appear after the patch is applied, use: .IP filterdiff \-\-as\-numbered\-lines=after patch\&.file .PP You can see the same context before the patch is applied with: .IP filterdiff \-\-as\-numbered\-lines=before patch\&.file .PP Filterdiff can also be used to convert between unified and context format diffs: .IP filterdiff \-v \-\-format=unified context\&.diff .SH "SEE ALSO" .PP \fBlsdiff\fR(1), \fBgrepdiff\fR(1) .SH AUTHOR Tim Waugh .