Last updated March 7, 2014. Created by marvil07 on May 4, 2011.
Edited by tr2012, Kolin, gobinathm, mdsami. Log in to edit this page.

Git helps us to give better attribution for code contributors.

How it happens

A commit has two roles involved: author and committer.

The author is the one who makes the changes, and the committer is the one who adds those changes to the repository. Naturally, each of them can be separate identities.

How to give authorship attribution from a patch

The way to give the author attribution depends on how the patch was created.

The patch is git aware

The author has created the patch with git format-patch, a command that includes git metadata in the patch. You must make sure you have configured your git global or project email address to match one of the ones in your Drupal profile OR the anonymous style "UserName@353190.no-reply.drupal.org" address seen on your profile page.

When using git format-patch it is a good idea to use Dreditor to create the commit message as it allows the format many maintainers prefer and it will give them more incentive to apply these types of patches directly.

When posting your patch make sure to specify that you created an advanced patch with git format-patch and that the patch should be applied with git am <patch-name> to apply your patch.

The patch is a common patch

In this case, the author has used another method like the diff command, or the patch has been applied with git apply, so there is no git metadata.

In this case, the author's drupal.org user name can be used for attribution.

  1. Apply the patch with your common method
  2. Stage changes to be committed
  3. Commit, using the author option with an anonymous email address of the form “[username]@[uid].no-reply.drupal.org”, for example
    git commit --author="scor <scor@52142.no-reply.drupal.org>"
    The exact option to use can be seen in the author's user profile or you can use Dreditor to create the commit message exactly according to Drupal standards and specify one --author to the commit (highly recommended).

For more details on using git commit, check the related page Maintaining a Drupal.org project.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

1) How do I know which way the patch was created?

2) If I am supposed to do the second option, where do I get the author's email address? Does this mean I have to go contact the author and ask them to send me their email address before I can commit a fix?

3) These instructions are not the same as the 'Git Instructions' tab that is displayed on every project page. I know where those instructions are and I follow them. If I'm supposed to do something different those instructions should be changed. I should not have to search around d.o. for alternative instructions and then try to figure out which one is right.

(I've never contributed any documentation, so I'm not sure if it's acceptable to modify the page to address these questions. Writing this to be general enough to be included on the page.)

  1. You can tell that a patch was generated by git format-patch based on the contents of the patch. format-patch results in a patch file that beings kind of like an email:

    From cce664e76d817492c3755bd2d2e35bab0efa20f1 Mon Sep 17 00:00:00 2001
    From: Brock Boland <brock@brockboland.com>
    Date: Mon, 4 Jul 2011 18:37:11 -0400
    Subject: [PATCH] Fixing a typo
    # (Followed by the diff)
  2. To get the author's anonymous email address, you need to combine their Drupal.org username with their user ID. In the issue where the user posted the patch, click on their username. Their user ID is in the URL, following /user/. To determine what you should use for --author in the commit command, just put it together, replacing username and userid in this example:

    username <username@userid.no-reply.drupal.org>
  3. I think that this information should be included in the Version Control information for each project, so that patch submitters get proper credit in the repo.

I totally agree with that, we should have the same info in version control tab and in the rest of the documentation.
Proper attribution of patches and commits is now easier than ever and we should take advantage of it.

Karen, you have now the --author string to use for commits in the user profile of each user, i.e.
--author="karens <karens@45874.no-reply.drupal.org>"

But I think that if several people is involved in a single patch, the right way to give attribution is with git format-patch and am.

How exactly can you do that, crediting authorship to multiple people? (Other than splitting the commit into several parts.) I think (unless this is possible) that's a major disadvantage of the new system, compared to just listing the authors in the commit message.

I think git --notes is more of a candidate for this http://groups.drupal.org/node/161659

I find there are several problems with this:

1. How do I find who actually made a commit? Eg, suppose a commit caused a problem and I want to let the committer know so they don't repeat the mistake.

2. The list of project maintainers now lists all commit authors. The result is that I appear to maintain a ton more projects than I actually do!

There is a quick way for patch contributors to make it easier for the committers.

See http://www.metaltoad.com/blog/quick-tip-receiving-git-attribution-your-d...

The maintainers of the larger modules (e.g. Organic Groups) seem to have this figured out, and will give you authorship automatically, even for the smallest fixes (bless them). But I find that many don't do it at all. As a result our commits log isn't even remotely representative of our actual contributions.

These incentives are important - to our team and the community at large. I'm wondering if there is anything that be done to increase general awareness of this issue so that contributors don't become discouraged and abandon projects because they aren't getting due credit. It isn't enough to tell people to ask for it.

Is this being discussed anywhere, maybe in groups?