1FILTERDIFF(1)                      Man pages                     FILTERDIFF(1)
2
3
4

NAME

6       filterdiff - extract or exclude diffs from a diff file
7

SYNOPSIS

9       filterdiff [[-i PATTERN] | [--include=PATTERN]] [[-I FILE] |
10                  [--include-from-file=FILE]] [[-p n] | [--strip-match=n]]
11                  [--strip=n] [--addprefix=PREFIX] [--addoldprefix=PREFIX]
12                  [--addnewprefix=PREFIX] [[-x PATTERN] | [--exclude=PATTERN]]
13                  [[-X FILE] | [--exclude-from-file=FILE]] [[-v] |
14                  [--verbose]] [--clean] [[-z] | [--decompress]] [[-# RANGE] |
15                  [--hunks=RANGE]] [--lines=RANGE] [--files=RANGE]
16                  [--annotate] [--format=FORMAT] [--as-numbered-lines=WHEN]
17                  [--remove-timestamps] [file...]
18
19       filterdiff {[--help] | [--version] | [--list] | [--grep ...]}
20

DESCRIPTION

22       You can use filterdiff to obtain a patch that applies to files matching
23       the shell wildcard PATTERN from a larger collection of patches. For
24       example, to see the patches in patch-2.4.3.gz that apply to all files
25       called lp.c:
26
27           filterdiff -z -i '*/lp.c' patch-2.4.3.gz
28
29       If neither -i nor -x options are given, -i '*' is assumed. This way
30       filterdiff can be used to clean up an existing diff file, removing
31       redundant lines from the beginning (eg. the text from the mail body) or
32       between the chunks (eg. in CVS diffs). To extract pure patch data, use
33       a command like this:
34
35           filterdiff message-with-diff-in-the-body > patch
36
37       Note that the interpretation of the shell wildcard pattern does not
38       count slash characters or periods as special (in other words, no flags
39       are given to fnmatch). This is so that “*/basename”-type patterns can
40       be given without limiting the number of pathname components.
41
42       You can use both unified and context format diffs with this program.
43

OPTIONS

45       -i PATTERN, --include=PATTERN
46           Include only files matching PATTERN. All other lines in the input
47           are suppressed.
48
49       -I FILE, --include-from-file=FILE
50           Include only files matching any pattern listed in FILE, one pattern
51           per line. All other lines in the input are suppressed.
52
53       -x PATTERN, --exclude=PATTERN
54           Exclude files matching PATTERN. All other lines in the input are
55           displayed.
56
57       -X FILE, --exclude-from-file=FILE
58           Exclude files matching any pattern listed in FILE, one pattern per
59           line. All other lines in the input are displayed.
60
61       -p n, --strip-match=n
62           When matching, ignore the first n components of the pathname.
63
64       -# RANGE, --hunks=RANGE
65           Only include hunks within the specified RANGE. Hunks are numbered
66           from 1, and the range is a comma-separated list of numbers or
67           “first-last” spans; either the first or the last in the span may be
68           omitted to indicate no limit in that direction.
69
70       --lines=RANGE
71           Only include hunks that contain lines from the original file that
72           lie within the specified RANGE. Lines are numbered from 1, and the
73           range is a comma-separated list of numbers or “first-last” spans;
74           either the first or the last in the span may be omitted to indicate
75           no limit in that direction.
76
77       --files=RANGE
78           Only include files indicated by the specified RANGE. Files are
79           numbered from 1 in the order they appear in the patch input, and
80           the range is a comma-separated list of numbers or “first-last”
81           spans; either the first or the last in the span may be omitted to
82           indicate no limit in that direction.
83
84       --annotate
85           Annotate each hunk with the filename and hunk number.
86
87       --format=unified|context
88           Use specified output format.
89
90       --strip=n
91           Remove the first n components of pathnames in the output.
92
93       --addprefix=PREFIX
94           Prefix pathnames in the output by PREFIX. This will override any
95           individual settings specified with the --addoldprefix or
96           --addnewprefix options.
97
98       --addoldprefix=PREFIX
99           Prefix pathnames for old or original files in the output by PREFIX.
100
101       --addnewprefix=PREFIX
102           Prefix pathnames for updated or new files in the output by PREFIX.
103
104       --as-numbered-lines=before|after
105           Instead of a patch fragment, display the lines of the selected
106           hunks with the line number of the file before (or after) the patch
107           is applied, followed by a TAB character and a colon, at the
108           beginning of each line. Each hunk except the first will have a line
109           consisting of “...”  before it.
110
111       --remove-timestamps
112           Do not include file timestamps in the output.
113
114       -v, --verbose
115           Always show non-diff lines in the output. By default, non-diff
116           lines are only shown when excluding a filename pattern.
117
118       --clean
119           Always remove all non-diff lines from the output. Even when
120           excluding a filename pattern.
121
122       -z, --decompress
123           Decompress files with extensions .gz and .bz2.
124
125       --help
126           Display a short usage message.
127
128       --version
129           Display the version number of filterdiff.
130
131       --list
132           Behave like lsdiff(1) instead.
133
134       --grep
135           Behave like grepdiff(1) instead.
136

EXAMPLES

138       To see all patch hunks that affect the first five lines of a C file:
139
140           filterdiff -i '*.c' --lines=-5 < patch
141
142       To see the first hunk of each file patch, use:
143
144           filterdiff -#1 patchfile
145
146       To see patches modifying a ChangeLog file in a subdirectory, use:
147
148           filterdiff -p1 Changelog
149
150       To see the complete patches for each patch that modifies line 1 of the
151       original file, use:
152
153           filterdiff --lines=1 patchfile | lsdiff | \
154             xargs -rn1 filterdiff patchfile -i
155
156       To see all but the first hunk of a particular patch, you might use:
157
158           filterdiff -p1 -i file.c -#2- foo-patch
159
160       If you have a very specific list of hunks in a patch that you want to
161       see, list them:
162
163           filterdiff -#1,2,5-8,10,12,27-
164
165       To see the lines of the files that would be patched as they will appear
166       after the patch is applied, use:
167
168           filterdiff --as-numbered-lines=after patch.file
169
170       You can see the same context before the patch is applied with:
171
172           filterdiff --as-numbered-lines=before
173           patch.file
174
175       Filterdiff can also be used to convert between unified and context
176       format diffs:
177
178           filterdiff -v --format=unified context.diff
179

SEE ALSO

181       lsdiff(1), grepdiff(1)
182

AUTHOR

184       Tim Waugh <twaugh@redhat.com>
185           Package maintainer
186
187
188
189patchutils                        23 Jan 2009                    FILTERDIFF(1)
Impressum