Original author(s) | Larry Wall |
---|---|
Developer(s) | Paul Eggert, Wayne Davison, David MacKenzie, Andreas Grünbacher |
Initial release | May 24, 1985; 34 years ago |
Repository | |
Operating system | Unix and Unix-like, MSX-DOS, Microsoft Windows |
Type | Command |
Website | savannah.gnu.org/projects/patch/ |
How to upload Subversion diffs of binary files? Answer To upload arbitrary Subversion diffs, Collaborator Client executes the svn diff command and parses its output. Declares that there is a binary conflict and contains the information to apply it as parsed from the file. Since New in 1.10. Definition at line 1290 of file svndiff.h.
The computer tool patch is a Unixprogram that updates text files according to instructions contained in a separate file, called a patch file. The patch file (also called a 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.
- 3Patches in software development
History[edit]
The original patch program was written by Larry Wall (who went on to create the Perl programming language) and posted to mod.sources[1] (which later became comp.sources.unix) in May 1985. A variant of the program (but not the only one)[2][3][4] is part of the GNU project[5] and is maintained by the FSF.
Usage context[edit]
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 source code, whereas patches can in fact be applied to any text. Patched files do not accumulate any unneeded text, 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 binary patches, which, although can be conceptually similar, are distributed to update binary files comprising the program to a new release.
Patches in software development[edit]
The diff files that serve as input to patch are readable text files, which means that they can be easily reviewed or modified by humans before use.
In addition to the 'diff' program, diffs can also be produced by other programs, such as Subversion, CVS, RCS, Mercurial and Git.
Patches have been the crucial component of many source control systems, including CVS.
Advanced diffs[edit]
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 using 'context diffs' and 'unified diffs' (also known as 'unidiffs'), which surround each change with context, which is the text immediately before and after the changed part. Patch can then use this context to locate the region to be patched even if it has been displaced by changes earlier in the file, using the line numbers in the diffs as a starting point. Because of this property, context and unified diffs are the preferred form of patches for submission to many software projects.
The above features make diff and patch especially popular for exchanging modifications to open-source software. Outsiders can download the latest publicly 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.
Usage examples[edit]
To create a patch, one could run the following command in a shell:
To apply a patch, one could run the following command in a shell:
This tells patch to apply the changes to the specified files described in mods.diff. Patches to files in subdirectories require the additional -pnumber 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:
In some cases when the file is not identical to the version the diff was generated against, the patch will not be able to be applied cleanly. For example, if lines of text are inserted at the beginning, the line numbers referred to in the patch will be incorrect. patch is able to recover from this, by looking at nearby lines to relocate the text to be patched. It will also recover when lines of context (for context and unified diffs) are altered; this is described as fuzz.
Ports of patch[edit]
Originally written for Unix and Unix-like systems, patch has also been ported to Windows and many other platforms. Windows ports of patch are provided by GnuWin32 and UnxUtils.
A
patch
command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.[6]See also[edit]
- IBM Mainframe utility IEBUPDTE a mainframe patch program, created about 20 years earlier (circa ~1964).
References[edit]
- ^Larry Wall (May 24, 1985). 'patch version 1.3'. Google.com at mod.sources.
- ^http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/patch/ OpenBSD patch source
- ^https://sourceforge.net/projects/schilytools/files/ A version of patch exists in the Schily tools collection
- ^A version of patch is maintained by IBM, Oracle and the Open Software Foundation
- ^'Patch - Free Software Directory'. Free Software Directory. Free Software Foundation. 2010-05-01. Retrieved 2016-05-25.
- ^MSX-DOS2 Tools User's Manual by ASCII Corporation
External links[edit]
- https://ftp.gnu.org/gnu/patch/ - Source code
patch
– Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group- 'patchutils'. Freecode. – Additional utility programs for manipulating patches
- GNU tools for Win32 – Win32 port of tools, including diff and patch
- diffstat – show statistics from output of diff
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Patch_(Unix)&oldid=924512642'
Binary diff and patch programs for the Windows command line.
Introduction
BDiff computes differences between two binary files. Output can be either a somewhat human-readable protocol in plain text, or a binary file that is readable by BPatch.
BPatch applies a binary patch generated by BDiff to a file to recreate the original file.
See the files
BDiff.txt
and BPatch.txt
in the Docs
directory for details of how to use the programs.BDiff and BPatch are derived from Stefan Reuther's bdiff and bpatch v0.2 and a later bug fix by Stefan.
The original C source was translated into Object Pascal by Peter D Johnson (@delphdabbler). The programs are are based on updates of the Pascal code base.
The programs should run on any current version of Windows.
For more information see the see the project web pages.
Installation
Copy the provided executable files to the required location. No further installation is required.
You may want to modify the Windows PATH environment variable to include the location of the programs.
To uninstall simply delete the programs. They make no changes to the system. If you changed the PATH environment variable you may wish to adjust this.
Tests
You can test the operation of BDiff and BPatch using the
Test.bat
script in the Test
directory. See ReadMe.txt
in that directory for details.Source Code
Pascal Source
The current source code is maintained in the delphidabbler/bdiff Git repository on GitHub. It contains releases going back to v0.2.5. Earlier versions were not under version control and are no longer available.
Note: Until February 2014 the source code was maintained in a Subversion repository. A dump of the repo is available from Google Drive.
For information on how to build the Pascal source, see
Build.txt
in the root of the Git repo.C Source
The original C source code can be downloaded from http://phost.de/~stefan/Files/bdiff-02.zip.
Copyright and License
See the file
LICENCE.md
for details of copyright and the license that applies to this software.Change Log
The change log is provided in the file
CHANGELOG.txt
.