How to make patches

From gvSIG CE Wiki

Jump to: navigation, search

If you are new to developing (for gvSIG CE), and you would rather not want to mess with the files in the SVN, or you only contribute code on an irregular basis and do not want/have an SVN account, you can create patches and send them to the developers mailing list instead. This way, other people can have a look at your code first, before they integrate them with the sources in our SVN.

Creating a patch is easy. All you need is a little tool called "diff". If you have followed the instructions on the page about Setting up the GNU Compiler Collection then you are ready to go.

To create a patch for a single file, simply copy the old and the new version of the file into your current directory and do:

 diff -uN <old-file> <new-file> > my_patch.diff

The resulting patch will be in the file my_patch.diff. That file will contain only the changes between the old and new version, in an easy-to-read format.

If you have a whole bunch of files with changes (a patch set), you can create a single patch file for all of them. If the files are stored in different directories, then you must recreate that directory structure for all the old and new files before using "diff".

E.g., you could create a directory old and a directory new in your current directory. You would then copy all original and changed files into the respective directory, creating all the sub directories leading up to them as necessary.

You would then run diff recursively, from the root directory of the patch set:

 diff -uNr old new > my_patchset.diff

More information on using "diff" is available here.

Alternatively, you can create patches of your local changes against the version of a file in SVN using Eclipse. See this page for instructions.