patch.1 (285772) | patch.1 (286795) |
---|---|
1.\"- 2.\" Copyright 1986, Larry Wall 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following condition 6.\" is met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this condition and the following disclaimer. --- 6 unchanged lines hidden (view full) --- 15.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 16.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 17.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 19.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 20.\" SUCH DAMAGE. 21.\" 22.\" $OpenBSD: patch.1,v 1.27 2014/04/15 06:26:54 jmc Exp $ | 1.\"- 2.\" Copyright 1986, Larry Wall 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following condition 6.\" is met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this condition and the following disclaimer. --- 6 unchanged lines hidden (view full) --- 15.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 16.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 17.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 19.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 20.\" SUCH DAMAGE. 21.\" 22.\" $OpenBSD: patch.1,v 1.27 2014/04/15 06:26:54 jmc Exp $ |
23.\" $FreeBSD: head/usr.bin/patch/patch.1 285772 2015-07-21 22:57:27Z cem $ 24.Dd July 21, 2015 | 23.\" $FreeBSD: head/usr.bin/patch/patch.1 286795 2015-08-15 00:42:33Z delphij $ 24.Dd August 15, 2015 |
25.Dt PATCH 1 26.Os 27.Sh NAME 28.Nm patch 29.Nd apply a diff file to an original 30.Sh SYNOPSIS 31.Nm 32.Bk -words --- 137 unchanged lines hidden (view full) --- 170This option does not suppress commentary; use 171.Fl s 172for that. 173.It Xo 174.Fl i Ar patchfile , 175.Fl Fl input Ar patchfile 176.Xc 177Causes the next argument to be interpreted as the input file name | 25.Dt PATCH 1 26.Os 27.Sh NAME 28.Nm patch 29.Nd apply a diff file to an original 30.Sh SYNOPSIS 31.Nm 32.Bk -words --- 137 unchanged lines hidden (view full) --- 170This option does not suppress commentary; use 171.Fl s 172for that. 173.It Xo 174.Fl i Ar patchfile , 175.Fl Fl input Ar patchfile 176.Xc 177Causes the next argument to be interpreted as the input file name |
178(i.e. a patchfile). | 178(i.e., a patchfile). |
179This option may be specified multiple times. 180.It Fl l , Fl Fl ignore-whitespace 181Causes the pattern matching to be done loosely, in case the tabs and 182spaces have been munged in your input file. 183Any sequence of whitespace in the pattern line will match any sequence 184in the input file. 185Normal characters must still match exactly. 186Each line of the context must still match a line in the input file. --- 53 unchanged lines hidden (view full) --- 240Whatever you end up with is looked for either in the current directory, 241or the directory specified by the 242.Fl d 243option. 244.It Fl R , Fl Fl reverse 245Tells 246.Nm 247that this patch was created with the old and new files swapped. | 179This option may be specified multiple times. 180.It Fl l , Fl Fl ignore-whitespace 181Causes the pattern matching to be done loosely, in case the tabs and 182spaces have been munged in your input file. 183Any sequence of whitespace in the pattern line will match any sequence 184in the input file. 185Normal characters must still match exactly. 186Each line of the context must still match a line in the input file. --- 53 unchanged lines hidden (view full) --- 240Whatever you end up with is looked for either in the current directory, 241or the directory specified by the 242.Fl d 243option. 244.It Fl R , Fl Fl reverse 245Tells 246.Nm 247that this patch was created with the old and new files swapped. |
248(Yes, I'm afraid that does happen occasionally, human nature being what it | 248(Yes, I am afraid that does happen occasionally, human nature being what it |
249is.) 250.Nm 251will attempt to swap each hunk around before applying it. 252Rejects will come out in the swapped format. 253The 254.Fl R 255option will not work with ed diff scripts because there is too little 256information to reconstruct the reverse operation. 257.Pp 258If the first hunk of a patch fails, 259.Nm 260will reverse the hunk to see if it can be applied that way. 261If it can, you will be asked if you want to have the 262.Fl R 263option set. 264If it cannot, the patch will continue to be applied normally. 265(Note: this method cannot detect a reversed patch if it is a normal diff | 249is.) 250.Nm 251will attempt to swap each hunk around before applying it. 252Rejects will come out in the swapped format. 253The 254.Fl R 255option will not work with ed diff scripts because there is too little 256information to reconstruct the reverse operation. 257.Pp 258If the first hunk of a patch fails, 259.Nm 260will reverse the hunk to see if it can be applied that way. 261If it can, you will be asked if you want to have the 262.Fl R 263option set. 264If it cannot, the patch will continue to be applied normally. 265(Note: this method cannot detect a reversed patch if it is a normal diff |
266and if the first command is an append (i.e. it should have been a delete) | 266and if the first command is an append (i.e., it should have been a delete) |
267since appends always succeed, due to the fact that a null context will match 268anywhere. 269Luckily, most patches add or change lines rather than delete them, so most 270reversed normal diffs will begin with a delete, which will fail, triggering 271the heuristic.) 272.It Xo 273.Fl r Ar rej-name , 274.Fl Fl reject-file Ar rej-name --- 107 unchanged lines hidden (view full) --- 382minus any offset used in applying the previous hunk. 383If that is not the correct place, 384.Nm 385will scan both forwards and backwards for a set of lines matching the context 386given in the hunk. 387First 388.Nm 389looks for a place where all lines of the context match. | 267since appends always succeed, due to the fact that a null context will match 268anywhere. 269Luckily, most patches add or change lines rather than delete them, so most 270reversed normal diffs will begin with a delete, which will fail, triggering 271the heuristic.) 272.It Xo 273.Fl r Ar rej-name , 274.Fl Fl reject-file Ar rej-name --- 107 unchanged lines hidden (view full) --- 382minus any offset used in applying the previous hunk. 383If that is not the correct place, 384.Nm 385will scan both forwards and backwards for a set of lines matching the context 386given in the hunk. 387First 388.Nm 389looks for a place where all lines of the context match. |
390If no such place is found, and it's a context diff, and the maximum fuzz factor | 390If no such place is found, and it is a context diff, and the maximum fuzz factor |
391is set to 1 or more, then another scan takes place ignoring the first and last 392line of context. 393If that fails, and the maximum fuzz factor is set to 2 or more, 394the first two and last two lines of context are ignored, 395and another scan is made. 396.Pq The default maximum fuzz factor is 2. 397.Pp 398If --- 79 unchanged lines hidden (view full) --- 478.Dq old 479and 480.Dq new 481file names or, for a non-context diff, the 482.Dq index 483file name, and choose the file name with the fewest path components, 484the shortest basename, and the shortest total file name length (in that order). 485.It | 391is set to 1 or more, then another scan takes place ignoring the first and last 392line of context. 393If that fails, and the maximum fuzz factor is set to 2 or more, 394the first two and last two lines of context are ignored, 395and another scan is made. 396.Pq The default maximum fuzz factor is 2. 397.Pp 398If --- 79 unchanged lines hidden (view full) --- 478.Dq old 479and 480.Dq new 481file names or, for a non-context diff, the 482.Dq index 483file name, and choose the file name with the fewest path components, 484the shortest basename, and the shortest total file name length (in that order). 485.It |
486If no file exists, 487.Nm 488checks for the existence of the files in an SCCS or RCS directory 489(using the appropriate prefix or suffix) using the criteria specified 490above. 491If found, 492.Nm 493will attempt to get or check out the file. 494.It | |
495If no suitable file was found to patch, the patch file is a context or 496unified diff, and the old file was zero length, the new file name is 497created and used. 498.It 499If the file name still cannot be determined, 500.Nm 501will prompt the user for the file name to use. 502.El --- 197 unchanged lines hidden --- | 486If no suitable file was found to patch, the patch file is a context or 487unified diff, and the old file was zero length, the new file name is 488created and used. 489.It 490If the file name still cannot be determined, 491.Nm 492will prompt the user for the file name to use. 493.El --- 197 unchanged lines hidden --- |