version 1.17, 2003/10/31 20:20:45 |
version 1.18, 2007/04/18 21:52:24 |
|
|
.Nd apply a diff file to an original |
.Nd apply a diff file to an original |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm patch |
.Nm patch |
.Op Cm options |
.Bk -words |
|
.Op Fl bCcEeflNnRstuv |
|
.Op Fl B Ar backup-prefix |
|
.Op Fl D Ar symbol |
|
.Op Fl d Ar directory |
|
.Op Fl F Ar max-fuzz |
|
.Op Fl i Ar patchfile |
|
.Op Fl o Ar out-file |
|
.Op Fl p Ar strip-count |
|
.Op Fl r Ar rej-name |
|
.Op Fl V Cm t | nil | never |
|
.Op Fl x Ar number |
|
.Op Fl z Ar backup-ext |
|
.Op Fl Fl posix |
.Op Ar origfile Op Ar patchfile |
.Op Ar origfile Op Ar patchfile |
|
.Ek |
.Nm patch |
.Nm patch |
.Pf \*(Lt Ar patchfile |
.Pf \*(Lt Ar patchfile |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
|
|
.Pp |
.Pp |
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
|
.It Xo |
|
.Fl B Ar backup-prefix , |
|
.Fl Fl prefix Ar backup-prefix |
|
.Xc |
|
Causes the next argument to be interpreted as a prefix to the backup file |
|
name. |
|
If this argument is specified, any argument to |
|
.Fl z |
|
will be ignored. |
.It Fl b , Fl Fl backup |
.It Fl b , Fl Fl backup |
Save a backup copy of the file before it is modified. |
Save a backup copy of the file before it is modified. |
By default the original file is saved with a backup extension of |
By default the original file is saved with a backup extension of |
|
|
unless the file already has a numbered backup, in which case a numbered |
unless the file already has a numbered backup, in which case a numbered |
backup is made. |
backup is made. |
This is equivalent to specifying |
This is equivalent to specifying |
.Qo Fl V Ar existing Qc . |
.Qo Fl V Cm existing Qc . |
This option is currently the default but that will change in a future release. |
This option is currently the default but that will change in a future release. |
.It Fl B , Fl Fl prefix |
.It Fl C , Fl Fl check |
Causes the next argument to be interpreted as a prefix to the backup file |
Checks that the patch would apply cleanly, but does not modify anything. |
name. |
|
If this argument is specified, any argument to |
|
.Fl z |
|
will be ignored. |
|
.It Fl c , Fl Fl context |
.It Fl c , Fl Fl context |
Forces |
Forces |
.Nm |
.Nm |
to interpret the patch file as a context diff. |
to interpret the patch file as a context diff. |
.It Fl C , Fl Fl check |
.It Xo |
Checks that the patch would apply cleanly, but does not modify anything. |
.Fl D Ar symbol , |
.It Fl d , Fl Fl directory |
.Fl Fl ifdef Ar symbol |
|
.Xc |
Causes |
Causes |
.Nm |
.Nm |
to interpret the next argument as a directory, and |
|
.Xr cd 1 |
|
to it before doing anything else. |
|
.It Fl D , Fl Fl ifdef |
|
Causes |
|
.Nm |
|
to use the |
to use the |
.Qq #ifdef...#endif |
.Qq #ifdef...#endif |
construct to mark changes. |
construct to mark changes. |
|
|
Note that, unlike the C compiler, there must be a space between the |
Note that, unlike the C compiler, there must be a space between the |
.Fl D |
.Fl D |
and the argument. |
and the argument. |
|
.It Xo |
|
.Fl d Ar directory , |
|
.Fl Fl directory Ar directory |
|
.Xc |
|
Causes |
|
.Nm |
|
to interpret the next argument as a directory, and |
|
.Xr cd 1 |
|
to it before doing anything else. |
|
.It Fl E , Fl Fl remove-empty-files |
|
Causes |
|
.Nm |
|
to remove output files that are empty after the patches have been applied. |
|
This option is useful when applying patches that create or remove files. |
.It Fl e , Fl Fl ed |
.It Fl e , Fl Fl ed |
Forces |
Forces |
.Nm |
.Nm |
to interpret the patch file as an |
to interpret the patch file as an |
.Xr ed 1 |
.Xr ed 1 |
script. |
script. |
.It Fl E , Fl Fl remove-empty-files |
.It Xo |
Causes |
.Fl F Ar max-fuzz , |
|
.Fl Fl fuzz Ar max-fuzz |
|
.Xc |
|
Sets the maximum fuzz factor. |
|
This option only applies to context diffs, and causes |
.Nm |
.Nm |
to remove output files that are empty after the patches have been applied. |
to ignore up to that many lines in looking for places to install a hunk. |
This option is useful when applying patches that create or remove files. |
Note that a larger fuzz factor increases the odds of a faulty patch. |
|
The default fuzz factor is 2, and it may not be set to more than |
|
the number of lines of context in the context diff, ordinarily 3. |
.It Fl f , Fl Fl force |
.It Fl f , Fl Fl force |
Forces |
Forces |
.Nm |
.Nm |
|
|
.Fl s |
.Fl s |
for that. |
for that. |
.It Xo |
.It Xo |
.Fl F Ns Aq Ar number , |
.Fl i Ar patchfile , |
.Fl Fl fuzz Aq Ar number |
.Fl Fl input Ar patchfile |
.Xc |
.Xc |
Sets the maximum fuzz factor. |
|
This option only applies to context diffs, and causes |
|
.Nm |
|
to ignore up to that many lines in looking for places to install a hunk. |
|
Note that a larger fuzz factor increases the odds of a faulty patch. |
|
The default fuzz factor is 2, and it may not be set to more than |
|
the number of lines of context in the context diff, ordinarily 3. |
|
.It Fl i , Fl Fl input |
|
Causes the next argument to be interpreted as the input file name |
Causes the next argument to be interpreted as the input file name |
(i.e. a patchfile). |
(i.e. a patchfile). |
This option may be specified multiple times. |
This option may be specified multiple times. |
|
|
in the input file. |
in the input file. |
Normal characters must still match exactly. |
Normal characters must still match exactly. |
Each line of the context must still match a line in the input file. |
Each line of the context must still match a line in the input file. |
.It Fl n , Fl Fl normal |
|
Forces |
|
.Nm |
|
to interpret the patch file as a normal diff. |
|
.It Fl N , Fl Fl forward |
.It Fl N , Fl Fl forward |
Causes |
Causes |
.Nm |
.Nm |
to ignore patches that it thinks are reversed or already applied. |
to ignore patches that it thinks are reversed or already applied. |
See also |
See also |
.Fl R . |
.Fl R . |
.It Fl o , Fl Fl output |
.It Fl n , Fl Fl normal |
|
Forces |
|
.Nm |
|
to interpret the patch file as a normal diff. |
|
.It Xo |
|
.Fl o Ar out-file , |
|
.Fl Fl output Ar out-file |
|
.Xc |
Causes the next argument to be interpreted as the output file name. |
Causes the next argument to be interpreted as the output file name. |
.It Xo |
.It Xo |
.Fl p Ns Aq Ar number , |
.Fl p Ar strip-count , |
.Fl Fl strip Aq Ar number |
.Fl Fl strip Ar strip-count |
.Xc |
.Xc |
Sets the pathname strip count, |
Sets the pathname strip count, |
which controls how pathnames found in the patch file are treated, |
which controls how pathnames found in the patch file are treated, |
|
|
or the directory specified by the |
or the directory specified by the |
.Fl d |
.Fl d |
option. |
option. |
.It Fl r , Fl Fl reject-file |
|
Causes the next argument to be interpreted as the reject file name. |
|
.It Fl R , Fl Fl reverse |
.It Fl R , Fl Fl reverse |
Tells |
Tells |
.Nm |
.Nm |
|
|
reversed normal diffs will begin with a delete, which will fail, triggering |
reversed normal diffs will begin with a delete, which will fail, triggering |
the heuristic.) |
the heuristic.) |
.It Xo |
.It Xo |
|
.Fl r Ar rej-name , |
|
.Fl Fl reject-file Ar rej-name |
|
.Xc |
|
Causes the next argument to be interpreted as the reject file name. |
|
.It Xo |
.Fl s , Fl Fl quiet , |
.Fl s , Fl Fl quiet , |
.Fl Fl silent |
.Fl Fl silent |
.Xc |
.Xc |
|
|
Forces |
Forces |
.Nm |
.Nm |
to interpret the patch file as a unified context diff (a unidiff). |
to interpret the patch file as a unified context diff (a unidiff). |
.It Fl v , Fl Fl version |
.It Xo |
Causes |
.Fl V Cm t | nil | never , |
.Nm |
.Fl Fl version-control Cm t | nil | never |
to print out its revision header and patch level. |
.Xc |
.It Fl V , Fl Fl version-control |
|
Causes the next argument to be interpreted as a method for creating |
Causes the next argument to be interpreted as a method for creating |
backup file names. |
backup file names. |
The type of backups made can also be given in the |
The type of backups made can also be given in the |
|
|
variable; they also recognize synonyms that are more descriptive. |
variable; they also recognize synonyms that are more descriptive. |
The valid values are (unique abbreviations are accepted): |
The valid values are (unique abbreviations are accepted): |
.Bl -tag -width Ds -offset indent |
.Bl -tag -width Ds -offset indent |
.It t , numbered |
.It Cm t , numbered |
Always make numbered backups. |
Always make numbered backups. |
.It nil , existing |
.It Cm nil , existing |
Make numbered backups of files that already have them, |
Make numbered backups of files that already have them, |
simple backups of the others. |
simple backups of the others. |
.It never , simple |
.It Cm never , simple |
Always make simple backups. |
Always make simple backups. |
.El |
.El |
|
.It Fl v , Fl Fl version |
|
Causes |
|
.Nm |
|
to print out its revision header and patch level. |
.It Xo |
.It Xo |
.Fl x Ns Aq Ar number , |
.Fl x Ar number , |
.Fl Fl debug Aq Ar number |
.Fl Fl debug Ar number |
.Xc |
.Xc |
Sets internal debugging flags, and is of interest only to |
Sets internal debugging flags, and is of interest only to |
.Nm |
.Nm |
patchers. |
patchers. |
.It Fl z , Fl Fl suffix |
.It Xo |
|
.Fl z Ar backup-ext , |
|
.Fl Fl suffix Ar backup-ext |
|
.Xc |
Causes the next argument to be interpreted as the backup extension, to be |
Causes the next argument to be interpreted as the backup extension, to be |
used in place of |
used in place of |
.Qq .orig . |
.Qq .orig . |