Formatting patches for drupal.org projects
I always end up wasting time referencing the “proper” way to format patches on d.o. against how I’ve done it, so here’s a quick summary for my future self.
Repository configuration
Set up Drupal repositories with the appropriate d.o username information.
git config --local user.name {d.o username}
git config --local user.email {d.o git attribution email address}
Patch naming
D.o unofficially uses the following patch naming convention:
[project_name]-[short-description]-[issue-number]-[comment-number].patch
However, most of the patches I submitted for Workbench Access (with agentrickard) have been formatted using the following convention :
[issue-number]-[comment-number]-[project_name]-[short-description].patch
I prefer putting the issue number first, but following a maintainer’s convention should always trump my personal preference.
Creating patches
git format-patch --stdout > {patch naming convention}
Git’s format-patch uses the author information from the commit, so its important to take a quick glance at the patch’s head before submitting it.