Applying patches on Mac OS X
Command Line, or GUI?
The patch program is included with Mac OS X, but you need to use it from the command line via Terminal.app. See HowTo: Apply patches for details on how to use patch.
If you'd rather use a GUI solution, check out Apple's Xcode Tools. Note that you'll have to signup as a 'developer', but there's no charge to do so.
Applying the patch using Terminal
Open your Mac's Terminal application, which can be found in the Applications > Utilities folder. You'll see an open window called a shell that reads something vaguely like this:
Last login: Thu Jan 4 13:59:50 on ttyp1
Welcome to Darwin!
Administrators-Computer:~ admin$Using the 'cd' command, navigate to the module folder that contains both the example.module and the newly downloaded example.patch file.
(e.g. "cd ~/Users/Sites/drupal5/sites/all/modules/example_module/")
Hint: You can drag a folder or a file from any Finder window onto the Terminal window, and the pathname will be auto-filled for you. Just type "cd " (note the space), and then drag your desired folder/file onto the Terminal window. This method saves a *lot* of typing, and the possibility of misspelled folder names during this process.
Once you're in the correct folder, run this command using the exact name of the patch file:
$ patch < example.patch
(note: don't type the dollar sign. That's the command line prompt.)And voila! Terminal says something like "file patched" and then moves one line down to a new $ prompt (which is Unix' way of being really, really excited that something worked.) The original files are now patched and ready for action. Yep, it's just that easy! You can now close the Terminal window and go pour yourself a well-deserved drink.
Aditional Reading Material
Apple's User Manual on the patch command has some good info as well. http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/
1. use --dry-run after the command to see what will happen without actually making any changes -- for instance,
patch < the_patch_file.patch --dry-run2. use -b to always make a backup of the original file (the default behavior is to only make a backup if there was a problem). The backup will have the suffix ".orig".
3. You can always type "patch --help" to see more options, such as how to change the backup suffix.
