Agaric Design Collective

How to make patch files to contribute to contributed modules

By Benjamin Melançon
on 28 Oct
1 comment

Key words and phrases

create patches for drupal modules run diff drupal make a patch

Tags

Description

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.

 

For going the other way, see
Posted by Benjamin Melançon on Sun, 2007-10-28 16:24
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.