Home | Press | Mailing List | Documentation | Screenshots | People | SourceForge | Downloads |
Please send patches to SourceForge Patches.
Patches are files created using diff that list only the changes between two sets of files. Using the patch command you can then migrate those differences to another copy of the same source. This is an alternative to using CVS to check-in changes made to a group project.
For discussion here we will assume that we are working on Film Gimp version 0.7. We have an original untouched copy in a directory called filmgimp-0.7, and our new copy with changes in a directory named filmgimp-0.7-new. We've made changes that we wish to apply to filmgimp-0.16.
Our first step is to make clean to eliminate as many unnecessary files as we can from filmgimp-0.7-new.
$ cd filmgimp-0.7-new
$ make clean
Next let's see what new files we have added, the "onlies" that are new files.
$ diff -qr filmgimp-0.7 filmgimp-0.7-new |grep "Only in" > fg7.onlies.txt
Some of the files listed will likely be intermediate output that didn't get deleted by make clean and need to be removed by hand. This is particularly the case for Makefiles generated by configure. (To see both onlies and the names of files that differ, leave off piping through grep in the command above.)
During our development we did some housekeeping to move files to different directories. Normally we wouldn't want to do this, because it creates extra work to straighten out when patching. Using our onlies list we create a mv script to rename files that we moved to different directories. We create mv_up.sh and its inverse, mv_down.sh.
$ cd filmgimp-0.7
$ sh ../mv_down.sh
Now we're ready to make our patch:
$ diff -aur --strip-trailing-cr filmgimp-0.7 filmgimp-0.7-new > fg7.patch
Because we're working with *nix files that we modified in Windows we need to strip off the trailing carriage returns inserted by Windows. Our patch is stored as fg7.patch. We're going to apply this to filmgimp-0.16. Because that's changing 0.16 we've named our directory filmgimp-0.16-new.
To appy our patch:
$ cd filmgimp-0.16-new/
$ patch -p1 < ../fg7.patch > ../fg7.txt
$ grep "saving rejects" fg7.txt > fg7.rejects.txt
The results of our merge are in fg7.txt. It lists several problems that must be fixed manually. Note that one of the rejects listed here was due to the file to be patched no longer existing in the new version. For convenience, we've used grep to list the rejected hunks in fg7.rejects.txt.
We need to copy our filmgimp-0.7-new/win32 directory manually to filmgimp-0.16-new. It wasn't included in the patch because it didn't exist before. After applying our patch we need the extra step of using our mv script to rename files we had moved back into the correct locations.
$ cd filmgimp-0.16-new
$ sh ../mv_up.sh
Once these problems are corrected we'll repeat the process to create a patch against the original 0.16.
$ diff -aur --strip-trailing-cr filmgimp-0.16 filmgimp-0.16-new > fg16.patch
This demonstrates how to catch up with the current version so we have a current patch.