A patch is a record of changes made to a set of resources. Typically a patch will add a new feature, fix a bug, or add documentation to the project.
A popular means of creating a patch is by using diff, a tool that is commonly available on Linux and Unix systems.
Patches are often the preferred way to submit contributions to open development projects such as open source software, particularly when a project is using a centralised version control system (VCS) and the contributor does not have commit rights. Projects using a distributed version control system (DVCS) may prefer contributions to be submitted as pull requests.
When using patches, the contributor creates a patch and submits it to the project. The project maintainer can then inspect the changes and apply them to the main code base if they so choose.
Various tools are available to help with patches. These tools make it very easy to create and manage patches for project outputs such as source code and documentation.
Patches and patch management tools are the key to building an active community of contributors to an open development project.
Creating A Patch.When a contributor makes a change to the outputs of a project they do so by editing files available in a version control system. A version control system tracks changes to documents and source code over time.
However, there are a few steps that should be taken to maximise the chances of the patch being accepted by the maintainers of a project.
It is important that the contributor ensures that the patch complies with any documentation and coding standards adopted by the project.
It is also critical to thoroughly test changes against any test suites the project provides. Finally, each contribution should be clearly documented with, at a minimum, details on:
what it is intended to do
how it is implemented
how it is used
Once the contributor is satisfied that the patch is worthy of consideration by the project maintainers, a patch must be created.
Most Integrated Development Environments (IDEs) include a feature to generate a patch. There are also many tools you can install, providing command line or GUI interfaces to patch generation tools.
After running the chosen tool, one or more files will be produced. Collectively, these files describe the changes made in the contribution.
Often multiple files will be placed into a single archive file for ease of management. This archive is called a patch. It is this patch that a contributor submits to the project.
The actual submission process varies from project to project, but in all cases there will be a requirement to address the assignment of copyright or rights to use the IP contained within the patch.