Chapter 6
Although uncommon, you should also be on the lookout for the opposite of
feeping creaturism stagnation. Every module must change with time to remain
vital. Don't let a fear of wild growth prevent perfectly reasonable additions. After
all, seeing your module grow in ways you never anticipated is part of the fun of
open source development!
Working with Patches
Accepting code contributions from other developers means working with patches.
A patch is a text file that encodes the differences between two versions of the same
file. Patch files are meant to be used with the patch program, written by Larry Wall
(yes, that Larry Wall). Patch files are generated by the diff program.
5
diff looks at
two versions of a file and outputs the differences. For this reason, patches are often
called diffs, causing much confusion for the uninitiated.
A typical use of diff and patch is as a way to transmit a change to the source
from a developer to a maintainer. The developer uses diff to produce a patch file
that describes the changes made to the files. The patch file is then submitted to the
maintainer of the project, often by e mailing it to a mailing list or directly to the
maintainer. If the maintainer accepts the change, then he or she uses the patch
program to apply the changes described in the patch file. The end result is that the
change made by a developer is transmitted to the project maintainer without
requiring the entire set of changed files to be exchanged.
TIP The patch program is able to skip any leading junk in a file con
taining a valid patch. This means that developers can append patches
to e mails, and you can send the entire e mail to patch without needing
to manually extract the patch file! This is also why maintainers often
prefer patches to be appended to e mail rather than attached.
Creating a Single File Patch
The simplest type of patch describes changes to a single file. As an example, I'll
make a small change to the Data::Counter module introduced in previous
5. Most Unix systems come with diff and patch installed. If your system is missing these
utilities, you can find the GNU versions at http://www.gnu.org. Windows users can get diff
and patch by installing the CygWin toolkit available at http://cygwin.com. Note that patch is
an optional package, and you'll have to select it manually from setup.exe
144
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved