git commit author - give credit where credit is due

Quite some time ago I wrote a post about how patching makes you feel good in which I talked about the motivations for, and benefits of submitting patches on drupal.org (d.o). I concluded by suggesting that project maintainers should be generous in recognising the efforts of those who submit patches.

Well, now that d.o has its magnificent git infrastructure, project maintainers have even better tools for giving credit to contributors who help fix or improve the code. There is still the well-established convention for commit messages which encourages that "others [who] have contributed to the change you are committing" are credited by name. e.g.

Issue #123456 by dww, Dries: Added project release tracking.

Similar messages are often added to the project's changelog too.

The new tool that perhaps not everyone knows about yet is the ability to assign the authorship of the commit to another user e.g.

git commit --author=[username]@[uid].no-reply.drupal.org

This is appropriate when committing a patch that is entirely somebody else's work. Perhaps some maintainers will be generous and attribute authorship even if they've had to make a few tweaks to the patch, but somebody else did the majority of the work to identify and fix a bug, for example.

When a user is credited as the author in this way, the commit will show up on their drupal.org profile page, which I think many people will feel is a great reward for the time they spent putting a patch together.

There are however some limitations and drawbacks to the system. The committer of the patch is not rewarded by seeing their commit count incremented, which some may find a disincentive for generosity in attributing authorship.

Where the maintainer might split the credit in a commit message for a fix where a user was helpful by giving a detailed bug report in the issue queue, but where they themselves had to actually fix the problem, for example, they're probably justified in leaving themselves as the author of the commit. Of course they can still mention the helpful user in the commit message and changelog.

There will surely also be less monochrome cases where authorship of the code being committed should be split between multiple users. As far as I'm aware, the git infrastructure on d.o doesn't cater for this situation, and messy workarounds such as breaking the commit up to split authorship have been suggested.

There are undoubtedly some limitations, and project maintainers will occasionally find themselves with tricky decisions to make. However, for the reasons I detailed in my patching makes you feel good post, I really encourage maintainers to be generous with the credit when it comes to patches which have been submitted in issue queues, and the option to set an author for a commit in git is a great way of doing so.

Comments

Nice to see

I recently brought this to a module maintainer's attention when he wasn't atrributing authors to commits, so I'm glad to see a blog post about it. The aforementioned maintainer has said that he will ensure to give credit where it's due in future. Well worth it.

Rewrite history

With Git, it's possible to retroactively reassign credit (using git filter-branch). It's easy to rewrite history!
(I used this on d.o. after committing a module using the git email address 'root@localhost' - fail!)

that's interesting - I wonder

that's interesting - I wonder whether the d.o. mechanisms I mentioned (commit counts and commits showing up on user profiles) would pick up on re-written history?

They do

They do - my commit-count and profile pages updated when I fixed the broken email address on my module :-)

Problems?

This is where my knowledge of git gets a little dicey. I know that there are some changes like this one that a maintainer should not do once the commit has been pushed to a remote repo (like d.o), because they do alter the commit history and could cause problems for other people that have a checkout of that repo. I could have sworn that Randy Fay wrote about this shortly after git was rolled out on d.o, but I can't seem to find it now.

Great Article

For last 2+ years I've been creating custom drupal projects and using contributed modules.

I just recently started the process of getting a new Drupal 7 project approved to become a full project...and I can now totally say that I agree with you on this topic. Contributing to the community that has provided so much to the company I work for and to myself as a PHP programmer, feels REALLY good. I also like to see people contributing patches to my work and giving them credit, because I know it took time for them to do it and I appreciate them using my module.

I enjoyed the article! Thanks for sharing.

Commit count?

"There are however some limitations and drawbacks to the system. The committer of the patch is not rewarded by seeing their commit count incremented, which some may find a disincentive for generosity in attributing authorship."

Do people really care about that? I suppose maybe someone who is only supplying patches and doesn't have their own project might, since it's more of a novelty. But, if you have your own project, you can make your commit count as high as you want just by committing a lot. LOL! I can't imagine being bothered by missing out on one for committing someone else's patch... Maybe I'm just weird. :)

I think a bigger issue for me would be remembering to do it, since it's different from the normal way I'm used to doing it.

Michelle

Agreed

I thought the same thing. If a maintainer is that concerned with their stats, they probably aren't the type to accept input from others anyway. And I'm thankful for this post for the second point: one tends to get into a flow (patch, review, commit, push, go!) and I appreciate the reminder that credit can be given this way.

Shortcut

For module maintainers who want to make use of this method, there's a quick and easy way to do it. Click on the name of the user who submitted the patch to see their d.o profile, and scroll down to Git attribution. The --author flag you'll need to give them credit is right there for you to copy!

It would be best if everyone

It would be best if everyone just started doing things properly:
create patch with git format-patch and apply it with git am. Among
other gained bonuses, the author would get credit automatically. I try to encourage people to do this when i commit patches, but so far people usually just have ignored the request.