Lines Matching refs:patch
5 showing the differences between files and the GNU `patch' command for
28 * patch: (diff)Invoking patch. Apply a patch to a file.
45 showing the differences between files and the GNU `patch' command for
79 * Merging with patch:: Using `patch' to change old files into new ones.
80 * Making Patches:: Tips for making and using patch distributions.
85 * Invoking patch:: Apply a diff file to an original.
109 called a "diff" or "patch". For files that are identical, `diff'
131 to the complete files. Given `diff' output, you can use the `patch'
132 program to update, or "patch", a copy of the file. If you think of
134 difference, you can think of `patch' as adding the difference to one
155 `patch' was written mainly by Larry Wall and Paul Eggert; several
622 small changes of their own to the files. `patch' can apply the diffs
625 where the diff says they are, `patch' can adjust the line numbers
627 more information on using `patch' to apply imperfect diffs.
650 `patch' typically needs at least two lines of context.
798 `patch' can automatically apply diffs in this format. For proper
799 operation, `patch' typically needs at least three lines of context.
1101 automatically; today, with `patch', it is almost obsolete. Use the
1201 `patch' can apply diffs in this format. It exists mainly for
1586 The `patch' `-D NAME' option behaves like the `diff' `-D NAME'
1588 file; *Note patch Options::.
1697 in the newer directory, you can make the patch smaller by using the
1701 added). At the top of the patch, write instructions for the user
1702 applying the patch to remove the files that were deleted before
1703 applying the patch. *Note Making Patches::, for more discussion of
1774 every 8 print columns. To use this form of output with `patch', you
1775 must give `patch' the `-l' or `--ignore-white-space' option (*note
2268 File: diff.info, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: …
2364 File: diff.info, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up:…
2366 Merging with `patch'
2369 `patch' takes comparison output produced by `diff' and applies the
2371 version. With `patch', you can distribute just the changes to a set of
2373 can apply `patch' to update their copy of the files with your changes.
2374 `patch' automatically determines the diff format, skips any leading or
2376 patch. This lets your correspondents feed a mail message containing a
2377 difference listing directly to `patch'.
2379 `patch' detects and warns about common problems like forward
2384 `patch' accepts a series of diffs in its standard input, usually
2385 separated by headers that specify which file to patch. It applies
2387 match the original file, `patch' uses heuristics to try to patch the
2388 file as well as it can. If no approximate match can be found, `patch'
2389 rejects the hunk and skips to the next hunk. `patch' normally replaces
2393 *Note Invoking patch::, for detailed information on the options to
2394 `patch'.
2398 * patch Input:: Selecting the type of `patch' input.
2401 * Creating and Removing:: Creating and removing files with a patch.
2404 * patch Directories:: Changing directory and stripping directories.
2408 * patch Messages:: Messages and questions `patch' can produce.
2409 * patch and POSIX:: Conformance to the POSIX standard.
2410 * patch and Tradition:: GNU versus traditional `patch'.
2413 File: diff.info, Node: patch Input, Next: Revision Control, Up: Merging with patch
2415 Selecting the `patch' Input Format
2418 `patch' normally determines which `diff' format the patch file uses
2419 by examining its contents. For patch files that contain particularly
2421 options to force `patch' to interpret the patch file as a certain
2423 `patch' can understand.
2442 …: diff.info, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch
2448 supported by `patch', `patch' normally asks the user whether to get (or
2450 supports RCS, ClearCase and SCCS. Under RCS and SCCS, `patch' also
2455 revision control systems. If NUM is positive, `patch' gets the file
2456 without asking the user; if zero, `patch' neither asks the user nor
2457 gets the file; and if negative, `patch' asks the user before getting
2460 value is zero if `patch' is conforming to POSIX, negative otherwise.
2461 *Note patch and POSIX::.
2467 …o, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch
2472 `patch' tries to skip any leading text in the patch file, apply the
2474 message directly to `patch', and it should work. If the entire diff is
2475 indented by a constant amount of white space, `patch' automatically
2477 return on each line, `patch' automatically ignores the carriage return.
2480 (ftp://ftp.isi.edu/in-notes/rfc934.txt), `patch' automatically
2490 * Inexact:: Helping `patch' find close matches.
2491 * Dry Runs:: Predicting what `patch' will do.
2500 tabs, or vice versa. If this happens to a patch file or an input file,
2501 the files might look the same, but `patch' will not be able to match
2503 `--ignore-white-space' option, which makes `patch' compare blank
2505 of blanks in the patch file matches any nonempty sequence of blanks in
2517 patches, give `patch' the `-R' or `--reverse' option. `patch' then
2521 Often `patch' can guess that the patch is reversed. If the first
2522 hunk of a patch fails, `patch' reverses the hunk to see if it can apply
2523 it that way. If it can, `patch' asks you if you want to have the `-R'
2524 option set; if it can't, `patch' continues to apply the patch normally.
2525 This method cannot detect a reversed patch if it is a normal diff and
2529 reversed normal diffs begin with a delete, which fails, and `patch'
2532 If you apply a patch that you have already applied, `patch' thinks
2533 it is a reversed patch and offers to un-apply the patch. This could be
2535 want to un-apply the patch, just answer `n' to this offer and to the
2536 subsequent "apply anyway" question--or type `C-c' to kill the `patch'
2542 Helping `patch' Find Inexact Matches
2545 For context diffs, and to a lesser extent normal diffs, `patch' can
2546 detect when the line numbers mentioned in the patch are incorrect, and
2547 it attempts to find the correct place to apply each hunk of the patch.
2550 the correct place, `patch' scans both forward and backward for a set of
2553 First `patch' looks for a place where all lines of the context
2556 `patch' makes another scan, ignoring the first and last line of
2566 faulty patch. The default fuzz factor is 2; there is no point to
2570 If `patch' cannot find a place to install a hunk of the patch, it
2573 hunks in context format no matter what form the input patch is in. If
2576 different from those in the patch file: they show the approximate
2577 location where `patch' thinks the failed hunks belong in the new file
2581 `patch' tells you whether the hunk succeeded or failed, and if it
2582 failed, on which line (in the new file) `patch' thinks the hunk should
2585 `patch' installed a hunk in the wrong place. `patch' also tells you if
2589 `patch' cannot tell if the line numbers are off in an `ed' script,
2596 pretty good indication that the patch worked, but not a guarantee.
2598 A patch against an empty file applies to a nonexistent file, and vice
2601 `patch' usually produces the correct results, even when it must make
2602 many guesses. However, the results are guaranteed only when the patch
2603 is applied to an exact copy of the file that the patch was generated
2609 Predicting what `patch' will do
2612 It may not be obvious in advance what `patch' will do with a
2613 complicated or poorly formatted patch. If you are concerned that the
2614 input might cause `patch' to modify the wrong files, you can use the
2615 `--dry-run' option, which causes `patch' to print the results of
2617 inspect the diagnostics generated by the dry run to see whether `patch'
2618 will modify the files that you expect. If the patch does not do what
2619 you want, you can modify the patch (or the other options to `patch')
2621 patch you can apply it by invoking `patch' as before, but this time
2625 …Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch
2634 UTC), `diff' outputs a patch that adds or deletes the contents of this
2635 file. When given such a patch, `patch' normally creates a new file or
2636 removes the old file. However, when conforming to POSIX (*note patch
2637 and POSIX::), `patch' does not remove the old file, but leaves it empty.
2638 The `-E' or `--remove-empty-files' option causes `patch' to remove
2639 output files that are empty after applying a patch, even if the patch
2642 If the patch appears to create a file that already exists, `patch'
2643 asks for confirmation before applying the patch.
2646 …atching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch
2651 When `patch' updates a file, it normally sets the file's
2653 `patch' to track a software distribution, this can cause `make' to
2655 if `syntax.c' depends on `syntax.y', and `patch' updates `syntax.c' and
2660 The `-Z' or `--set-utc' option causes `patch' to set a patched
2675 `patch' normally refrains from setting a file's time stamps if the
2678 patch. However, if the `-f' or `--force' option is given, the file's
2681 Due to the limitations of the current `diff' format, `patch' cannot
2689 …ff.info, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merg…
2694 If the patch file contains more than one patch, and if you do not
2695 specify an input file on the command line, `patch' tries to apply each
2696 patch as if they came from separate patch files. This means that it
2697 determines the name of the file to patch for each patch, and that it
2698 examines the leading text before each patch for file names and
2702 `patch' uses the following rules to intuit a file name from the
2703 leading text before a patch. First, `patch' takes an ordered list of
2706 * If the header is that of a context diff, `patch' takes the old and
2712 the old and new names are both absent or if `patch' is conforming
2713 to POSIX, `patch' takes the name in the `Index:' line.
2719 Then `patch' selects a file name from the candidate list as follows:
2721 * If some of the named files exist, `patch' selects the first name
2724 * If `patch' is not ignoring RCS, ClearCase, and SCCS (*note
2726 ClearCase, or SCCS master is found, `patch' selects the first
2730 found, some names are given, `patch' is not conforming to POSIX,
2731 and the patch appears to create a file, `patch' selects the best
2735 for the name of the file to patch, and `patch' selects that name.
2737 To determine the "best" of a nonempty list of file names, `patch'
2743 *Note patch and POSIX::, to see whether `patch' is conforming to
2747 File: diff.info, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging wi…
2752 The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch'
2754 file names in the patch file, and file names given as arguments to
2756 reading program, you can patch a file in the `/usr/src/emacs' directory
2757 directly from a message containing the patch like this:
2759 | patch -d /usr/src/emacs
2761 Sometimes the file names given in a patch contain leading
2763 one given in the patch. In those cases, you can use the `-pNUMBER' or
2765 The strip count tells `patch' how many slashes, along with the directory
2768 default, `patch' strips off all leading directories, leaving just the
2771 For example, suppose the file name in the patch file is
2776 `patch' looks for each file (after any slashes have been stripped)
2781 …: diff.info, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch
2786 Normally, `patch' creates a backup file if the patch does not
2788 original data might not be recovered if you undo the patch with `patch
2790 `patch' does not create backup files by default. *Note patch and
2793 The `-b' or `--backup' option causes `patch' to make a backup file
2794 regardless of whether the patch matches the original input. The
2795 `--backup-if-mismatch' option causes `patch' to create backup files for
2797 `--no-backup-if-mismatch' option causes `patch' to not create backup
2806 File: diff.info, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch
2811 Normally, `patch' renames an original input file into a backup file
2814 `--suffix=BACKUP-SUFFIX' option causes `patch' to use BACKUP-SUFFIX as
2820 `patch' can also create numbered backup files the way GNU Emacs
2822 `patch' makes a new backup file name each time it patches a file. For
2828 alternately control the type of backups that `patch' makes with the
2855 You can also tell `patch' to prepend a prefix, such as a directory
2874 (1) A coding error in GNU `patch' version 2.5.4 causes it to always
2878 File: diff.info, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with…
2883 The names for reject files (files containing patches that `patch'
2888 Alternatively, you can tell `patch' to place all of the rejected
2894 File: diff.info, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging w…
2896 Messages and Questions from `patch'
2899 `patch' can produce a variety of messages, especially if it has
2901 how to proceed, `patch' normally prompts you for more information from
2908 * More or Fewer Messages:: Controlling the verbosity of `patch'.
2909 * patch and Keyboard Input:: Inhibiting keyboard input.
2910 * patch Quoting Style:: Quoting file names in diagnostics.
2912 `patch' exits with status 0 if all hunks are applied successfully, 1
2915 status, so you don't apply a later patch to a partially patched file.
2918 File: diff.info, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages
2920 Controlling the Verbosity of `patch'
2923 You can cause `patch' to produce more messages by using the
2925 message `Hmm...' indicates that `patch' is reading text in the patch
2926 file, attempting to determine whether there is a patch in that text,
2927 and if so, what kind of patch it is.
2929 You can inhibit all terminal output from `patch', unless an error
2933 File: diff.info, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer …
2938 There are two ways you can prevent `patch' from asking you any
2940 are doing. It causes `patch' to do the following:
2945 `Prereq:' line in the patch;
2957 `Prereq:' line in the patch;
2962 File: diff.info, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages
2964 `patch' Quoting Style
2967 When `patch' outputs a file name in a diagnostic message, it can
2994 change in a future version of `patch'.
2997 File: diff.info, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Me…
2999 `patch' and the POSIX Standard
3003 environment variable, `patch' conforms more strictly to the POSIX
3022 File: diff.info, Node: patch and Tradition, Prev: patch and POSIX, Up: Merging with patch
3024 GNU `patch' and Traditional `patch'
3027 The current version of GNU `patch' normally follows the POSIX
3028 standard. *Note patch and POSIX::, for the few exceptions to this
3031 Unfortunately, POSIX redefined the behavior of `patch' in several
3033 you must interoperate with traditional `patch', or with GNU `patch'
3036 * In traditional `patch', the `-p' option's operand was optional,
3041 Also, traditional `patch' simply counted slashes when stripping
3042 path prefixes; `patch' now counts pathname components. That is, a
3047 * In traditional `patch', backups were enabled by default. This
3050 Conversely, in POSIX `patch', backups are never made, even when
3051 there is a mismatch. In GNU `patch', this behavior is enabled
3055 The `-b SUFFIX' option of traditional `patch' is equivalent to the
3056 `-b -z SUFFIX' options of GNU `patch'.
3058 * Traditional `patch' used a complicated (and incompletely
3060 from the patch header. This method did not conform to POSIX, and
3061 had a few gotchas. Now `patch' uses a different, equally
3066 patch is normally compatible if each header's file names all
3069 * When traditional `patch' asked the user a question, it sent the
3072 standard output, `/dev/tty', and standard input. Now `patch'
3075 `patch' never goes into an infinite loop when using default
3078 * Traditional `patch' exited with a status value that counted the
3080 Now `patch' exits with status 1 if some hunks failed, or with 2 if
3084 meant to be executed by anyone running GNU `patch', traditional
3085 `patch', or a `patch' that conforms to POSIX. Spaces are
3102 File: diff.info, Node: Making Patches, Next: Invoking cmp, Prev: Merging with patch, Up: Top
3110 harder-to-digest patch that covers all the subjects.
3119 * Avoiding Common Mistakes:: Avoiding common mistakes when using `patch'.
3128 To create a patch that changes an older version of a package into a
3133 To generate the patch, use the command `diff -Naur OLD NEW' where
3135 NEW should not contain any slashes. The `-N' option lets the patch
3136 create and remove files; `-a' lets the patch update non-text files; `-u'
3138 patch update subdirectories. Here is an example command, using Bourne
3144 which working directory to use, and which `patch' options to use; the
3149 when generating a patch.
3157 A patch producer should tell recipients how to apply the patches, so
3158 the first rule of thumb for a patch consumer is to follow the
3159 instructions supplied with the patch.
3162 that end in incomplete lines. However, older versions of `patch'
3163 cannot patch such files. If you are having trouble applying such
3164 patches, try upgrading to a recent version of GNU `patch'.
3172 When producing a patch for multiple files, apply `diff' to
3174 when the patch consumer specifies the `-pNUMBER' option, since this
3176 different numbers of slashes. For example, do not send a patch with a
3184 different versions of `patch' interpret the file names differently. To
3194 already applied the patch.
3197 `README.orig' or `README~', since this might confuse `patch' into
3202 To save people from partially applying a patch before other patches
3203 that should have gone before it, you can make the first patch in the
3204 patch file update a file with a name like `patchlevel.h' or
3205 `version.c', which contains a patch level or version number. If the
3206 input file contains the wrong version number, `patch' will complain
3210 line before the patch. If the leading text in the patch file contains a
3211 line that starts with `Prereq:', `patch' takes the next word from that
3214 newline. If not, `patch' prompts you for confirmation before
3224 The simplest way to generate a patch is to use `diff -Naur' (*note
3226 of the patch by renaming or removing some files before making the
3227 patch. If the older version of the package contains any files that the
3230 execute in the old version directory before applying the patch. Then
3233 If there are any files that you don't need to include in the patch
3236 patch by giving `diff' the `-x PATTERN' option (*note Comparing
3237 Directories::). If you want your patch to modify a derived file
3239 patch for the derived file follows any patches for files that it
3242 Now you can create the patch using `diff -Naur'. Make sure to
3245 Add to the top of the patch a note telling the user any `rm' and
3246 `mv' commands to run before applying the patch. Then you can remove
3249 You can also shrink the patch size by using fewer lines of context,
3250 but bear in mind that `patch' typically needs at least two lines for
3487 For proper operation, `patch' typically needs at least two lines of
3669 For proper operation, `patch' typically needs at least two lines of
3706 File: diff.info, Node: Invoking diff3, Next: Invoking patch, Prev: Invoking diff, Up: Top
3822 File: diff.info, Node: Invoking patch, Next: Invoking sdiff, Prev: Invoking diff3, Up: Top
3824 Invoking `patch'
3827 Normally `patch' is invoked like this:
3829 patch <PATCHFILE
3831 The full format for invoking `patch' is:
3833 patch OPTIONS... [ORIGFILE [PATCHFILE]]
3835 You can also specify where to read the patch from with the `-i
3837 PATCHFILE, or if PATCHFILE is `-', `patch' reads the patch (that is,
3840 If you do not specify an input file on the command line, `patch'
3841 tries to intuit from the "leading text" (any text in the patch that
3845 By default, `patch' replaces the original input file with the
3847 backup file (*note Backup Names::, for a description of how `patch'
3854 * patch Options:: Summary table of options to `patch'.
3857 File: diff.info, Node: patch Options, Up: Invoking patch
3859 Options to `patch'
3862 Here is a summary of all of the options that GNU `patch' accepts.
3863 *Note patch and Tradition::, for which of these options are safe to use
3864 in older versions of `patch'.
3879 Back up the original contents of each file if the patch does not
3887 difference, the patch should be generated by `diff -a --binary'.
3892 Interpret the patch file as a context diff. *Note patch Input::.
3897 both file names in the patch file, and file names given as
3898 arguments to other options. *Note patch Directories::.
3910 Interpret the patch file as an `ed' script. *Note patch Input::.
3920 not ask any questions. *Note patch Messages::.
3937 Read the patch from PATCHFILE rather than from standard input.
3938 *Note patch Options::.
3942 Let any sequence of blanks (spaces or tabs) in the patch file match
3948 Interpret the patch file as a normal diff. *Note patch Input::.
3952 Ignore patches that `patch' thinks are reversed or already applied.
3961 Use FILE as the output file name. *Note patch Options::.
3965 Set the file name strip count to NUMBER. *Note patch
3970 had been set. *Note patch and POSIX::.
3975 patch Quoting Style::.
3983 Assume that this patch was created with the old and new files
3989 Work silently unless an error occurs. *Note patch Messages::.
3993 Do not ask any questions. *Note patch Messages::.
4003 Interpret the patch file as a unified diff. *Note patch Input::.
4015 Print more diagnostics than usual. *Note patch Messages::.
4019 Set internal debugging flags. Of interest only to `patch'
4039 File: diff.info, Node: Invoking sdiff, Next: Standards conformance, Prev: Invoking patch, Up: T…
4207 Here are some ideas for improving GNU `diff' and `patch'. The GNU
4225 Suggested Projects for Improving GNU `diff' and `patch'
4228 One should be able to use GNU `diff' to generate a patch from any
4229 pair of directory trees, and given the patch and a copy of one such
4230 tree, use `patch' to generate a faithful copy of the other.
4232 current patch formats; also, `patch' does not handle some of the
4267 `http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch…
4277 `diff' and `patch' do not handle some changes to directory
4281 `patch' to transform the directory subtree into the file.
4284 having to include its entire contents in the patch file. There should
4285 also be a way to tell `patch' that a file was renamed, even if there is
4287 to tell `patch' that a file's time stamp has changed, even if its
4291 represent changes in directory structure, and extending `patch' to
4305 comparing directories. This means that `patch' cannot represent changes
4311 and `patch' should be extended to understand these extensions.
4320 white space, `diff -r' generates a patch that `patch' cannot parse.
4321 The problem is with format of `diff' output, not just with `patch',
4323 patch that is syntactically correct but patches the wrong files. The
4333 Applying `patch' to a multiple-file diff can result in files whose
4334 time stamps are out of order. GNU `patch' has options to restore the
4336 sometimes it is useful to generate a patch that works even if the
4337 recipient does not have GNU patch, or does not use these options. One
4385 <bug-gnu-utils@gnu.org>. Please send bug reports for GNU `patch' to
4386 <bug-patch@gnu.org>. Send as precise a description of the problem as
4390 patch, please send it too. It may simplify the maintainer's job if the
4391 patch is relative to a recent test release, which you can find in the
4824 * diagnostics from patch: patch Messages.
4833 * directories and patch: patch Directories.
4835 * dry runs for patch: Dry Runs.
4858 * imperfect patch application: Imperfect.
4862 * inhibit messages from patch: More or Fewer Messages.
4869 * invoking patch: Invoking patch.
4871 * keyboard input to patch: patch and Keyboard Input.
4886 * messages from patch: patch Messages.
4894 * options for patch: patch Options.
4899 * overview of diff and patch: Overview.
4901 * patch consumer tips: Tips for Patch Consumers.
4902 * patch input format: patch Input.
4903 * patch invocation: Invoking patch.
4904 * patch messages and questions: patch Messages.
4905 * patch options: patch Options.
4906 * patch producer tips: Tips for Patch Producers.
4907 * patch, common mistakes: Avoiding Common Mistakes.
4911 * patching directories: patch Directories.
4916 * POSIX: patch and POSIX.
4917 * POSIXLY_CORRECT <1>: patch and POSIX.
4920 * quoting style: patch Quoting Style.
4921 * QUOTING_STYLE: patch Quoting Style.
4950 * testing patch: Dry Runs.
4955 * traditional patch: patch and Tradition.
4960 * verbose messages from patch: More or Fewer Messages.
5032 Node: Merging with patch92503
5033 Node: patch Input94867
5043 Node: patch Directories110328
5048 Node: patch Messages116660
5050 Node: patch and Keyboard Input118319
5051 Node: patch Quoting Style119332
5052 Node: patch and POSIX120464
5053 Node: patch and Tradition121290
5065 Node: Invoking patch149255
5066 Node: patch Options150455