Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
8 user(s) are online (7 user(s) are browsing encyclopedia)

Members: 0
Guests: 8

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Patch (Unix)

patch is a Unix computer program that updates text files according to instructions contained in a separate file, called a patch file . The patch file (confusingly also called patch for short) is a text file that consists of a list of differences and is produced by running the related Diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.

=History=

The original patch program was written by .

=Usage context=

Developed by a programmer for other programmers, patch was frequently used for updating of source code to a newer version. Because of this many people came to associate patches with usage in programs, whereas patches can in fact be applied to any text. It should be noted that patched files do not accumulate any unneeded cruft, which is what some people perceive based on the English meaning of the word; patch is as capable of removing text as it is of adding it. Patches described here should not be confused with Patch (computing) distributed by closed-source software manufacturers to update binary files containing the program to a new release.

=Patches in software development=

The diff files that serve as input to patch are readable text files, because of which they can be easily reviewed by humans before use. When more advanced diffs are used, patches can be applied even to files that have been modified in the meantime, as long as those modifications do not interfere with the patch. This is achieved by context and unified diffs surrounding each change with context , the text preceding and following the changed part. patch uses the context to locate the change independently of line numbers.

The above two features made diff and patch especially popular for exchanging modifications to free software. Outsiders can download the latest publically available source code, make modifications to it, and send them, in diff form, to the development team. Using diffs, the development team has the ability to effectively review the patches before applying them, and can apply them to a newer code base than the one the outside developer had access to.

Patches have been the crucial component of many source control systems, including CVS.

=Usage examples=

To apply a patch, one could run the following command in a shell:

$ patch < mods.diff

This tells patch to apply the changes to the specified files described in mods.diff. Patches to files in subdirectories require the additional -p number option, where number is 1 if the base directory of the source tree is included in the diff, and 0 otherwise.

Patches can be undone, or reversed, with the -R option:

$ patch -R < mods.diff

= Ports of patch =

Originally written for Unix and Unix-like systems, Patch has also been ported to Microsoft Windows and many other platforms.

= See also =

  • Diff
  • Patch (computing)
  • rsync
  • xdelta