GNU Info

Info Node: (diff.info)patch Directories

(diff.info)patch Directories


Next: Backups Up: Invoking patch
Enter node , (file) or (file)node

Applying Patches in Other Directories
=====================================

   The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch'
makes directory DIRECTORY the current directory for interpreting both
file names in the patch file, and file names given as arguments to
other options (such as `-B' and `-o').  For example, while in a news
reading program, you can patch a file in the `/usr/src/emacs' directory
directly from the article containing the patch like this:

     | patch -d /usr/src/emacs

   Sometimes the file names given in a patch contain leading
directories, but you keep your files in a directory different from the
one given in the patch.  In those cases, you can use the `-p[NUMBER]'
or `--strip[=NUMBER]' option to set the file name strip count to
NUMBER.  The strip count tells `patch' how many slashes, along with the
directory names between them, to strip from the front of file names.
`-p' with no NUMBER given is equivalent to `-p0'.  By default, `patch'
strips off all leading directories, leaving just the base file names,
except that when a file name given in the patch is a relative file name
and all of its leading directories already exist, `patch' does not
strip off the leading directory.  (A "relative" file name is one that
does not start with a slash.)

   `patch' looks for each file (after any slashes have been stripped)
in the current directory, or if you used the `-d DIRECTORY' option, in
that directory.

   For example, suppose the file name in the patch file is
`/gnu/src/emacs/etc/NEWS'.  Using `-p' or `-p0' gives the entire file
name unmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading
slash), `-p4' gives `etc/NEWS', and not specifying `-p' at all gives
`NEWS'.


automatically generated by info2www version 1.2.2.9