This article is about how to make patches for maintainers and how to apply patches if you are a maintainer.
Over time, people download copies of that directory for their own use and for whatever reasons may be inclined to make a few changes that they would like to share with the rest of the world by making a contribution to the original source base.
However, there's a problem. The original source base may have changed and a number of other people may have gotten the same idea.
It's up to the maintainer to take all these different versions, munge them into a new version, and redistribute. It can be a lot of hard and tedious work, and that's why its important to lessen the burden on a maintainer in order to improve the changes of your submission getting accepted.
What's important to note is that this "difference file", also called a patch file tells how to convert one version to the other. It isn't one-way!
This means that changes made can be backed out again.
Let's assume that you downloaded a program, untared it, and it's now sitting in a subdirectory called original. You're going to keep this copy around as the master copy from which to make comparisons.
Duplicate the directory exactly and do all your changes in your own copy.
Be sure to clean up any temporary files, object files, map files, executable files, core files, and anything else the maintainer didn't have out there. The best way to tick off a maintainer is to send them junk.
Here's how to make a unifed diff against a single file which can be used for patching one version to the other.
You can now use this new file to convert either version to the other. If you're going to validate your patch, and you should, do so on another copy of original.
$ cd origcopy $ patch -p1 < ../mypatch The original version should now be patched to match your version. Care to back the change back out again?
$ patch -R -p1 < ../mypatch |
$ cd myversion $ patch -p1 < ../mypatch Your version, at this point, would be patched back to look like the original. Care to back the change back out again?
$ patch -R -p1 < ../mypatch |
You may be asking at this point, "what's the -p1 for?" As you recall, you made the patch file from a directory above the sources. This means the patch file contains the subdirectory names in them, which is exactly what you want, because it lets the maintainer you're submitting a patch to know what he's looking at.
However, when the actal patching process takes place, the first (and hence the '1') pathname needs to be striped to get to the real filename.
You should be all set to email the maintainer with a description of your patch (what it does and how, including which version of the code your patch should be applied against), and the patch as an attachment.
Two additional thoughts. One, if the patch file is big, compress it first. Two, download the latest version (it may have changed while you were working), apply your patch against it, so you see exactly what the maintainer will see, and make sure it works before mailing.
Read of the description, read over the patch changes themselves, and if agreeable, apply the patch to the files. It's possible to do a dry run first, which makes sure the patch applies cleanly before you really do it.
Rebuild and test the changes don't break anything, then redistribute, committing the changed version to the master copy.
It's always a good idea to send an email back to submitters so that they know their efforts are appreciated, so that they'll stop resubmitting duplicate patches (which can happen if you're slow to incorporate changes), and so that they can grab a new version and verify for themselves things went according to plan.
It's also polite to give submitters credit in some text file
associated with the project.
![]() |
•••About •••Articles •••Links •••Search Tips |