User login

How to make patch files to contribute to contributed modules

These instructions assume a GNU-Linux, Mac OS X, or other UNIX-y computing environment.

Follow these instructions for using CVS:

http://drupal.org/patch/create

However, if you are making a patch for a contributed module rather than Drupal core, going to the Drupal root directory doesn't make sense.

For a change to a single file (not adding or removing a file), you can just make a copy of the original file, call your new file _original and list the file you change (the one without a rename in this case) second in the diff command.

And create the actual patch from within the module directory:

diff -up token_node_original.inc token_node.inc > token_5_reroll.patch

For a patch that affects multiple files:

First make sure you have an unblemished copy to compare to:

cd ~
ben@ebony-ubuntu:~$ drush dl hierarchical_select-5.x
Project hierarchical_select (5.x-3.0-rc7) downloaded to /home/ben/.

Now go back to the directory where you edited the project, for instance cd /path/to/project/sites/all/modules/hierarchical_select and:

diff -urp . /home/ben/hierarchical_select > hierarchical_select_fix_plus_gmix_tweak.patch

Note both of the above would be easier with cvs diff (no name or keep or fetch the original files, because it will compare directly to the central repository) if you have the foresight to check the project out of CVS before you begin working.

See also: recommended patch naming conventions.

Resolution

Searched words: 
create patches for drupal modules run diff drupal make a patch

Comments

For going the other way, see

For going the other way, see Agaric's how to apply a patch to a Drupal module.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.