[3444] | 1 | .\" patch man page
|
---|
| 2 | .de Id
|
---|
| 3 | .ds Dt \\$4
|
---|
| 4 | ..
|
---|
| 5 | .Id $Id: patch.man,v 1.31 2002/05/25 10:36:44 eggert Exp $
|
---|
| 6 | .ds = \-\^\-
|
---|
| 7 | .de Sp
|
---|
| 8 | .if t .sp .3
|
---|
| 9 | .if n .sp
|
---|
| 10 | ..
|
---|
| 11 | .TH PATCH 1 \*(Dt GNU
|
---|
| 12 | .ta 3n
|
---|
| 13 | .SH NAME
|
---|
| 14 | patch \- apply a diff file to an original
|
---|
| 15 | .SH SYNOPSIS
|
---|
| 16 | .B patch
|
---|
| 17 | .RI [ options ]
|
---|
| 18 | .RI [ originalfile
|
---|
| 19 | .RI [ patchfile ]]
|
---|
| 20 | .Sp
|
---|
| 21 | but usually just
|
---|
| 22 | .Sp
|
---|
| 23 | .BI "patch \-p" "num"
|
---|
| 24 | .BI < patchfile
|
---|
| 25 | .SH DESCRIPTION
|
---|
| 26 | .B patch
|
---|
| 27 | takes a patch file
|
---|
| 28 | .I patchfile
|
---|
| 29 | containing a difference listing produced by the
|
---|
| 30 | .B diff
|
---|
| 31 | program and applies those differences to one or more original files,
|
---|
| 32 | producing patched versions.
|
---|
| 33 | Normally the patched versions are put in place of the originals.
|
---|
| 34 | Backups can be made; see the
|
---|
| 35 | .B \-b
|
---|
| 36 | or
|
---|
| 37 | .B \*=backup
|
---|
| 38 | option.
|
---|
| 39 | The names of the files to be patched are usually taken from the patch file,
|
---|
| 40 | but if there's just one file to be patched it can specified on the
|
---|
| 41 | command line as
|
---|
| 42 | .IR originalfile .
|
---|
| 43 | .PP
|
---|
| 44 | Upon startup, patch attempts to determine the type of the diff listing,
|
---|
| 45 | unless overruled by a
|
---|
| 46 | \fB\-c\fP (\fB\*=context\fP),
|
---|
| 47 | \fB\-e\fP (\fB\*=ed\fP),
|
---|
| 48 | \fB\-n\fP (\fB\*=normal\fP),
|
---|
| 49 | or
|
---|
| 50 | \fB\-u\fP (\fB\*=unified\fP)
|
---|
| 51 | option.
|
---|
| 52 | Context diffs (old-style, new-style, and unified) and
|
---|
| 53 | normal diffs are applied by the
|
---|
| 54 | .B patch
|
---|
| 55 | program itself, while
|
---|
| 56 | .B ed
|
---|
| 57 | diffs are simply fed to the
|
---|
| 58 | .BR ed (1)
|
---|
| 59 | editor via a pipe.
|
---|
| 60 | .PP
|
---|
| 61 | .B patch
|
---|
| 62 | tries to skip any leading garbage, apply the diff,
|
---|
| 63 | and then skip any trailing garbage.
|
---|
| 64 | Thus you could feed an article or message containing a
|
---|
| 65 | diff listing to
|
---|
| 66 | .BR patch ,
|
---|
| 67 | and it should work.
|
---|
| 68 | If the entire diff is indented by a consistent amount,
|
---|
| 69 | or if a context diff contains lines ending in \s-1CRLF\s0
|
---|
| 70 | or is encapsulated one or more times by prepending
|
---|
| 71 | "\fB\- \fP" to lines starting with "\fB\-\fP" as specified by Internet RFC 934,
|
---|
| 72 | this is taken into account.
|
---|
| 73 | After removing indenting or encapsulation,
|
---|
| 74 | lines beginning with
|
---|
| 75 | .B #
|
---|
| 76 | are ignored, as they are considered to be comments.
|
---|
| 77 | .PP
|
---|
| 78 | With context diffs, and to a lesser extent with normal diffs,
|
---|
| 79 | .B patch
|
---|
| 80 | can detect when the line numbers mentioned in the patch are incorrect,
|
---|
| 81 | and attempts to find the correct place to apply each hunk of the patch.
|
---|
| 82 | As a first guess, it takes the line number mentioned for the hunk, plus or
|
---|
| 83 | minus any offset used in applying the previous hunk.
|
---|
| 84 | If that is not the correct place,
|
---|
| 85 | .B patch
|
---|
| 86 | scans both forwards and backwards for a set of lines matching the context
|
---|
| 87 | given in the hunk.
|
---|
| 88 | First
|
---|
| 89 | .B patch
|
---|
| 90 | looks for a place where all lines of the context match.
|
---|
| 91 | If no such place is found, and it's a context diff, and the maximum fuzz factor
|
---|
| 92 | is set to 1 or more, then another scan takes place ignoring the first and last
|
---|
| 93 | line of context.
|
---|
| 94 | If that fails, and the maximum fuzz factor is set to 2 or more,
|
---|
| 95 | the first two and last two lines of context are ignored,
|
---|
| 96 | and another scan is made.
|
---|
| 97 | (The default maximum fuzz factor is 2.)
|
---|
| 98 | If
|
---|
| 99 | .B patch
|
---|
| 100 | cannot find a place to install that hunk of the patch, it puts the
|
---|
| 101 | hunk out to a reject file, which normally is the name of the output file
|
---|
| 102 | plus a
|
---|
| 103 | .B \&.rej
|
---|
| 104 | suffix, or
|
---|
| 105 | .B #
|
---|
| 106 | if
|
---|
| 107 | .B \&.rej
|
---|
| 108 | would generate a file name that is too long
|
---|
| 109 | (if even appending the single character
|
---|
| 110 | .B #
|
---|
| 111 | makes the file name too long, then
|
---|
| 112 | .B #
|
---|
| 113 | replaces the file name's last character).
|
---|
| 114 | (The rejected hunk comes out in ordinary context diff form regardless of
|
---|
| 115 | the input patch's form.
|
---|
| 116 | If the input was a normal diff, many of the contexts are simply null.)
|
---|
| 117 | The line numbers on the hunks in the reject file may be different than
|
---|
| 118 | in the patch file: they reflect the approximate location patch thinks the
|
---|
| 119 | failed hunks belong in the new file rather than the old one.
|
---|
| 120 | .PP
|
---|
| 121 | As each hunk is completed, you are told if the hunk
|
---|
| 122 | failed, and if so which line (in the new file)
|
---|
| 123 | .B patch
|
---|
| 124 | thought the hunk should go on.
|
---|
| 125 | If the hunk is installed at a different line
|
---|
| 126 | from the line number specified in the diff you
|
---|
| 127 | are told the offset.
|
---|
| 128 | A single large offset
|
---|
| 129 | .I may
|
---|
| 130 | indicate that a hunk was installed in the
|
---|
| 131 | wrong place.
|
---|
| 132 | You are also told if a fuzz factor was used to make the match, in which
|
---|
| 133 | case you should also be slightly suspicious.
|
---|
| 134 | If the
|
---|
| 135 | .B \*=verbose
|
---|
| 136 | option is given, you are also told about hunks that match exactly.
|
---|
| 137 | .PP
|
---|
| 138 | If no original file
|
---|
| 139 | .I origfile
|
---|
| 140 | is specified on the command line,
|
---|
| 141 | .B patch
|
---|
| 142 | tries to figure out from the leading garbage what the name of the file
|
---|
| 143 | to edit is, using the following rules.
|
---|
| 144 | .LP
|
---|
| 145 | First,
|
---|
| 146 | .B patch
|
---|
| 147 | takes an ordered list of candidate file names as follows:
|
---|
| 148 | .TP 3
|
---|
| 149 | .B " \(bu"
|
---|
| 150 | If the header is that of a context diff,
|
---|
| 151 | .B patch
|
---|
| 152 | takes the old and new file names in the header.
|
---|
| 153 | A name is ignored if it does not have enough slashes to satisfy the
|
---|
| 154 | .BI \-p num
|
---|
| 155 | or
|
---|
| 156 | .BI \*=strip= num
|
---|
| 157 | option.
|
---|
| 158 | The name
|
---|
| 159 | .B /dev/null
|
---|
| 160 | is also ignored.
|
---|
| 161 | .TP
|
---|
| 162 | .B " \(bu"
|
---|
| 163 | If there is an
|
---|
| 164 | .B Index:\&
|
---|
| 165 | line in the leading garbage
|
---|
| 166 | and if either the old and new names are both absent or if
|
---|
| 167 | .B patch
|
---|
| 168 | is conforming to \s-1POSIX\s0,
|
---|
| 169 | .B patch
|
---|
| 170 | takes the name in the
|
---|
| 171 | .B Index:\&
|
---|
| 172 | line.
|
---|
| 173 | .TP
|
---|
| 174 | .B " \(bu"
|
---|
| 175 | For the purpose of the following rules,
|
---|
| 176 | the candidate file names are considered to be in the order (old, new, index),
|
---|
| 177 | regardless of the order that they appear in the header.
|
---|
| 178 | .LP
|
---|
| 179 | Then
|
---|
| 180 | .B patch
|
---|
| 181 | selects a file name from the candidate list as follows:
|
---|
| 182 | .TP 3
|
---|
| 183 | .B " \(bu"
|
---|
| 184 | If some of the named files exist,
|
---|
| 185 | .B patch
|
---|
| 186 | selects the first name if conforming to \s-1POSIX\s0,
|
---|
| 187 | and the best name otherwise.
|
---|
| 188 | .TP
|
---|
| 189 | .B " \(bu"
|
---|
| 190 | If
|
---|
| 191 | .B patch
|
---|
| 192 | is not ignoring \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0 (see the
|
---|
| 193 | .BI "\-g\ " num
|
---|
| 194 | or
|
---|
| 195 | .BI \*=get= num
|
---|
| 196 | option), and no named files exist
|
---|
| 197 | but an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master is found,
|
---|
| 198 | .B patch
|
---|
| 199 | selects the first named file
|
---|
| 200 | with an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master.
|
---|
| 201 | .TP
|
---|
| 202 | .B " \(bu"
|
---|
| 203 | If no named files exist,
|
---|
| 204 | no \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master was found,
|
---|
| 205 | some names are given,
|
---|
| 206 | .B patch
|
---|
| 207 | is not conforming to \s-1POSIX\s0,
|
---|
| 208 | and the patch appears to create a file,
|
---|
| 209 | .B patch
|
---|
| 210 | selects the best name requiring the creation of the fewest directories.
|
---|
| 211 | .TP
|
---|
| 212 | .B " \(bu"
|
---|
| 213 | If no file name results from the above heuristics, you are asked
|
---|
| 214 | for the name of the file to patch, and
|
---|
| 215 | .B patch
|
---|
| 216 | selects that name.
|
---|
| 217 | .LP
|
---|
| 218 | To determine the
|
---|
| 219 | .I best
|
---|
| 220 | of a nonempty list of file names,
|
---|
| 221 | .B patch
|
---|
| 222 | first takes all the names with the fewest path name components;
|
---|
| 223 | of those, it then takes all the names with the shortest basename;
|
---|
| 224 | of those, it then takes all the shortest names;
|
---|
| 225 | finally, it takes the first remaining name.
|
---|
| 226 | .PP
|
---|
| 227 | Additionally, if the leading garbage contains a
|
---|
| 228 | .B Prereq:\&
|
---|
| 229 | line,
|
---|
| 230 | .B patch
|
---|
| 231 | takes the first word from the prerequisites line (normally a version
|
---|
| 232 | number) and checks the original file to see if that word can be found.
|
---|
| 233 | If not,
|
---|
| 234 | .B patch
|
---|
| 235 | asks for confirmation before proceeding.
|
---|
| 236 | .PP
|
---|
| 237 | The upshot of all this is that you should be able to say, while in a news
|
---|
| 238 | interface, something like the following:
|
---|
| 239 | .Sp
|
---|
| 240 | \fB| patch \-d /usr/src/local/blurfl\fP
|
---|
| 241 | .Sp
|
---|
| 242 | and patch a file in the
|
---|
| 243 | .B blurfl
|
---|
| 244 | directory directly from the article containing
|
---|
| 245 | the patch.
|
---|
| 246 | .PP
|
---|
| 247 | If the patch file contains more than one patch,
|
---|
| 248 | .B patch
|
---|
| 249 | tries to apply each of them as if they came from separate patch files.
|
---|
| 250 | This means, among other things, that it is assumed that the name of the file
|
---|
| 251 | to patch must be determined for each diff listing,
|
---|
| 252 | and that the garbage before each diff listing
|
---|
| 253 | contains interesting things such as file names and revision level, as
|
---|
| 254 | mentioned previously.
|
---|
| 255 | .SH OPTIONS
|
---|
| 256 | .TP 3
|
---|
| 257 | \fB\-b\fP or \fB\*=backup\fP
|
---|
| 258 | Make backup files.
|
---|
| 259 | That is, when patching a file,
|
---|
| 260 | rename or copy the original instead of removing it.
|
---|
| 261 | When backing up a file that does not exist,
|
---|
| 262 | an empty, unreadable backup file is created
|
---|
| 263 | as a placeholder to represent the nonexistent file.
|
---|
| 264 | See the
|
---|
| 265 | .B \-V
|
---|
| 266 | or
|
---|
| 267 | .B \*=version\-control
|
---|
| 268 | option for details about how backup file names are determined.
|
---|
| 269 | .TP
|
---|
| 270 | .B \*=backup\-if\-mismatch
|
---|
| 271 | Back up a file if the patch does not match the file exactly
|
---|
| 272 | and if backups are not otherwise requested.
|
---|
| 273 | This is the default unless
|
---|
| 274 | .B patch
|
---|
| 275 | is conforming to \s-1POSIX\s0.
|
---|
| 276 | .TP
|
---|
| 277 | .B \*=no\-backup\-if\-mismatch
|
---|
| 278 | Do not back up a file if the patch does not match the file exactly
|
---|
| 279 | and if backups are not otherwise requested.
|
---|
| 280 | This is the default if
|
---|
| 281 | .B patch
|
---|
| 282 | is conforming to \s-1POSIX\s0.
|
---|
| 283 | .TP
|
---|
| 284 | \fB\-B\fP \fIpref\fP or \fB\*=prefix=\fP\fIpref\fP
|
---|
| 285 | Prefix
|
---|
| 286 | .I pref
|
---|
| 287 | to a file name when generating its simple backup file name.
|
---|
| 288 | For example, with
|
---|
| 289 | .B "\-B\ /junk/"
|
---|
| 290 | the simple backup file name for
|
---|
| 291 | .B src/patch/util.c
|
---|
| 292 | is
|
---|
| 293 | .BR /junk/src/patch/util.c .
|
---|
| 294 | .TP
|
---|
| 295 | \fB\*=binary\fP
|
---|
| 296 | Read and write all files in binary mode,
|
---|
| 297 | except for standard output and
|
---|
| 298 | .BR /dev/tty .
|
---|
| 299 | This option has no effect on \s-1POSIX\s0-conforming systems.
|
---|
| 300 | On systems like \s-1DOS\s0 where this option makes a difference,
|
---|
| 301 | the patch should be generated by
|
---|
| 302 | .BR "diff\ \-a\ \*=binary" .
|
---|
| 303 | .TP
|
---|
| 304 | \fB\-c\fP or \fB\*=context\fP
|
---|
| 305 | Interpret the patch file as a ordinary context diff.
|
---|
| 306 | .TP
|
---|
| 307 | \fB\-d\fP \fIdir\fP or \fB\*=directory=\fP\fIdir\fP
|
---|
| 308 | Change to the directory
|
---|
| 309 | .I dir
|
---|
| 310 | immediately, before doing
|
---|
| 311 | anything else.
|
---|
| 312 | .TP
|
---|
| 313 | \fB\-D\fP \fIdefine\fP or \fB\*=ifdef=\fP\fIdefine\fP
|
---|
| 314 | Use the
|
---|
| 315 | .BR #ifdef " .\|.\|. " #endif
|
---|
| 316 | construct to mark changes, with
|
---|
| 317 | .I define
|
---|
| 318 | as the differentiating symbol.
|
---|
| 319 | .TP
|
---|
| 320 | .B "\*=dry\-run"
|
---|
| 321 | Print the results of applying the patches without actually changing any files.
|
---|
| 322 | .TP
|
---|
| 323 | \fB\-e\fP or \fB\*=ed\fP
|
---|
| 324 | Interpret the patch file as an
|
---|
| 325 | .B ed
|
---|
| 326 | script.
|
---|
| 327 | .TP
|
---|
| 328 | \fB\-E\fP or \fB\*=remove\-empty\-files\fP
|
---|
| 329 | Remove output files that are empty after the patches have been applied.
|
---|
| 330 | Normally this option is unnecessary, since
|
---|
| 331 | .B patch
|
---|
| 332 | can examine the time stamps on the header to determine whether a file
|
---|
| 333 | should exist after patching.
|
---|
| 334 | However, if the input is not a context diff or if
|
---|
| 335 | .B patch
|
---|
| 336 | is conforming to \s-1POSIX\s0,
|
---|
| 337 | .B patch
|
---|
| 338 | does not remove empty patched files unless this option is given.
|
---|
| 339 | When
|
---|
| 340 | .B patch
|
---|
| 341 | removes a file, it also attempts to remove any empty ancestor directories.
|
---|
| 342 | .TP
|
---|
| 343 | \fB\-f\fP or \fB\*=force\fP
|
---|
| 344 | Assume that the user knows exactly what he or she is doing, and do not
|
---|
| 345 | ask any questions. Skip patches whose headers
|
---|
| 346 | do not say which file is to be patched; patch files even though they have the
|
---|
| 347 | wrong version for the
|
---|
| 348 | .B Prereq:\&
|
---|
| 349 | line in the patch; and assume that
|
---|
| 350 | patches are not reversed even if they look like they are.
|
---|
| 351 | This option does not suppress commentary; use
|
---|
| 352 | .B \-s
|
---|
| 353 | for that.
|
---|
| 354 | .TP
|
---|
| 355 | \fB\-F\fP \fInum\fP or \fB\*=fuzz=\fP\fInum\fP
|
---|
| 356 | Set the maximum fuzz factor.
|
---|
| 357 | This option only applies to diffs that have context, and causes
|
---|
| 358 | .B patch
|
---|
| 359 | to ignore up to that many lines in looking for places to install a hunk.
|
---|
| 360 | Note that a larger fuzz factor increases the odds of a faulty patch.
|
---|
| 361 | The default fuzz factor is 2, and it may not be set to more than
|
---|
| 362 | the number of lines of context in the context diff, ordinarily 3.
|
---|
| 363 | .TP
|
---|
| 364 | \fB\-g\fP \fInum\fP or \fB\*=get=\fP\fInum\fP
|
---|
| 365 | This option controls
|
---|
| 366 | .BR patch 's
|
---|
| 367 | actions when a file is under \s-1RCS\s0 or \s-1SCCS\s0 control,
|
---|
| 368 | and does not exist or is read-only and matches the default version,
|
---|
| 369 | or when a file is under ClearCase or Perforce control and does not exist.
|
---|
| 370 | If
|
---|
| 371 | .I num
|
---|
| 372 | is positive,
|
---|
| 373 | .B patch
|
---|
| 374 | gets (or checks out) the file from the revision control system; if zero,
|
---|
| 375 | .B patch
|
---|
| 376 | ignores \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0
|
---|
| 377 | and does not get the file; and if negative,
|
---|
| 378 | .B patch
|
---|
| 379 | asks the user whether to get the file.
|
---|
| 380 | The default value of this option is given by the value of the
|
---|
| 381 | .B PATCH_GET
|
---|
| 382 | environment variable if it is set; if not, the default value is zero if
|
---|
| 383 | .B patch
|
---|
| 384 | is conforming to \s-1POSIX\s0, negative otherwise.
|
---|
| 385 | .TP
|
---|
| 386 | .B "\*=help"
|
---|
| 387 | Print a summary of options and exit.
|
---|
| 388 | .TP
|
---|
| 389 | \fB\-i\fP \fIpatchfile\fP or \fB\*=input=\fP\fIpatchfile\fP
|
---|
| 390 | Read the patch from
|
---|
| 391 | .IR patchfile .
|
---|
| 392 | If
|
---|
| 393 | .I patchfile
|
---|
| 394 | is
|
---|
| 395 | .BR \- ,
|
---|
| 396 | read from standard input, the default.
|
---|
| 397 | .TP
|
---|
| 398 | \fB\-l\fP or \fB\*=ignore\-whitespace\fP
|
---|
| 399 | Match patterns loosely, in case tabs or spaces
|
---|
| 400 | have been munged in your files.
|
---|
| 401 | Any sequence of one or more blanks in the patch file matches any sequence
|
---|
| 402 | in the original file, and sequences of blanks at the ends of lines are ignored.
|
---|
| 403 | Normal characters must still match exactly.
|
---|
| 404 | Each line of the context must still match a line in the original file.
|
---|
| 405 | .TP
|
---|
| 406 | \fB\-n\fP or \fB\*=normal\fP
|
---|
| 407 | Interpret the patch file as a normal diff.
|
---|
| 408 | .TP
|
---|
| 409 | \fB\-N\fP or \fB\*=forward\fP
|
---|
| 410 | Ignore patches that seem to be reversed or already applied.
|
---|
| 411 | See also
|
---|
| 412 | .BR \-R .
|
---|
| 413 | .TP
|
---|
| 414 | \fB\-o\fP \fIoutfile\fP or \fB\*=output=\fP\fIoutfile\fP
|
---|
| 415 | Send output to
|
---|
| 416 | .I outfile
|
---|
| 417 | instead of patching files in place.
|
---|
| 418 | Do not use this option if
|
---|
| 419 | .I outfile
|
---|
| 420 | is one of the files to be patched.
|
---|
| 421 | .TP
|
---|
| 422 | \fB\-p\fP\fInum\fP or \fB\*=strip\fP\fB=\fP\fInum\fP
|
---|
| 423 | Strip the smallest prefix containing
|
---|
| 424 | .I num
|
---|
| 425 | leading slashes from each file name found in the patch file.
|
---|
| 426 | A sequence of one or more adjacent slashes is counted as a single slash.
|
---|
| 427 | This controls how file names found in the patch file are treated, in case
|
---|
| 428 | you keep your files in a different directory than the person who sent
|
---|
| 429 | out the patch.
|
---|
| 430 | For example, supposing the file name in the patch file was
|
---|
| 431 | .Sp
|
---|
| 432 | \fB/u/howard/src/blurfl/blurfl.c\fP
|
---|
| 433 | .Sp
|
---|
| 434 | setting
|
---|
| 435 | .B \-p0
|
---|
| 436 | gives the entire file name unmodified,
|
---|
| 437 | .B \-p1
|
---|
| 438 | gives
|
---|
| 439 | .Sp
|
---|
| 440 | \fBu/howard/src/blurfl/blurfl.c\fP
|
---|
| 441 | .Sp
|
---|
| 442 | without the leading slash,
|
---|
| 443 | .B \-p4
|
---|
| 444 | gives
|
---|
| 445 | .Sp
|
---|
| 446 | \fBblurfl/blurfl.c\fP
|
---|
| 447 | .Sp
|
---|
| 448 | and not specifying
|
---|
| 449 | .B \-p
|
---|
| 450 | at all just gives you \fBblurfl.c\fP.
|
---|
| 451 | Whatever you end up with is looked for either in the current directory,
|
---|
| 452 | or the directory specified by the
|
---|
| 453 | .B \-d
|
---|
| 454 | option.
|
---|
| 455 | .TP
|
---|
| 456 | .B \*=posix
|
---|
| 457 | Conform more strictly to the \s-1POSIX\s0 standard, as follows.
|
---|
| 458 | .RS
|
---|
| 459 | .TP 3
|
---|
| 460 | .B " \(bu"
|
---|
| 461 | Take the first existing file from the list (old, new, index)
|
---|
| 462 | when intuiting file names from diff headers.
|
---|
| 463 | .TP
|
---|
| 464 | .B " \(bu"
|
---|
| 465 | Do not remove files that are empty after patching.
|
---|
| 466 | .TP
|
---|
| 467 | .B " \(bu"
|
---|
| 468 | Do not ask whether to get files from \s-1RCS\s0, ClearCase, Perforce,
|
---|
| 469 | or \s-1SCCS\s0.
|
---|
| 470 | .TP
|
---|
| 471 | .B " \(bu"
|
---|
| 472 | Require that all options precede the files in the command line.
|
---|
| 473 | .TP
|
---|
| 474 | .B " \(bu"
|
---|
| 475 | Do not backup files when there is a mismatch.
|
---|
| 476 | .RE
|
---|
| 477 | .TP
|
---|
| 478 | .BI \*=quoting\-style= word
|
---|
| 479 | Use style
|
---|
| 480 | .I word
|
---|
| 481 | to quote output names.
|
---|
| 482 | The
|
---|
| 483 | .I word
|
---|
| 484 | should be one of the following:
|
---|
| 485 | .RS
|
---|
| 486 | .TP
|
---|
| 487 | .B literal
|
---|
| 488 | Output names as-is.
|
---|
| 489 | .TP
|
---|
| 490 | .B shell
|
---|
| 491 | Quote names for the shell if they contain shell metacharacters or would
|
---|
| 492 | cause ambiguous output.
|
---|
| 493 | .TP
|
---|
| 494 | .B shell-always
|
---|
| 495 | Quote names for the shell, even if they would normally not require quoting.
|
---|
| 496 | .TP
|
---|
| 497 | .B c
|
---|
| 498 | Quote names as for a C language string.
|
---|
| 499 | .TP
|
---|
| 500 | .B escape
|
---|
| 501 | Quote as with
|
---|
| 502 | .B c
|
---|
| 503 | except omit the surrounding double-quote characters.
|
---|
| 504 | .LP
|
---|
| 505 | You can specify the default value of the
|
---|
| 506 | .B \*=quoting\-style
|
---|
| 507 | option with the environment variable
|
---|
| 508 | .BR QUOTING_STYLE .
|
---|
| 509 | If that environment variable is not set, the default value is
|
---|
| 510 | .BR shell .
|
---|
| 511 | .RE
|
---|
| 512 | .TP
|
---|
| 513 | \fB\-r\fP \fIrejectfile\fP or \fB\*=reject\-file=\fP\fIrejectfile\fP
|
---|
| 514 | Put rejects into
|
---|
| 515 | .I rejectfile
|
---|
| 516 | instead of the default
|
---|
| 517 | .B \&.rej
|
---|
| 518 | file.
|
---|
| 519 | .TP
|
---|
| 520 | \fB\-R\fP or \fB\*=reverse\fP
|
---|
| 521 | Assume that this patch was created with the old and new files swapped.
|
---|
| 522 | (Yes, I'm afraid that does happen occasionally, human nature being what it
|
---|
| 523 | is.)
|
---|
| 524 | .B patch
|
---|
| 525 | attempts to swap each hunk around before applying it.
|
---|
| 526 | Rejects come out in the swapped format.
|
---|
| 527 | The
|
---|
| 528 | .B \-R
|
---|
| 529 | option does not work with
|
---|
| 530 | .B ed
|
---|
| 531 | diff scripts because there is too little
|
---|
| 532 | information to reconstruct the reverse operation.
|
---|
| 533 | .Sp
|
---|
| 534 | If the first hunk of a patch fails,
|
---|
| 535 | .B patch
|
---|
| 536 | reverses the hunk to see if it can be applied that way.
|
---|
| 537 | If it can, you are asked if you want to have the
|
---|
| 538 | .B \-R
|
---|
| 539 | option set.
|
---|
| 540 | If it can't, the patch continues to be applied normally.
|
---|
| 541 | (Note: this method cannot detect a reversed patch if it is a normal diff
|
---|
| 542 | and if the first command is an append (i.e. it should have been a delete)
|
---|
| 543 | since appends always succeed, due to the fact that a null context matches
|
---|
| 544 | anywhere.
|
---|
| 545 | Luckily, most patches add or change lines rather than delete them, so most
|
---|
| 546 | reversed normal diffs begin with a delete, which fails, triggering
|
---|
| 547 | the heuristic.)
|
---|
| 548 | .TP
|
---|
| 549 | \fB\-s\fP or \fB\*=silent\fP or \fB\*=quiet\fP
|
---|
| 550 | Work silently, unless an error occurs.
|
---|
| 551 | .TP
|
---|
| 552 | \fB\-t\fP or \fB\*=batch\fP
|
---|
| 553 | Suppress questions like
|
---|
| 554 | .BR \-f ,
|
---|
| 555 | but make some different assumptions:
|
---|
| 556 | skip patches whose headers do not contain file names (the same as \fB\-f\fP);
|
---|
| 557 | skip patches for which the file has the wrong version for the
|
---|
| 558 | .B Prereq:\&
|
---|
| 559 | line
|
---|
| 560 | in the patch; and assume that patches are reversed if they look like
|
---|
| 561 | they are.
|
---|
| 562 | .TP
|
---|
| 563 | \fB\-T\fP or \fB\*=set\-time\fP
|
---|
| 564 | Set the modification and access times of patched files from time stamps
|
---|
| 565 | given in context diff headers, assuming that the context diff headers
|
---|
| 566 | use local time. This option is not recommended, because patches using
|
---|
| 567 | local time cannot easily be used by people in other time zones, and
|
---|
| 568 | because local time stamps are ambiguous when local clocks move backwards
|
---|
| 569 | during daylight-saving time adjustments. Instead of using this option,
|
---|
| 570 | generate patches with \s-1UTC\s0 and use the
|
---|
| 571 | .B \-Z
|
---|
| 572 | or
|
---|
| 573 | .B \*=set\-utc
|
---|
| 574 | option instead.
|
---|
| 575 | .TP
|
---|
| 576 | \fB\-u\fP or \fB\*=unified\fP
|
---|
| 577 | Interpret the patch file as a unified context diff.
|
---|
| 578 | .TP
|
---|
| 579 | \fB\-v\fP or \fB\*=version\fP
|
---|
| 580 | Print out
|
---|
| 581 | .BR patch 's
|
---|
| 582 | revision header and patch level, and exit.
|
---|
| 583 | .TP
|
---|
| 584 | \fB\-V\fP \fImethod\fP or \fB\*=version\-control=\fP\fImethod\fP
|
---|
| 585 | Use
|
---|
| 586 | .I method
|
---|
| 587 | to determine
|
---|
| 588 | backup file names. The method can also be given by the
|
---|
| 589 | .B PATCH_VERSION_CONTROL
|
---|
| 590 | (or, if that's not set, the
|
---|
| 591 | .BR VERSION_CONTROL )
|
---|
| 592 | environment variable, which is overridden by this option.
|
---|
| 593 | The method does not affect whether backup files are made;
|
---|
| 594 | it affects only the names of any backup files that are made.
|
---|
| 595 | .Sp
|
---|
| 596 | The value of
|
---|
| 597 | .I method
|
---|
| 598 | is like the \s-1GNU\s0
|
---|
| 599 | Emacs `version-control' variable;
|
---|
| 600 | .B patch
|
---|
| 601 | also recognizes synonyms that
|
---|
| 602 | are more descriptive. The valid values for
|
---|
| 603 | .I method
|
---|
| 604 | are (unique abbreviations are
|
---|
| 605 | accepted):
|
---|
| 606 | .RS
|
---|
| 607 | .TP 3
|
---|
| 608 | \fBexisting\fP or \fBnil\fP
|
---|
| 609 | Make numbered backups of files that already have them,
|
---|
| 610 | otherwise simple backups.
|
---|
| 611 | This is the default.
|
---|
| 612 | .TP
|
---|
| 613 | \fBnumbered\fP or \fBt\fP
|
---|
| 614 | Make numbered backups. The numbered backup file name for
|
---|
| 615 | .I F
|
---|
| 616 | is
|
---|
| 617 | .IB F .~ N ~
|
---|
| 618 | where
|
---|
| 619 | .I N
|
---|
| 620 | is the version number.
|
---|
| 621 | .TP
|
---|
| 622 | \fBsimple\fP or \fBnever\fP
|
---|
| 623 | Make simple backups.
|
---|
| 624 | The
|
---|
| 625 | .B \-B
|
---|
| 626 | or
|
---|
| 627 | .BR \*=prefix ,
|
---|
| 628 | .B \-Y
|
---|
| 629 | or
|
---|
| 630 | .BR \*=basename\-prefix ,
|
---|
| 631 | and
|
---|
| 632 | .B \-z
|
---|
| 633 | or
|
---|
| 634 | .BR \*=suffix
|
---|
| 635 | options specify the simple backup file name.
|
---|
| 636 | If none of these options are given, then a simple backup suffix is used;
|
---|
| 637 | it is the value of the
|
---|
| 638 | .B SIMPLE_BACKUP_SUFFIX
|
---|
| 639 | environment variable if set, and is
|
---|
| 640 | .B \&.orig
|
---|
| 641 | otherwise.
|
---|
| 642 | .PP
|
---|
| 643 | With numbered or simple backups,
|
---|
| 644 | if the backup file name is too long, the backup suffix
|
---|
| 645 | .B ~
|
---|
| 646 | is used instead; if even appending
|
---|
| 647 | .B ~
|
---|
| 648 | would make the name too long, then
|
---|
| 649 | .B ~
|
---|
| 650 | replaces the last character of the file name.
|
---|
| 651 | .RE
|
---|
| 652 | .TP
|
---|
| 653 | \fB\*=verbose\fP
|
---|
| 654 | Output extra information about the work being done.
|
---|
| 655 | .TP
|
---|
| 656 | \fB\-x\fP \fInum\fP or \fB\*=debug=\fP\fInum\fP
|
---|
| 657 | Set internal debugging flags of interest only to
|
---|
| 658 | .B patch
|
---|
| 659 | patchers.
|
---|
| 660 | .TP
|
---|
| 661 | \fB\-Y\fP \fIpref\fP or \fB\*=basename\-prefix=\fP\fIpref\fP
|
---|
| 662 | Prefix
|
---|
| 663 | .I pref
|
---|
| 664 | to the basename of a file name when generating its simple backup file name.
|
---|
| 665 | For example, with
|
---|
| 666 | .B "\-Y\ .del/"
|
---|
| 667 | the simple backup file name for
|
---|
| 668 | .B src/patch/util.c
|
---|
| 669 | is
|
---|
| 670 | .BR src/patch/.del/util.c .
|
---|
| 671 | .TP
|
---|
| 672 | \fB\-z\fP \fIsuffix\fP or \fB\*=suffix=\fP\fIsuffix\fP
|
---|
| 673 | Use
|
---|
| 674 | .I suffix
|
---|
| 675 | as the simple backup suffix.
|
---|
| 676 | For example, with
|
---|
| 677 | .B "\-z\ -"
|
---|
| 678 | the simple backup file name for
|
---|
| 679 | .B src/patch/util.c
|
---|
| 680 | is
|
---|
| 681 | .BR src/patch/util.c- .
|
---|
| 682 | The backup suffix may also be specified by the
|
---|
| 683 | .B SIMPLE_BACKUP_SUFFIX
|
---|
| 684 | environment variable, which is overridden by this option.
|
---|
| 685 | .TP
|
---|
| 686 | \fB\-Z\fP or \fB\*=set\-utc\fP
|
---|
| 687 | Set the modification and access times of patched files from time stamps
|
---|
| 688 | given in context diff headers, assuming that the context diff headers
|
---|
| 689 | use Coordinated Universal Time (\s-1UTC\s0, often known as \s-1GMT\s0).
|
---|
| 690 | Also see the
|
---|
| 691 | .B \-T
|
---|
| 692 | or
|
---|
| 693 | .B \*=set\-time
|
---|
| 694 | option.
|
---|
| 695 | .Sp
|
---|
| 696 | The
|
---|
| 697 | .B \-Z
|
---|
| 698 | or
|
---|
| 699 | .B \*=set\-utc
|
---|
| 700 | and
|
---|
| 701 | .B \-T
|
---|
| 702 | or
|
---|
| 703 | .B \*=set\-time
|
---|
| 704 | options normally refrain from setting a file's time if the file's original time
|
---|
| 705 | does not match the time given in the patch header, or if its
|
---|
| 706 | contents do not match the patch exactly. However, if the
|
---|
| 707 | .B \-f
|
---|
| 708 | or
|
---|
| 709 | .B \*=force
|
---|
| 710 | option is given, the file time is set regardless.
|
---|
| 711 | .Sp
|
---|
| 712 | Due to the limitations of
|
---|
| 713 | .B diff
|
---|
| 714 | output format, these options cannot update the times of files whose
|
---|
| 715 | contents have not changed. Also, if you use these options, you should remove
|
---|
| 716 | (e.g. with
|
---|
| 717 | .BR "make\ clean" )
|
---|
| 718 | all files that depend on the patched files, so that later invocations of
|
---|
| 719 | .B make
|
---|
| 720 | do not get confused by the patched files' times.
|
---|
| 721 | .SH ENVIRONMENT
|
---|
| 722 | .TP 3
|
---|
| 723 | .B PATCH_GET
|
---|
| 724 | This specifies whether
|
---|
| 725 | .B patch
|
---|
| 726 | gets missing or read-only files from \s-1RCS\s0, ClearCase, Perforce,
|
---|
| 727 | or \s-1SCCS\s0
|
---|
| 728 | by default; see the
|
---|
| 729 | .B \-g
|
---|
| 730 | or
|
---|
| 731 | .B \*=get
|
---|
| 732 | option.
|
---|
| 733 | .TP
|
---|
| 734 | .B POSIXLY_CORRECT
|
---|
| 735 | If set,
|
---|
| 736 | .B patch
|
---|
| 737 | conforms more strictly to the \s-1POSIX\s0 standard by default:
|
---|
| 738 | see the
|
---|
| 739 | .B \*=posix
|
---|
| 740 | option.
|
---|
| 741 | .TP
|
---|
| 742 | .B QUOTING_STYLE
|
---|
| 743 | Default value of the
|
---|
| 744 | .B \*=quoting\-style
|
---|
| 745 | option.
|
---|
| 746 | .TP
|
---|
| 747 | .B SIMPLE_BACKUP_SUFFIX
|
---|
| 748 | Extension to use for simple backup file names instead of
|
---|
| 749 | .BR \&.orig .
|
---|
| 750 | .TP
|
---|
| 751 | \fBTMPDIR\fP, \fBTMP\fP, \fBTEMP\fP
|
---|
| 752 | Directory to put temporary files in;
|
---|
| 753 | .B patch
|
---|
| 754 | uses the first environment variable in this list that is set.
|
---|
| 755 | If none are set, the default is system-dependent;
|
---|
| 756 | it is normally
|
---|
| 757 | .B /tmp
|
---|
| 758 | on Unix hosts.
|
---|
| 759 | .TP
|
---|
| 760 | \fBVERSION_CONTROL\fP or \fBPATCH_VERSION_CONTROL\fP
|
---|
| 761 | Selects version control style; see the
|
---|
| 762 | .B \-v
|
---|
| 763 | or
|
---|
| 764 | .B \*=version\-control
|
---|
| 765 | option.
|
---|
| 766 | .SH FILES
|
---|
| 767 | .TP 3
|
---|
| 768 | .IB $TMPDIR "/p\(**"
|
---|
| 769 | temporary files
|
---|
| 770 | .TP
|
---|
| 771 | .B /dev/tty
|
---|
| 772 | controlling terminal; used to get answers to questions asked of the user
|
---|
| 773 | .SH "SEE ALSO"
|
---|
| 774 | .BR diff (1),
|
---|
| 775 | .BR ed (1)
|
---|
| 776 | .Sp
|
---|
| 777 | Marshall T. Rose and Einar A. Stefferud,
|
---|
| 778 | Proposed Standard for Message Encapsulation,
|
---|
| 779 | Internet RFC 934 <URL:ftp://ftp.isi.edu/in-notes/rfc934.txt> (1985-01).
|
---|
| 780 | .SH "NOTES FOR PATCH SENDERS"
|
---|
| 781 | There are several things you should bear in mind if you are going to
|
---|
| 782 | be sending out patches.
|
---|
| 783 | .PP
|
---|
| 784 | Create your patch systematically.
|
---|
| 785 | A good method is the command
|
---|
| 786 | .BI "diff\ \-Naur\ " "old\ new"
|
---|
| 787 | where
|
---|
| 788 | .I old
|
---|
| 789 | and
|
---|
| 790 | .I new
|
---|
| 791 | identify the old and new directories.
|
---|
| 792 | The names
|
---|
| 793 | .I old
|
---|
| 794 | and
|
---|
| 795 | .I new
|
---|
| 796 | should not contain any slashes.
|
---|
| 797 | The
|
---|
| 798 | .B diff
|
---|
| 799 | command's headers should have dates
|
---|
| 800 | and times in Universal Time using traditional Unix format,
|
---|
| 801 | so that patch recipients can use the
|
---|
| 802 | .B \-Z
|
---|
| 803 | or
|
---|
| 804 | .B \*=set\-utc
|
---|
| 805 | option.
|
---|
| 806 | Here is an example command, using Bourne shell syntax:
|
---|
| 807 | .Sp
|
---|
| 808 | \fBLC_ALL=C TZ=UTC0 diff \-Naur gcc\-2.7 gcc\-2.8\fP
|
---|
| 809 | .PP
|
---|
| 810 | Tell your recipients how to apply the patch
|
---|
| 811 | by telling them which directory to
|
---|
| 812 | .B cd
|
---|
| 813 | to, and which
|
---|
| 814 | .B patch
|
---|
| 815 | options to use. The option string
|
---|
| 816 | .B "\-Np1"
|
---|
| 817 | is recommended.
|
---|
| 818 | Test your procedure by pretending to be a recipient and applying
|
---|
| 819 | your patch to a copy of the original files.
|
---|
| 820 | .PP
|
---|
| 821 | You can save people a lot of grief by keeping a
|
---|
| 822 | .B patchlevel.h
|
---|
| 823 | file which is patched to increment the patch level
|
---|
| 824 | as the first diff in the patch file you send out.
|
---|
| 825 | If you put a
|
---|
| 826 | .B Prereq:\&
|
---|
| 827 | line in with the patch, it won't let them apply
|
---|
| 828 | patches out of order without some warning.
|
---|
| 829 | .PP
|
---|
| 830 | You can create a file by sending out a diff that compares
|
---|
| 831 | .B /dev/null
|
---|
| 832 | or an empty file dated the Epoch (1970-01-01 00:00:00 \s-1UTC\s0)
|
---|
| 833 | to the file you want to create.
|
---|
| 834 | This only works if the file you want to create doesn't exist already in
|
---|
| 835 | the target directory.
|
---|
| 836 | Conversely, you can remove a file by sending out a context diff that compares
|
---|
| 837 | the file to be deleted with an empty file dated the Epoch.
|
---|
| 838 | The file will be removed unless
|
---|
| 839 | .B patch
|
---|
| 840 | is conforming to \s-1POSIX\s0 and the
|
---|
| 841 | .B \-E
|
---|
| 842 | or
|
---|
| 843 | .B \*=remove\-empty\-files
|
---|
| 844 | option is not given.
|
---|
| 845 | An easy way to generate patches that create and remove files
|
---|
| 846 | is to use \s-1GNU\s0
|
---|
| 847 | .BR diff 's
|
---|
| 848 | .B \-N
|
---|
| 849 | or
|
---|
| 850 | .B \*=new\-file
|
---|
| 851 | option.
|
---|
| 852 | .PP
|
---|
| 853 | If the recipient is supposed to use the
|
---|
| 854 | .BI \-p N
|
---|
| 855 | option, do not send output that looks like this:
|
---|
| 856 | .Sp
|
---|
| 857 | .ft B
|
---|
| 858 | .ne 3
|
---|
| 859 | diff \-Naur v2.0.29/prog/README prog/README
|
---|
| 860 | .br
|
---|
| 861 | \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
|
---|
| 862 | .br
|
---|
| 863 | +\^+\^+ prog/README Mon Mar 17 14:58:22 1997
|
---|
| 864 | .ft
|
---|
| 865 | .Sp
|
---|
| 866 | because the two file names have different numbers of slashes,
|
---|
| 867 | and different versions of
|
---|
| 868 | .B patch
|
---|
| 869 | interpret the file names differently.
|
---|
| 870 | To avoid confusion, send output that looks like this instead:
|
---|
| 871 | .Sp
|
---|
| 872 | .ft B
|
---|
| 873 | .ne 3
|
---|
| 874 | diff \-Naur v2.0.29/prog/README v2.0.30/prog/README
|
---|
| 875 | .br
|
---|
| 876 | \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
|
---|
| 877 | .br
|
---|
| 878 | +\^+\^+ v2.0.30/prog/README Mon Mar 17 14:58:22 1997
|
---|
| 879 | .ft
|
---|
| 880 | .Sp
|
---|
| 881 | .PP
|
---|
| 882 | Avoid sending patches that compare backup file names like
|
---|
| 883 | .BR README.orig ,
|
---|
| 884 | since this might confuse
|
---|
| 885 | .B patch
|
---|
| 886 | into patching a backup file instead of the real file.
|
---|
| 887 | Instead, send patches that compare the same base file names
|
---|
| 888 | in different directories, e.g.\&
|
---|
| 889 | .B old/README
|
---|
| 890 | and
|
---|
| 891 | .BR new/README .
|
---|
| 892 | .PP
|
---|
| 893 | Take care not to send out reversed patches, since it makes people wonder
|
---|
| 894 | whether they already applied the patch.
|
---|
| 895 | .PP
|
---|
| 896 | Try not to have your patch modify derived files
|
---|
| 897 | (e.g. the file
|
---|
| 898 | .B configure
|
---|
| 899 | where there is a line
|
---|
| 900 | .B "configure: configure.in"
|
---|
| 901 | in your makefile), since the recipient should be
|
---|
| 902 | able to regenerate the derived files anyway.
|
---|
| 903 | If you must send diffs of derived files,
|
---|
| 904 | generate the diffs using \s-1UTC\s0,
|
---|
| 905 | have the recipients apply the patch with the
|
---|
| 906 | .B \-Z
|
---|
| 907 | or
|
---|
| 908 | .B \*=set\-utc
|
---|
| 909 | option, and have them remove any unpatched files that depend on patched files
|
---|
| 910 | (e.g. with
|
---|
| 911 | .BR "make\ clean" ).
|
---|
| 912 | .PP
|
---|
| 913 | While you may be able to get away with putting 582 diff listings into
|
---|
| 914 | one file, it may be wiser to group related patches into separate files in
|
---|
| 915 | case something goes haywire.
|
---|
| 916 | .SH DIAGNOSTICS
|
---|
| 917 | Diagnostics generally indicate that
|
---|
| 918 | .B patch
|
---|
| 919 | couldn't parse your patch file.
|
---|
| 920 | .PP
|
---|
| 921 | If the
|
---|
| 922 | .B \*=verbose
|
---|
| 923 | option is given, the message
|
---|
| 924 | .B Hmm.\|.\|.\&
|
---|
| 925 | indicates that there is unprocessed text in
|
---|
| 926 | the patch file and that
|
---|
| 927 | .B patch
|
---|
| 928 | is attempting to intuit whether there is a patch in that text and, if so,
|
---|
| 929 | what kind of patch it is.
|
---|
| 930 | .PP
|
---|
| 931 | .BR patch 's
|
---|
| 932 | exit status is
|
---|
| 933 | 0 if all hunks are applied successfully,
|
---|
| 934 | 1 if some hunks cannot be applied,
|
---|
| 935 | and 2 if there is more serious trouble.
|
---|
| 936 | When applying a set of patches in a loop it behooves you to check this
|
---|
| 937 | exit status so you don't apply a later patch to a partially patched file.
|
---|
| 938 | .SH CAVEATS
|
---|
| 939 | Context diffs cannot reliably represent the creation or deletion of
|
---|
| 940 | empty files, empty directories, or special files such as symbolic links.
|
---|
| 941 | Nor can they represent changes to file metadata like ownership, permissions,
|
---|
| 942 | or whether one file is a hard link to another.
|
---|
| 943 | If changes like these are also required, separate instructions
|
---|
| 944 | (e.g. a shell script) to accomplish them should accompany the patch.
|
---|
| 945 | .PP
|
---|
| 946 | .B patch
|
---|
| 947 | cannot tell if the line numbers are off in an
|
---|
| 948 | .B ed
|
---|
| 949 | script, and can detect
|
---|
| 950 | bad line numbers in a normal diff only when it finds a change or deletion.
|
---|
| 951 | A context diff using fuzz factor 3 may have the same problem.
|
---|
| 952 | Until a suitable interactive interface is added, you should probably do
|
---|
| 953 | a context diff in these cases to see if the changes made sense.
|
---|
| 954 | Of course, compiling without errors is a pretty good indication that the patch
|
---|
| 955 | worked, but not always.
|
---|
| 956 | .PP
|
---|
| 957 | .B patch
|
---|
| 958 | usually produces the correct results, even when it has to do a lot of
|
---|
| 959 | guessing.
|
---|
| 960 | However, the results are guaranteed to be correct only when the patch is
|
---|
| 961 | applied to exactly the same version of the file that the patch was
|
---|
| 962 | generated from.
|
---|
| 963 | .SH "COMPATIBILITY ISSUES"
|
---|
| 964 | The \s-1POSIX\s0 standard specifies behavior that differs from
|
---|
| 965 | .BR patch 's
|
---|
| 966 | traditional behavior.
|
---|
| 967 | You should be aware of these differences if you must interoperate with
|
---|
| 968 | .B patch
|
---|
| 969 | versions 2.1 and earlier, which do not conform to \s-1POSIX\s0.
|
---|
| 970 | .TP 3
|
---|
| 971 | .B " \(bu"
|
---|
| 972 | In traditional
|
---|
| 973 | .BR patch ,
|
---|
| 974 | the
|
---|
| 975 | .B \-p
|
---|
| 976 | option's operand was optional, and a bare
|
---|
| 977 | .B \-p
|
---|
| 978 | was equivalent to
|
---|
| 979 | .BR \-p0.
|
---|
| 980 | The
|
---|
| 981 | .B \-p
|
---|
| 982 | option now requires an operand, and
|
---|
| 983 | .B "\-p\ 0"
|
---|
| 984 | is now equivalent to
|
---|
| 985 | .BR \-p0 .
|
---|
| 986 | For maximum compatibility, use options like
|
---|
| 987 | .B \-p0
|
---|
| 988 | and
|
---|
| 989 | .BR \-p1 .
|
---|
| 990 | .Sp
|
---|
| 991 | Also,
|
---|
| 992 | traditional
|
---|
| 993 | .B patch
|
---|
| 994 | simply counted slashes when stripping path prefixes;
|
---|
| 995 | .B patch
|
---|
| 996 | now counts pathname components.
|
---|
| 997 | That is, a sequence of one or more adjacent slashes
|
---|
| 998 | now counts as a single slash.
|
---|
| 999 | For maximum portability, avoid sending patches containing
|
---|
| 1000 | .B //
|
---|
| 1001 | in file names.
|
---|
| 1002 | .TP
|
---|
| 1003 | .B " \(bu"
|
---|
| 1004 | In traditional
|
---|
| 1005 | .BR patch ,
|
---|
| 1006 | backups were enabled by default.
|
---|
| 1007 | This behavior is now enabled with the
|
---|
| 1008 | .B \-b
|
---|
| 1009 | or
|
---|
| 1010 | .B \*=backup
|
---|
| 1011 | option.
|
---|
| 1012 | .Sp
|
---|
| 1013 | Conversely, in \s-1POSIX\s0
|
---|
| 1014 | .BR patch ,
|
---|
| 1015 | backups are never made, even when there is a mismatch.
|
---|
| 1016 | In \s-1GNU\s0
|
---|
| 1017 | .BR patch ,
|
---|
| 1018 | this behavior is enabled with the
|
---|
| 1019 | .B \*=no\-backup\-if\-mismatch
|
---|
| 1020 | option, or by conforming to \s-1POSIX\s0 with the
|
---|
| 1021 | .B \*=posix
|
---|
| 1022 | option or by setting the
|
---|
| 1023 | .B POSIXLY_CORRECT
|
---|
| 1024 | environment variable.
|
---|
| 1025 | .Sp
|
---|
| 1026 | The
|
---|
| 1027 | .BI \-b "\ suffix"
|
---|
| 1028 | option
|
---|
| 1029 | of traditional
|
---|
| 1030 | .B patch
|
---|
| 1031 | is equivalent to the
|
---|
| 1032 | .BI "\-b\ \-z" "\ suffix"
|
---|
| 1033 | options of \s-1GNU\s0
|
---|
| 1034 | .BR patch .
|
---|
| 1035 | .TP
|
---|
| 1036 | .B " \(bu"
|
---|
| 1037 | Traditional
|
---|
| 1038 | .B patch
|
---|
| 1039 | used a complicated (and incompletely documented) method
|
---|
| 1040 | to intuit the name of the file to be patched from the patch header.
|
---|
| 1041 | This method did not conform to \s-1POSIX\s0, and had a few gotchas.
|
---|
| 1042 | Now
|
---|
| 1043 | .B patch
|
---|
| 1044 | uses a different, equally complicated (but better documented) method
|
---|
| 1045 | that is optionally \s-1POSIX\s0-conforming; we hope it has
|
---|
| 1046 | fewer gotchas. The two methods are compatible if the
|
---|
| 1047 | file names in the context diff header and the
|
---|
| 1048 | .B Index:\&
|
---|
| 1049 | line are all identical after prefix-stripping.
|
---|
| 1050 | Your patch is normally compatible if each header's file names
|
---|
| 1051 | all contain the same number of slashes.
|
---|
| 1052 | .TP
|
---|
| 1053 | .B " \(bu"
|
---|
| 1054 | When traditional
|
---|
| 1055 | .B patch
|
---|
| 1056 | asked the user a question, it sent the question to standard error
|
---|
| 1057 | and looked for an answer from
|
---|
| 1058 | the first file in the following list that was a terminal:
|
---|
| 1059 | standard error, standard output,
|
---|
| 1060 | .BR /dev/tty ,
|
---|
| 1061 | and standard input.
|
---|
| 1062 | Now
|
---|
| 1063 | .B patch
|
---|
| 1064 | sends questions to standard output and gets answers from
|
---|
| 1065 | .BR /dev/tty .
|
---|
| 1066 | Defaults for some answers have been changed so that
|
---|
| 1067 | .B patch
|
---|
| 1068 | never goes into an infinite loop when using default answers.
|
---|
| 1069 | .TP
|
---|
| 1070 | .B " \(bu"
|
---|
| 1071 | Traditional
|
---|
| 1072 | .B patch
|
---|
| 1073 | exited with a status value that counted the number of bad hunks,
|
---|
| 1074 | or with status 1 if there was real trouble.
|
---|
| 1075 | Now
|
---|
| 1076 | .B patch
|
---|
| 1077 | exits with status 1 if some hunks failed,
|
---|
| 1078 | or with 2 if there was real trouble.
|
---|
| 1079 | .TP
|
---|
| 1080 | .B " \(bu"
|
---|
| 1081 | Limit yourself to the following options when sending instructions
|
---|
| 1082 | meant to be executed by anyone running \s-1GNU\s0
|
---|
| 1083 | .BR patch ,
|
---|
| 1084 | traditional
|
---|
| 1085 | .BR patch ,
|
---|
| 1086 | or a
|
---|
| 1087 | .B patch
|
---|
| 1088 | that conforms to \s-1POSIX\s0.
|
---|
| 1089 | Spaces are significant in the following list, and operands are required.
|
---|
| 1090 | .Sp
|
---|
| 1091 | .nf
|
---|
| 1092 | .in +3
|
---|
| 1093 | .ne 11
|
---|
| 1094 | .B \-c
|
---|
| 1095 | .BI \-d " dir"
|
---|
| 1096 | .BI \-D " define"
|
---|
| 1097 | .B \-e
|
---|
| 1098 | .B \-l
|
---|
| 1099 | .B \-n
|
---|
| 1100 | .B \-N
|
---|
| 1101 | .BI \-o " outfile"
|
---|
| 1102 | .BI \-p num
|
---|
| 1103 | .B \-R
|
---|
| 1104 | .BI \-r " rejectfile"
|
---|
| 1105 | .in
|
---|
| 1106 | .fi
|
---|
| 1107 | .SH BUGS
|
---|
| 1108 | Please report bugs via email to
|
---|
| 1109 | .BR <bug-patch@gnu.org> .
|
---|
| 1110 | .PP
|
---|
| 1111 | .B patch
|
---|
| 1112 | could be smarter about partial matches, excessively deviant offsets and
|
---|
| 1113 | swapped code, but that would take an extra pass.
|
---|
| 1114 | .PP
|
---|
| 1115 | If code has been duplicated (for instance with
|
---|
| 1116 | \fB#ifdef OLDCODE\fP .\|.\|. \fB#else .\|.\|. #endif\fP),
|
---|
| 1117 | .B patch
|
---|
| 1118 | is incapable of patching both versions, and, if it works at all, will likely
|
---|
| 1119 | patch the wrong one, and tell you that it succeeded to boot.
|
---|
| 1120 | .PP
|
---|
| 1121 | If you apply a patch you've already applied,
|
---|
| 1122 | .B patch
|
---|
| 1123 | thinks it is a reversed patch, and offers to un-apply the patch.
|
---|
| 1124 | This could be construed as a feature.
|
---|
| 1125 | .SH COPYING
|
---|
| 1126 | Copyright
|
---|
| 1127 | .ie t \(co
|
---|
| 1128 | .el (C)
|
---|
| 1129 | 1984, 1985, 1986, 1988 Larry Wall.
|
---|
| 1130 | .br
|
---|
| 1131 | Copyright
|
---|
| 1132 | .ie t \(co
|
---|
| 1133 | .el (C)
|
---|
| 1134 | 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
---|
| 1135 | 2000, 2001, 2002 Free Software Foundation, Inc.
|
---|
| 1136 | .PP
|
---|
| 1137 | Permission is granted to make and distribute verbatim copies of
|
---|
| 1138 | this manual provided the copyright notice and this permission notice
|
---|
| 1139 | are preserved on all copies.
|
---|
| 1140 | .PP
|
---|
| 1141 | Permission is granted to copy and distribute modified versions of this
|
---|
| 1142 | manual under the conditions for verbatim copying, provided that the
|
---|
| 1143 | entire resulting derived work is distributed under the terms of a
|
---|
| 1144 | permission notice identical to this one.
|
---|
| 1145 | .PP
|
---|
| 1146 | Permission is granted to copy and distribute translations of this
|
---|
| 1147 | manual into another language, under the above conditions for modified
|
---|
| 1148 | versions, except that this permission notice may be included in
|
---|
| 1149 | translations approved by the copyright holders instead of in
|
---|
| 1150 | the original English.
|
---|
| 1151 | .SH AUTHORS
|
---|
| 1152 | Larry Wall wrote the original version of
|
---|
| 1153 | .BR patch .
|
---|
| 1154 | Paul Eggert removed
|
---|
| 1155 | .BR patch 's
|
---|
| 1156 | arbitrary limits; added support for binary files,
|
---|
| 1157 | setting file times, and deleting files;
|
---|
| 1158 | and made it conform better to \s-1POSIX\s0.
|
---|
| 1159 | Other contributors include Wayne Davison, who added unidiff support,
|
---|
| 1160 | and David MacKenzie, who added configuration and backup support.
|
---|