13 patch \- apply a diff file to an original
28 containing a difference listing produced by the
30 program and applies those differences to one or more original files,
31 producing patched versions.
32 Normally the patched versions are put in place of the originals.
33 Backups can be made; see the
38 The names of the files to be patched are usually taken from the patch file,
39 but if there's just one file to be patched it can be specified on the
43 Upon startup, patch attempts to determine the type of the diff listing,
45 \fB\-c\fP (\fB\*=context\fP),
46 \fB\-e\fP (\fB\*=ed\fP),
47 \fB\-n\fP (\fB\*=normal\fP),
49 \fB\-u\fP (\fB\*=unified\fP)
51 Context diffs (old-style, new-style, and unified) and
52 normal diffs are applied by the
56 diffs are simply fed to the
61 tries to skip any leading garbage, apply the diff,
62 and then skip any trailing garbage.
63 Thus you could feed an article or message containing a
67 If the entire diff is indented by a consistent amount, if lines end in \s-1CRLF\s0,
68 or if a diff is encapsulated one or more times by prepending
69 "\fB\- \fP" to lines starting with "\fB\-\fP" as specified by Internet RFC 934,
70 this is taken into account.
71 After removing indenting or encapsulation,
74 are ignored, as they are considered to be comments.
76 With context diffs, and to a lesser extent with normal diffs,
78 can detect when the line numbers mentioned in the patch are incorrect,
79 and attempts to find the correct place to apply each hunk of the patch.
80 As a first guess, it takes the line number mentioned for the hunk, plus or
81 minus any offset used in applying the previous hunk.
82 If that is not the correct place,
84 scans both forwards and backwards for a set of lines matching the context
88 looks for a place where all lines of the context match.
89 If no such place is found, and it's a context diff, and the maximum fuzz factor
90 is set to 1 or more, then another scan takes place ignoring the first and last
92 If that fails, and the maximum fuzz factor is set to 2 or more,
93 the first two and last two lines of context are ignored,
94 and another scan is made.
95 (The default maximum fuzz factor is 2.)
97 Hunks with less prefix context than suffix context (after applying fuzz)
98 must apply at the start of the file if their first line number is\ 1. Hunks
99 with more prefix context than suffix context (after applying fuzz) must apply
100 at the end of the file.
104 cannot find a place to install that hunk of the patch, it puts the
105 hunk out to a reject file, which normally is the name of the output file
112 would generate a file name that is too long
113 (if even appending the single character
115 makes the file name too long, then
117 replaces the file name's last character).
119 The rejected hunk comes out in unified or context diff format.
120 If the input was a normal diff, many of the contexts are simply null.
121 The line numbers on the hunks in the reject file may be different than
122 in the patch file: they reflect the approximate location patch thinks the
123 failed hunks belong in the new file rather than the old one.
125 As each hunk is completed, you are told if the hunk
126 failed, and if so which line (in the new file)
128 thought the hunk should go on.
129 If the hunk is installed at a different line
130 from the line number specified in the diff, you
132 A single large offset
134 indicate that a hunk was installed in the
136 You are also told if a fuzz factor was used to make the match, in which
137 case you should also be slightly suspicious.
140 option is given, you are also told about hunks that match exactly.
144 is specified on the command line,
146 tries to figure out from the leading garbage what the name of the file
147 to edit is, using the following rules.
151 takes an ordered list of candidate file names as follows:
154 If the header is that of a context diff,
156 takes the old and new file names in the header.
157 A name is ignored if it does not have enough slashes to satisfy the
169 line in the leading garbage
170 and if either the old and new names are both absent or if
172 is conforming to \s-1POSIX\s0,
174 takes the name in the
179 For the purpose of the following rules,
180 the candidate file names are considered to be in the order (old, new, index),
181 regardless of the order that they appear in the header.
185 selects a file name from the candidate list as follows:
188 If some of the named files exist,
190 selects the first name if conforming to \s-1POSIX\s0,
191 and the best name otherwise.
196 is not ignoring \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0 (see the
200 option), and no named files exist
201 but an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master is found,
203 selects the first named file
204 with an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master.
207 If no named files exist,
208 no \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master was found,
209 some names are given,
211 is not conforming to \s-1POSIX\s0,
212 and the patch appears to create a file,
214 selects the best name requiring the creation of the fewest directories.
217 If no file name results from the above heuristics, you are asked
218 for the name of the file to patch, and
224 of a nonempty list of file names,
226 first takes all the names with the fewest path name components;
227 of those, it then takes all the names with the shortest basename;
228 of those, it then takes all the shortest names;
229 finally, it takes the first remaining name.
231 Additionally, if the leading garbage contains a
235 takes the first word from the prerequisites line (normally a version
236 number) and checks the original file to see if that word can be found.
239 asks for confirmation before proceeding.
241 The upshot of all this is that you should be able to say, while in a news
242 interface, something like the following:
244 \fB| patch \-d /usr/src/local/blurfl\fP
246 and patch a file in the
248 directory directly from the article containing
251 If the patch file contains more than one patch,
253 tries to apply each of them as if they came from separate patch files.
254 This means, among other things, that it is assumed that the name of the file
255 to patch must be determined for each diff listing,
256 and that the garbage before each diff listing
257 contains interesting things such as file names and revision level, as
258 mentioned previously.
261 \fB\-b\fP or \fB\*=backup\fP
263 That is, when patching a file,
264 rename or copy the original instead of removing it.
265 When backing up a file that does not exist,
266 an empty, unreadable backup file is created
267 as a placeholder to represent the nonexistent file.
271 .B \*=version\-control
272 option for details about how backup file names are determined.
274 .B \*=backup\-if\-mismatch
275 Back up a file if the patch does not match the file exactly
276 and if backups are not otherwise requested.
277 This is the default unless
279 is conforming to \s-1POSIX\s0.
281 .B \*=no\-backup\-if\-mismatch
282 Do not back up a file if the patch does not match the file exactly
283 and if backups are not otherwise requested.
284 This is the default if
286 is conforming to \s-1POSIX\s0.
288 \fB\-B\fP \fIpref\fP or \fB\*=prefix=\fP\fIpref\fP
291 method to determine backup file names (see the
294 .BI "\*=version\-control " method
297 to a file name when generating its backup file name.
300 the simple backup file name for
303 .BR /junk/src/patch/util.c .
306 Write all files in binary mode, except for standard output and
308 When reading, disable the heuristic for transforming CRLF line endings into LF
309 line endings. This option is needed on \s-1POSIX\s0 systems when applying patches
310 generated on non-\s-1POSIX\s0 systems to non-\s-1POSIX\s0 files.
311 (On \s-1POSIX\s0 systems, file reads and writes never transform line
312 endings. On Windows, reads and writes do transform line endings by default,
313 and patches should be generated by
315 when line endings are significant.)
317 \fB\*=read\-only=\fP\fIbehavior\fP
318 Behave as requested when trying to modify a read-only file: \fBignore\fP the
319 potential problem, \fBwarn\fP about it (the default), or \fBfail\fP.
321 \fB\-c\fP or \fB\*=context\fP
322 Interpret the patch file as a ordinary context diff.
324 \fB\-d\fP \fIdir\fP or \fB\*=directory=\fP\fIdir\fP
325 Change to the directory
327 immediately, before doing
330 \fB\-D\fP \fIdefine\fP or \fB\*=ifdef=\fP\fIdefine\fP
332 .BR #ifdef " .\|.\|. " #endif
333 construct to mark changes, with
335 as the differentiating symbol.
338 Print the results of applying the patches without actually changing any files.
340 \fB\-e\fP or \fB\*=ed\fP
341 Interpret the patch file as an
345 \fB\-E\fP or \fB\*=remove\-empty\-files\fP
346 Remove output files that are empty after the patches have been applied.
347 Normally this option is unnecessary, since
349 can examine the time stamps on the header to determine whether a file
350 should exist after patching.
351 However, if the input is not a context diff or if
353 is conforming to \s-1POSIX\s0,
355 does not remove empty patched files unless this option is given.
358 removes a file, it also attempts to remove any empty ancestor directories.
360 \fB\-f\fP or \fB\*=force\fP
361 Assume that the user knows exactly what he or she is doing, and do not
362 ask any questions. Skip patches whose headers
363 do not say which file is to be patched; patch files even though they have the
364 wrong version for the
366 line in the patch; and assume that
367 patches are not reversed even if they look like they are.
368 This option does not suppress commentary; use
372 \fB\-F\fP \fInum\fP or \fB\*=fuzz=\fP\fInum\fP
373 Set the maximum fuzz factor.
374 This option only applies to diffs that have context, and causes
376 to ignore up to that many lines of context in looking for places to install a hunk.
377 Note that a larger fuzz factor increases the odds of a faulty patch.
378 The default fuzz factor is 2. A fuzz factor greater than or equal to the
379 number of lines of context in the context diff, ordinarily 3, ignores all
382 \fB\-g\fP \fInum\fP or \fB\*=get=\fP\fInum\fP
385 actions when a file is under \s-1RCS\s0 or \s-1SCCS\s0 control,
386 and does not exist or is read-only and matches the default version,
387 or when a file is under ClearCase or Perforce control and does not exist.
392 gets (or checks out) the file from the revision control system; if zero,
394 ignores \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0
395 and does not get the file; and if negative,
397 asks the user whether to get the file.
398 The default value of this option is given by the value of the
400 environment variable if it is set; if not, the default value is zero.
403 Print a summary of options and exit.
405 \fB\-i\fP \fIpatchfile\fP or \fB\*=input=\fP\fIpatchfile\fP
412 read from standard input, the default.
414 \fB\-l\fP or \fB\*=ignore\-whitespace\fP
415 Match patterns loosely, in case tabs or spaces
416 have been munged in your files.
417 Any sequence of one or more blanks in the patch file matches any sequence
418 in the original file, and sequences of blanks at the ends of lines are ignored.
419 Normal characters must still match exactly.
420 Each line of the context must still match a line in the original file.
422 \fB\*=merge\fP or \fB\*=merge=merge\fP or \fB\*=merge=diff3\fP
423 Merge a patch file into the original files similar to \fBdiff3\fP(1) or
424 \fBmerge\fP(1). If a conflict is found, \fBpatch\fP outputs a warning and
425 brackets the conflict with \fB<<<<<<<\fP and \fB>>>>>>>\fP lines.
426 A typical conflict will look like this:
431 .I lines from the original file
433 .I original lines from the patch
435 .I new lines from the patch
440 The optional argument of \fB\*=merge\fP determines the output format for
441 conflicts: the diff3 format shows the \fB|||||||\fP section with the original
442 lines from the patch; in the merge format, this section is missing. The merge
443 format is the default.
445 This option implies \fB\*=forward\fP and does not take the
446 \fB--fuzz\fR=\fInum\fP option into account.
448 \fB\-n\fP or \fB\*=normal\fP
449 Interpret the patch file as a normal diff.
451 \fB\-N\fP or \fB\*=forward\fP
452 Ignore patches that seem to be reversed or already applied. It is only checked if
453 the first hunk of a patch can be reversed.
457 \fB\-o\fP \fIoutfile\fP or \fB\*=output=\fP\fIoutfile\fP
460 instead of patching files in place.
461 Do not use this option if
463 is one of the files to be patched.
464 When \fIoutfile\fP is \fB\-\fP, send output to standard output, and send any
465 messages that would usually go to standard output to standard error.
467 \fB\-p\fP\fInum\fP or \fB\*=strip\fP\fB=\fP\fInum\fP
468 Strip the smallest prefix containing
470 leading slashes from each file name found in the patch file.
471 A sequence of one or more adjacent slashes is counted as a single slash.
472 This controls how file names found in the patch file are treated, in case
473 you keep your files in a different directory than the person who sent
475 For example, supposing the file name in the patch file was
477 \fB/u/howard/src/blurfl/blurfl.c\fP
481 gives the entire file name unmodified,
485 \fBu/howard/src/blurfl/blurfl.c\fP
487 without the leading slash,
491 \fBblurfl/blurfl.c\fP
495 at all just gives you \fBblurfl.c\fP.
496 Whatever you end up with is looked for either in the current directory,
497 or the directory specified by the
502 Conform more strictly to the \s-1POSIX\s0 standard, as follows.
506 Take the first existing file from the list (old, new, index)
507 when intuiting file names from diff headers.
510 Do not remove files that are empty after patching.
513 Do not ask whether to get files from \s-1RCS\s0, ClearCase, Perforce,
517 Require that all options precede the files in the command line.
520 Do not backup files when there is a mismatch.
523 .BI \*=quoting\-style= word
526 to quote output names.
529 should be one of the following:
536 Quote names for the shell if they contain shell metacharacters or would
537 cause ambiguous output.
540 Quote names for the shell, even if they would normally not require quoting.
543 Quote names as for a C language string.
548 except omit the surrounding double-quote characters.
550 You can specify the default value of the
552 option with the environment variable
554 If that environment variable is not set, the default value is
558 \fB\-r\fP \fIrejectfile\fP or \fB\*=reject\-file=\fP\fIrejectfile\fP
561 instead of the default
563 file. When \fIrejectfile\fP is \fB\-\fP, discard rejects.
565 \fB\-R\fP or \fB\*=reverse\fP
566 Assume that this patch was created with the old and new files swapped.
567 (Yes, I'm afraid that does happen occasionally, human nature being what it
570 attempts to swap each hunk around before applying it.
571 Rejects come out in the swapped format.
574 option does not work with
576 diff scripts because there is too little
577 information to reconstruct the reverse operation.
579 If the first hunk of a patch fails,
581 reverses the hunk to see if it can be applied that way.
582 If it can, you are asked if you want to have the
585 If it can't, the patch continues to be applied normally.
586 (Note: this method cannot detect a reversed patch if it is a normal diff
587 and if the first command is an append (i.e. it should have been a delete)
588 since appends always succeed, due to the fact that a null context matches
590 Luckily, most patches add or change lines rather than delete them, so most
591 reversed normal diffs begin with a delete, which fails, triggering
594 \fB\*=reject\-format=\fP\fIformat\fP
595 Produce reject files in the specified \fIformat\fP (either \fBcontext\fP or
596 \fBunified\fP). Without this option, rejected hunks come out in unified diff
597 format if the input patch was of that format, otherwise in ordinary context
600 \fB\-s\fP or \fB\*=silent\fP or \fB\*=quiet\fP
601 Work silently, unless an error occurs.
603 \fB\-t\fP or \fB\*=batch\fP
604 Suppress questions like
606 but make some different assumptions:
607 skip patches whose headers do not contain file names (the same as \fB\-f\fP);
608 skip patches for which the file has the wrong version for the
611 in the patch; and assume that patches are reversed if they look like
614 \fB\-T\fP or \fB\*=set\-time\fP
615 Set the modification and access times of patched files from time stamps
616 given in context diff headers. Unless specified in the time stamps,
617 assume that the context diff headers use local time.
619 Use of this option with time stamps that do not include time zones is
620 not recommended, because patches using local time cannot easily be used
621 by people in other time zones, and because local time stamps are
622 ambiguous when local clocks move backwards during daylight-saving time
623 adjustments. Make sure that time stamps include time zones, or generate
624 patches with \s-1UTC\s0 and use the
630 \fB\-u\fP or \fB\*=unified\fP
631 Interpret the patch file as a unified context diff.
633 \fB\-v\fP or \fB\*=version\fP
636 revision header and patch level, and exit.
638 \fB\-V\fP \fImethod\fP or \fB\*=version\-control=\fP\fImethod\fP
642 backup file names. The method can also be given by the
643 .B PATCH_VERSION_CONTROL
644 (or, if that's not set, the
645 .BR VERSION_CONTROL )
646 environment variable, which is overridden by this option.
647 The method does not affect whether backup files are made;
648 it affects only the names of any backup files that are made.
652 is like the \s-1GNU\s0
653 Emacs `version-control' variable;
655 also recognizes synonyms that
656 are more descriptive. The valid values for
658 are (unique abbreviations are
662 \fBexisting\fP or \fBnil\fP
663 Make numbered backups of files that already have them,
664 otherwise simple backups.
667 \fBnumbered\fP or \fBt\fP
668 Make numbered backups. The numbered backup file name for
674 is the version number.
676 \fBsimple\fP or \fBnever\fP
684 .BR \*=basename\-prefix ,
689 options specify the simple backup file name.
690 If none of these options are given, then a simple backup suffix is used;
691 it is the value of the
692 .B SIMPLE_BACKUP_SUFFIX
693 environment variable if set, and is
697 With numbered or simple backups,
698 if the backup file name is too long, the backup suffix
700 is used instead; if even appending
702 would make the name too long, then
704 replaces the last character of the file name.
708 Output extra information about the work being done.
710 \fB\-x\fP \fInum\fP or \fB\*=debug=\fP\fInum\fP
711 Set internal debugging flags of interest only to
715 \fB\-Y\fP \fIpref\fP or \fB\*=basename\-prefix=\fP\fIpref\fP
718 method to determine backup file names (see the
721 .BI "\*=version\-control " method
724 to the basename of a file name when generating its backup file name.
727 the simple backup file name for
730 .BR src/patch/.del/util.c .
732 \fB\-z\fP \fIsuffix\fP or \fB\*=suffix=\fP\fIsuffix\fP
735 method to determine backup file names (see the
738 .BI "\*=version\-control " method
744 the backup file name for
747 .BR src/patch/util.c- .
749 \fB\-Z\fP or \fB\*=set\-utc\fP
750 Set the modification and access times of patched files from time stamps
751 given in context diff headers. Unless specified in the time stamps,
752 assume that the context diff headers use Coordinated Universal Time
753 (\s-1UTC\s0, often known as \s-1GMT\s0). Also see the
767 options normally refrain from setting a file's time if the file's original time
768 does not match the time given in the patch header, or if its
769 contents do not match the patch exactly. However, if the
773 option is given, the file time is set regardless.
775 Due to the limitations of
777 output format, these options cannot update the times of files whose
778 contents have not changed. Also, if you use these options, you should remove
781 all files that depend on the patched files, so that later invocations of
783 do not get confused by the patched files' times.
787 This specifies whether
789 gets missing or read-only files from \s-1RCS\s0, ClearCase, Perforce,
800 conforms more strictly to the \s-1POSIX\s0 standard by default:
810 .B SIMPLE_BACKUP_SUFFIX
811 Extension to use for simple backup file names instead of
814 \fBTMPDIR\fP, \fBTMP\fP, \fBTEMP\fP
815 Directory to put temporary files in;
817 uses the first environment variable in this list that is set.
818 If none are set, the default is system-dependent;
823 \fBVERSION_CONTROL\fP or \fBPATCH_VERSION_CONTROL\fP
824 Selects version control style; see the
827 .B \*=version\-control
835 controlling terminal; used to get answers to questions asked of the user
841 Marshall T. Rose and Einar A. Stefferud,
842 Proposed Standard for Message Encapsulation,
843 Internet RFC 934 <URL:ftp://ftp.isi.edu/in-notes/rfc934.txt> (1985-01).
844 .SH "NOTES FOR PATCH SENDERS"
845 There are several things you should bear in mind if you are going to
846 be sending out patches.
848 Create your patch systematically.
849 A good method is the command
850 .BI "diff\ \-Naur\ " "old\ new"
855 identify the old and new directories.
860 should not contain any slashes.
863 command's headers should have dates
864 and times in Universal Time using traditional Unix format,
865 so that patch recipients can use the
870 Here is an example command, using Bourne shell syntax:
872 \fBLC_ALL=C TZ=UTC0 diff \-Naur gcc\-2.7 gcc\-2.8\fP
874 Tell your recipients how to apply the patch
875 by telling them which directory to
879 options to use. The option string
882 Test your procedure by pretending to be a recipient and applying
883 your patch to a copy of the original files.
885 You can save people a lot of grief by keeping a
887 file which is patched to increment the patch level
888 as the first diff in the patch file you send out.
891 line in with the patch, it won't let them apply
892 patches out of order without some warning.
894 You can create a file by sending out a diff that compares
896 or an empty file dated the Epoch (1970-01-01 00:00:00 \s-1UTC\s0)
897 to the file you want to create.
898 This only works if the file you want to create doesn't exist already in
899 the target directory.
900 Conversely, you can remove a file by sending out a context diff that compares
901 the file to be deleted with an empty file dated the Epoch.
902 The file will be removed unless
904 is conforming to \s-1POSIX\s0 and the
907 .B \*=remove\-empty\-files
909 An easy way to generate patches that create and remove files
917 If the recipient is supposed to use the
919 option, do not send output that looks like this:
923 diff \-Naur v2.0.29/prog/README prog/README
925 \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
927 +\^+\^+ prog/README Mon Mar 17 14:58:22 1997
930 because the two file names have different numbers of slashes,
931 and different versions of
933 interpret the file names differently.
934 To avoid confusion, send output that looks like this instead:
938 diff \-Naur v2.0.29/prog/README v2.0.30/prog/README
940 \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
942 +\^+\^+ v2.0.30/prog/README Mon Mar 17 14:58:22 1997
946 Avoid sending patches that compare backup file names like
948 since this might confuse
950 into patching a backup file instead of the real file.
951 Instead, send patches that compare the same base file names
952 in different directories, e.g.\&
957 Take care not to send out reversed patches, since it makes people wonder
958 whether they already applied the patch.
960 Try not to have your patch modify derived files
963 where there is a line
964 .B "configure: configure.in"
965 in your makefile), since the recipient should be
966 able to regenerate the derived files anyway.
967 If you must send diffs of derived files,
968 generate the diffs using \s-1UTC\s0,
969 have the recipients apply the patch with the
973 option, and have them remove any unpatched files that depend on patched files
977 While you may be able to get away with putting 582 diff listings into
978 one file, it may be wiser to group related patches into separate files in
979 case something goes haywire.
981 Diagnostics generally indicate that
983 couldn't parse your patch file.
987 option is given, the message
989 indicates that there is unprocessed text in
990 the patch file and that
992 is attempting to intuit whether there is a patch in that text and, if so,
993 what kind of patch it is.
997 0 if all hunks are applied successfully,
998 1 if some hunks cannot be applied or there were merge conflicts,
999 and 2 if there is more serious trouble.
1000 When applying a set of patches in a loop it behooves you to check this
1001 exit status so you don't apply a later patch to a partially patched file.
1003 Context diffs cannot reliably represent the creation or deletion of
1004 empty files, empty directories, or special files such as symbolic links.
1005 Nor can they represent changes to file metadata like ownership, permissions,
1006 or whether one file is a hard link to another.
1007 If changes like these are also required, separate instructions
1008 (e.g. a shell script) to accomplish them should accompany the patch.
1011 cannot tell if the line numbers are off in an
1013 script, and can detect
1014 bad line numbers in a normal diff only when it finds a change or deletion.
1015 A context diff using fuzz factor 3 may have the same problem.
1016 You should probably do
1017 a context diff in these cases to see if the changes made sense.
1018 Of course, compiling without errors is a pretty good indication that the patch
1019 worked, but not always.
1022 usually produces the correct results, even when it has to do a lot of
1024 However, the results are guaranteed to be correct only when the patch is
1025 applied to exactly the same version of the file that the patch was
1027 .SH "COMPATIBILITY ISSUES"
1028 The \s-1POSIX\s0 standard specifies behavior that differs from
1030 traditional behavior.
1031 You should be aware of these differences if you must interoperate with
1033 versions 2.1 and earlier, which do not conform to \s-1POSIX\s0.
1040 option's operand was optional, and a bare
1046 option now requires an operand, and
1048 is now equivalent to
1050 For maximum compatibility, use options like
1058 simply counted slashes when stripping path prefixes;
1060 now counts pathname components.
1061 That is, a sequence of one or more adjacent slashes
1062 now counts as a single slash.
1063 For maximum portability, avoid sending patches containing
1070 backups were enabled by default.
1071 This behavior is now enabled with the
1077 Conversely, in \s-1POSIX\s0
1079 backups are never made, even when there is a mismatch.
1082 this behavior is enabled with the
1083 .B \*=no\-backup\-if\-mismatch
1084 option, or by conforming to \s-1POSIX\s0 with the
1086 option or by setting the
1088 environment variable.
1095 is equivalent to the
1096 .BI "\-b\ \-z" "\ suffix"
1097 options of \s-1GNU\s0
1103 used a complicated (and incompletely documented) method
1104 to intuit the name of the file to be patched from the patch header.
1105 This method did not conform to \s-1POSIX\s0, and had a few gotchas.
1108 uses a different, equally complicated (but better documented) method
1109 that is optionally \s-1POSIX\s0-conforming; we hope it has
1110 fewer gotchas. The two methods are compatible if the
1111 file names in the context diff header and the
1113 line are all identical after prefix-stripping.
1114 Your patch is normally compatible if each header's file names
1115 all contain the same number of slashes.
1120 asked the user a question, it sent the question to standard error
1121 and looked for an answer from
1122 the first file in the following list that was a terminal:
1123 standard error, standard output,
1128 sends questions to standard output and gets answers from
1130 Defaults for some answers have been changed so that
1132 never goes into an infinite loop when using default answers.
1137 exited with a status value that counted the number of bad hunks,
1138 or with status 1 if there was real trouble.
1141 exits with status 1 if some hunks failed,
1142 or with 2 if there was real trouble.
1145 Limit yourself to the following options when sending instructions
1146 meant to be executed by anyone running \s-1GNU\s0
1152 that conforms to \s-1POSIX\s0.
1153 Spaces are significant in the following list, and operands are required.
1168 .BI \-r " rejectfile"
1172 Please report bugs via email to
1173 .BR <bug-patch@gnu.org> .
1175 If code has been duplicated (for instance with
1176 \fB#ifdef OLDCODE\fP .\|.\|. \fB#else .\|.\|. #endif\fP),
1178 is incapable of patching both versions, and, if it works at all, will likely
1179 patch the wrong one, and tell you that it succeeded to boot.
1181 If you apply a patch you've already applied,
1183 thinks it is a reversed patch, and offers to un-apply the patch.
1184 This could be construed as a feature.
1186 Computing how to merge a hunk is significantly harder than using the standard
1187 fuzzy algorithm. Bigger hunks, more context, a bigger offset from the
1188 original location, and a worse match all slow the algorithm down.
1193 1984, 1985, 1986, 1988 Larry Wall.
1198 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
1199 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
1201 Permission is granted to make and distribute verbatim copies of
1202 this manual provided the copyright notice and this permission notice
1203 are preserved on all copies.
1205 Permission is granted to copy and distribute modified versions of this
1206 manual under the conditions for verbatim copying, provided that the
1207 entire resulting derived work is distributed under the terms of a
1208 permission notice identical to this one.
1210 Permission is granted to copy and distribute translations of this
1211 manual into another language, under the above conditions for modified
1212 versions, except that this permission notice may be included in
1213 translations approved by the copyright holders instead of in
1214 the original English.
1216 Larry Wall wrote the original version of
1220 arbitrary limits; added support for binary files,
1221 setting file times, and deleting files;
1222 and made it conform better to \s-1POSIX\s0.
1223 Other contributors include Wayne Davison, who added unidiff support,
1224 and David MacKenzie, who added configuration and backup support.
1225 Andreas Gr\[:u]nbacher added support for merging.