FILTERDIFF(1) | Man pages | FILTERDIFF(1) |
NAME
filterdiff - extract or exclude diffs from a diff file
SYNOPSIS
filterdiff [[-i PATTERN] | [--include=PATTERN]] [[-I FILE] | [--include-from-file=FILE]] [[-p n] | [--strip-match=n]] [--strip=n] [--addprefix=PREFIX] [--addoldprefix=PREFIX] [--addnewprefix=PREFIX] [[-x PATTERN] | [--exclude=PATTERN]] [[-X FILE] | [--exclude-from-file=FILE]] [[-v] | [--verbose]] [--clean] [[-z] | [--decompress]] [[-# RANGE] | [--hunks=RANGE]] [--lines=RANGE] [[-FRANGE] | [--files=RANGE]] [--annotate] [--format=FORMAT] [--as-numbered-lines=WHEN] [--remove-timestamps] [file...]
filterdiff {[--help] | [--version] | [--list] | [--grep ...]}
DESCRIPTION
You can use filterdiff to obtain a patch that applies to files matching the shell wildcard PATTERN from a larger collection of patches. For example, to see the patches in patch-2.4.3.gz that apply to all files called lp.c:
filterdiff -z -i '*/lp.c' patch-2.4.3.gz
If neither -i nor -x options are given, -i '*' is assumed. This way filterdiff 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:
filterdiff message-with-diff-in-the-body > patch
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 fnmatch). This is so that “*/basename”-type patterns can be given without limiting the number of pathname components.
You can use both unified and context format diffs with this program.
OPTIONS
-i PATTERN, --include=PATTERN
-I FILE, --include-from-file=FILE
-x PATTERN, --exclude=PATTERN
-X FILE, --exclude-from-file=FILE
-p n, --strip-match=n
-# RANGE, --hunks=RANGE
--lines=RANGE
-F=RANGE, --files=RANGE
--annotate
--format=unified|context
--strip=n
--addprefix=PREFIX
--addoldprefix=PREFIX
--addnewprefix=PREFIX
--as-numbered-lines=before|after
--remove-timestamps
-v, --verbose
--clean
-z, --decompress
--help
--version
--list
--grep
EXAMPLES
To see all patch hunks that affect the first five lines of a C file:
filterdiff -i '*.c' --lines=-5 < patch
To see the first hunk of each file patch, use:
filterdiff -#1 patchfile
To see patches modifying a ChangeLog file in a subdirectory, use:
filterdiff -p1 Changelog
To see the complete patches for each patch that modifies line 1 of the original file, use:
filterdiff --lines=1 patchfile | lsdiff | \ xargs -rn1 filterdiff patchfile -i
To see all but the first hunk of a particular patch, you might use:
filterdiff -p1 -i file.c -#2- foo-patch
If you have a very specific list of hunks in a patch that you want to see, list them:
filterdiff -#1,2,5-8,10,12,27-
To see the lines of the files that would be patched as they will appear after the patch is applied, use:
filterdiff --as-numbered-lines=after patch.file
You can see the same context before the patch is applied with:
filterdiff --as-numbered-lines=before patch.file
Filterdiff can also be used to convert between unified and context format diffs:
filterdiff -v --format=unified context.diff
SEE ALSO
AUTHOR
Tim Waugh <twaugh@redhat.com>
23 Jan 2009 | patchutils |