|Comparing and Merging Files with GNU diff and patch|
by David MacKenzie, Paul Eggert, and Richard Stallman
Paperback (6"x9"), 120 pages
RRP £12.95 ($19.95)
"Well packaged... the quality of information is excellent" --- Linux User and Developer Magazine (Issue 36, Feb 2004) Get a printed copy>>>
10.6 Multiple Patches in a File
If the patch file contains more than one patch, and if you do not
specify an input file on the command line,
patch tries to
apply each patch as if they came from separate patch files. This
means that it determines the name of the file to patch for each patch,
and that it examines the leading text before each patch for file names
and prerequisite revision level (see section 11 Tips for Making and Using Patches, for more on
patch uses the following rules to intuit a file name from
the leading text before a patch. First,
patch takes an
ordered list of candidate file names as follows:
If the header is that of a context diff,
patchtakes the old and new file names in the header. A name is ignored if it does not have enough slashes to satisfy the
--strip=numoption. The name ‘/dev/null’ is also ignored.
If there is an ‘Index:’ line in the leading garbage and if either
the old and new names are both absent or if
patchis conforming to POSIX,
patchtakes the name in the ‘Index:’ line.
- For the purpose of the following rules, the candidate file names are considered to be in the order (old, new, index), regardless of the order that they appear in the header.
patch selects a file name from the candidate list as
If some of the named files exist,
patchselects the first name if conforming to POSIX, and the best name otherwise.
patchis not ignoring RCS, ClearCase, and SCCS (see section 10.2 Revision Control), and no named files exist but an RCS, ClearCase, or SCCS master is found,
patchselects the first named file with an RCS, ClearCase, or SCCS master.
If no named files exist, no RCS, ClearCase, or SCCS master
was found, some names are given,
patchis not conforming to POSIX, and the patch appears to create a file,
patchselects the best name requiring the creation of the fewest directories.
If no file name results from the above heuristics, you are asked for
the name of the file to patch, and
patchselects that name.
To determine the best of a nonempty list of file names,
patch first takes all the names with the fewest path name
components; of those, it then takes all the names with the shortest
basename; of those, it then takes all the shortest names; finally, it
takes the first remaining name.
See section 10.12
patch and the POSIX Standard, to see whether
patch is conforming
|ISBN 0954161750||Comparing and Merging Files with GNU diff and patch||See the print edition|