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] [[-FRANGE] |
16                  [--files=RANGE]] [--annotate] [--format=FORMAT]
17                  [--as-numbered-lines=WHEN] [--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, optionially preceeded by a modifier 'x' which
68           inverts the entire range; either the first or the last in the span
69           may be omitted to indicate no limit in that direction.
70
71       --lines=RANGE
72           Only include hunks that contain lines from the original file that
73           lie within the specified RANGE. Lines are numbered from 1, and the
74           range is a comma-separated list of numbers or “first-last” spans,
75           optionially preceeded by a modifier 'x' which inverts the entire
76           range; either the first or the last in the span may be omitted to
77           indicate no limit in that direction.
78
79       -F=RANGE, --files=RANGE
80           Only include files indicated by the specified RANGE. Files are
81           numbered from 1 in the order they appear in the patch input, and
82           the range is a comma-separated list of numbers or “first-last”
83           spans, optionially preceeded by a modifier 'x' which inverts the
84           entire range; either the first or the last in the span may be
85           omitted to indicate no limit in that direction.
86
87       --annotate
88           Annotate each hunk with the filename and hunk number.
89
90       --format=unified|context
91           Use specified output format.
92
93       --strip=n
94           Remove the first n components of pathnames in the output.
95
96       --addprefix=PREFIX
97           Prefix pathnames in the output by PREFIX. This will override any
98           individual settings specified with the --addoldprefix or
99           --addnewprefix options.
100
101       --addoldprefix=PREFIX
102           Prefix pathnames for old or original files in the output by PREFIX.
103
104       --addnewprefix=PREFIX
105           Prefix pathnames for updated or new files in the output by PREFIX.
106
107       --as-numbered-lines=before|after
108           Instead of a patch fragment, display the lines of the selected
109           hunks with the line number of the file before (or after) the patch
110           is applied, followed by a TAB character and a colon, at the
111           beginning of each line. Each hunk except the first will have a line
112           consisting of “...”  before it.
113
114       --remove-timestamps
115           Do not include file timestamps in the output.
116
117       -v, --verbose
118           Always show non-diff lines in the output. By default, non-diff
119           lines are only shown when excluding a filename pattern.
120
121       --clean
122           Always remove all non-diff lines from the output. Even when
123           excluding a filename pattern.
124
125       -z, --decompress
126           Decompress files with extensions .gz and .bz2.
127
128       --help
129           Display a short usage message.
130
131       --version
132           Display the version number of filterdiff.
133
134       --list
135           Behave like lsdiff(1) instead.
136
137       --grep
138           Behave like grepdiff(1) instead.
139

EXAMPLES

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

SEE ALSO

184       lsdiff(1), grepdiff(1)
185

AUTHOR

187       Tim Waugh <twaugh@redhat.com>
188           Package maintainer
189
190
191
192patchutils                        23 Jan 2009                    FILTERDIFF(1)
Impressum