www.delorie.com/gnu/docs/diffutils/diff_61.html   search  
 
Buy GNU books!


Comparing and Merging Files

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10. Merging with patch

patch takes comparison output produced by diff and applies the differences to a copy of the original file, producing a patched version. With patch, you can distribute just the changes to a set of files instead of distributing the entire file set; your correspondents can apply patch to update their copy of the files with your changes. patch automatically determines the diff format, skips any leading or trailing headers, and uses the headers to determine which file to patch. This lets your correspondents feed a mail message containing a difference listing directly to patch.

patch detects and warns about common problems like forward patches. It saves any patches that it could not apply. It can also maintain a patchlevel.h file to ensure that your correspondents apply diffs in the proper order.

patch accepts a series of diffs in its standard input, usually separated by headers that specify which file to patch. It applies diff hunks (see section 1.1 Hunks) one by one. If a hunk does not exactly match the original file, patch uses heuristics to try to patch the file as well as it can. If no approximate match can be found, patch rejects the hunk and skips to the next hunk. patch normally replaces each file f with its new version, putting reject hunks (if any) into `f.rej'.

See section 15. Invoking patch, for detailed information on the options to patch.

10.1 Selecting the patch Input Format  Selecting the type of patch input.
10.2 Revision Control  Getting files from RCS, SCCS, etc.
10.3 Applying Imperfect Patches  Dealing with imperfect patches.
10.4 Creating and Removing Files  Creating and removing files with a patch.
10.5 Updating Time Stamps on Patched Files  Updating time stamps on patched files.
10.6 Multiple Patches in a File  Handling multiple patches in a file.
10.7 Applying Patches in Other Directories  Changing directory and stripping directories.
10.8 Backup Files  Whether backup files are made.
10.9 Backup File Names  Backup file names.
10.10 Reject File Names  Reject file names.
10.11 Messages and Questions from patch  Messages and questions patch can produce.
10.12 patch and the POSIX Standard  Conformance to the POSIX standard.
10.13 GNU patch and Traditional patch  GNU versus traditional patch.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003