Quick Tip: Receiving Git Attribution for Your Drupal.org Patches

If you contribute patches to the Drupal issue queues, you often spend a lot of time and hard work getting that patch through the review process. Even though we do it for the good of the community, once it is all said and done, it's nice to get a little acknowledgement. While there is a page for module maintainers on how to properly attribute contributions to users, not all maintainers know about that, and it can often mean they have to spend a little extra time figuring out what your Drupal.org git email address is. But there is a quick way for us as patch contributors to make that easier for them.

Once you clone a contrib module repo, you should set the user.name and user.email for that repo and then use git format-patch when creating your patch.

git config --local user.name jojonaloha
git config --local user.email jojonaloha@1579186.no-reply.drupal.org

If you want to use these by default you can use the --global flag instead.


It's probably also worth mentioning that Dreditor creates a "Create commit message" feature in the issue queue to craft an appropriately attributed Git commit.

some maintainers have been kind to attribute my patches to me (both of them?) - these instructions make that easier, thanks Jonathan!

Just a heads up that it can be helpful to mention in the queue when you've used the format-patch command instead of standard diff.

I started using format-patch soon after the switch to git and people didn't realize that it separates your work into discrete commits within the file. While this separation is cool (and allows original authors of re-rolled patches to retain their credit too!), if someone wants to visually review the patch, they may consider it incomplete unless you instruct them to actually apply it then look at the full diff.

While format-patch output with multiple patches is sometimes used in the issue queue, it is more common for folks to go with the easier-to-read single-patch attachments. You can still create this kind of patch, with all changes rolled into a single diff, with git format-patch; however, doing so requires that you create a new branch first, and then use git merge --squash to merge and combine the commits together. If you use drush iq-diff, it will automatically squash your commit before creating it with format-patch, so you will get an easy-to-read patch file that also contains commit credit. Even better, if you use the new drush iq-submit command, it will also create an interdiff for you.

For a description of the Drush IQ workflow, see: http://drupalcode.org/project/drush_iq.git/blob_plain/refs/heads/7.x-1…

Good info on how to make it work... but finding notes on how to properly use git format-patch is proving crappy!

So I found the documentation out there for how to properly use git format patch rather spares, and not particularly applicable to our situation. Using your article, and another article (http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/) I was able to figure out the proper way to generate everything. I wrote a blog post on it.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Ready to get started?