File: filterdiff.1

package info (click to toggle)
patchutils 0.2.31-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,384 kB
  • ctags: 261
  • sloc: sh: 6,195; ansic: 5,749; xml: 1,971; perl: 398; makefile: 367
file content (195 lines) | stat: -rw-r--r-- 5,914 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
.\"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 <twaugh@redhat\&.com>.