How to Make a Patch for an Open Source Project

One of the greatest advantages of open source is the ability to view and modify the source code. For programmers, this means diagnosing and fixing problems themselves instead of waiting for someone else to do it. In order to contribute this fix to the developers of the open source project, you need to send them a patch.

Things You'll Need

  • Software source code
  • Code management software (CVS or SVN)
  • Internet connection
  • Diff program
Show More

Instructions

  1. Make a Patch for an Open Source Project

    • 1

      Identify a problem or bug in a piece of open source software. This usually occurs as you're using the software. The program either crashes or behaves in an unexpected or unintended manner. Sometimes it's a matter of being able to visualize a better way of accomplishing something.

    • 2

      Download the source code. Since you're going to make a patch to send to the developers, you need the original code to write it. This is done with source code management software like Concurrent Versions System (CVS) or Subversion (SVN).

    • 3

      Go to the software's project page and click on "Code" if the developer is using CVS on SourceForge. Follow the directions for anonymous CVS access. This will allow you to download the developer source code from CVS.

    • 4

      Search the developer's website for instructions to download the source code if he is using a service other than SourceForge. If the instructions are not on the website, you will need to email the developer or a related mailing list for assistance.

    • 5

      Diagnose the problem without making any modifications. Now that you have the source code, you can find out where the software is breaking.

    • 6

      Copy every file you're going to modify to a temporary .old.* file. For example, if you were going to change "eval.c," you would copy "eval.c" to "eval.old.c." This keeps a record of the old file so the diff program has something to work from.

    • 7

      Get coding and fix the problem. It could be as simple as one-line fix, such as changing a function parameter or adding some parentheses to some arithmetic, or much more complicated. Sometimes you may need to rewrite an entire function.

    • 8

      Clean up your work to make the developer's job easier. Clean up any junk lines or comments you may have left while fixing the code and make sure your indentation and whitespace style is the same as the developer's. You should also be sure that you followed any naming conventions the developer used if you want your patch to be submitted. Not doing the cleanup means the developer may not have time to clean up your code and your patch will never be accepted.

    • 9

      Run the diff program. The diff program compares two files and records the differences between them. This will generate the patch, so later the patch program can add these changes to the developer's source code. For every file you modified, you need to run the diff program like this: "patch -uN eval.old.c eval.c > eval.patch"

    • 10

      Send the patch to the developer, emailing it to him in an attachment. The developer can download source from CVS, apply the patch and commit the changes. He will probably also add you to the credits if the software has any (usually located in the readme file).

Tips & Warnings

  • Development source code is different than the release source code. The release source code is in a known good state, but the development source code is changed as the developers are working on it. Be aware that since the source code is in an unknown state when you download the development source code, it may not even compile.

Related Searches:

Comments

  • Stanislaw Smetanin Aug 14, 2010
    Please, fix a blunder in the step nine, instead of patch contributor must use a diff utility: "diff -uN eval.old.c eval.c > eval.patch"
  • cybershadow Feb 23, 2009
    This how-to is wrong in several places. Points 3 and 4 should be a subpoint of point 2, as it's just a clarification (more of a nitpick). You do not need to make .old copies if you use source control, because "svn diff" and CVS's equivalent will generate a patch of all your edits. Often it's hard to "diagnose" a problem without modifying the source code - people often add/enable logging and other debugging code. Modern versions of the diff program allow comparing directories, which means that for non-SCM source distributions you can just back up the entire source folder, and not bother making .old files for everything you edit.
  • cybershadow Feb 23, 2009
    This how-to is wrong in several places. Points 3 and 4 should be a subpoint of point 2, as it's just a clarification (more of a nitpick). You do not need to make .old copies if you use source control, because "svn diff" and CVS's equivalent will generate a patch of all your edits. Often it's hard to "diagnose" a problem without modifying the source code - people often add/enable logging and other debugging code. Modern versions of the diff program allow comparing directories, which means that for non-SCM source distributions you can just back up the entire source folder, and not bother making .old files for everything you edit.

You May Also Like

  • How to create jacket patches

    Ever wanted a certain band's patch to sew on your jacket but can't find one? There's a very simple solution for this:...

  • How to Make an Eye Patch

    Pirates have never been more popular and a pirate is a great Halloween costume. No pirate Halloween costume is complete without an...

  • How to Make a Patch Cable

    Audio patch cables come in many varieties and costs from the RCS cables included with your CD player to the high dollar...

  • How to Make a Cat 5 Patch Cable

    Ethernet technology was developed and implemented in the late 1970s and early 1980s. Ethernet has undergone several revisions and operates on many...

  • How to Make Patches With an Embroidery Machine

    Creating really clean, slick embroidered patches almost requires professional equipment. Quality base cloth, fusing and laser cutting equipment are key concerns for...

  • How to Make a Custom Cloth Patch

    Patching clothing isn't just for repairs anymore. Make custom patches to embellish clothing as well as for patching up holes. Custom patches...

  • How to Make a Patch File

    Computer patches are files that contain corrected code and can be used to make changes or fix errors in already existing programs....

  • How to Download Software Patches

    There is a multitude of software available for computer users, everything from games, to operating systems to home recording software. If you...

  • How to Make Patches

    Children's clothing is so expensive these days, and children grow so quickly, that many families are looking to thrift stores and hand...

  • How to Paint Quikrete Vinyl Concrete Patcher

    Quikrete Vinyl Concrete Patcher is a fast-drying repair material for concrete surfaces, including driveways, walls and walkways. The substance spreads easily and...

  • How to Make Iron on Patches

    Iron on patches can be used to repair clothing by covering a rip, tear or hole. They can also be used to...

  • How to Test Differential Pressure Gauges & Manometers

    Testing a manometer or differential pressure gauge can prevent you from further using faulty equipment. Manometers, sometimes called differential pressure gauges, are...

  • How to Use a Patch for an Open Source Project

    Patches are a way to stay on the cutting edge of an open source software project. By using patches, you can fix...

  • How to Create Custom Patches Online

    Whether you'd like to adorn an article of clothing with a decorative patch or you'd like design a custom patch as a...

  • How to Make Custom Patches

    Covering over a hole in your clothing or adding decorative patches to jazz up the look of your plain clothing or accessories...

  • How To Patch an Ice Shelter

    Ice shelters keep you warm when ice fishing and can be stowed away easily when not in use just like a tent.....

  • How to Build a Subwoofer Box for Your Car

    Subwoofer boxes come in a variety of styles, including sealed, ported and bandpass. The sealed enclosure is probably the most widely used...

  • How to Make a Jean Jacket With Patches

    Learn how to make a fashionable denim jacket with patches.

  • How to Make Wood Veneer Furniture Patch

    Make old office furniture look new! Learn how to make wood veneer furniture patch to repair old furniture in this free woodworking...

  • How to Make a No-CD Patch

    Click "Start," then select the video game disk copy program from the "All Applications" menu. Click "File" at the top of the...

Related Ads

Featured