Submitting Patches

This page describes the full process of submitting a patch to the AOSP, including reviewing and tracking changes with Gerrit.

Prerequisites

For contributors

Start a repo branch

For each change you intend to make, start a new branch within the relevant git repository:

$ repo start NAME

You can start several independent branches at the same time in the same repository. The branch NAME is local to your workspace and will not be included on gerrit or the final source tree.

Make your change

Once you have modified the source files (and validated them, please) commit the changes to your local repository:

$ git add -A
$ git commit -s

Provide a detailed description of the change in your commit message. This description will be pushed to the public AOSP repository, so please follow our guidelines for writing changelist descriptions:

A unique change ID and your name and email as provided during repo init will be automatically added to your commit message.

Upload to gerrit

Once you have committed your change to your personal history, upload it to gerrit with

$ repo upload

If you have started multiple branches in the same repository, you will be prompted to select which one(s) to upload.

After a successful upload, repo will provide you the URL of a new page on r.android.com. Visit this link to view your patch on the review server, add comments, or request specific reviewers for your patch.

Uploading a replacement patch

Suppose a reviewer has looked at your patch and requested a small modification. You can amend your commit within git, which will result in a new patch on gerrit with the same change ID as the original.

Note that if you have made other commits since uploading this patch, you will need to manually move your git HEAD.

$ git add -A
$ git commit --amend

When you upload the amended patch, it will replace the original on gerrit and in your local git history.

Resolving sync conflicts

If other patches are submitted to the source tree that conflict with yours, you will need to rebase your patch on top of the new HEAD of the source repository. The easy way to do this is to run

$ repo sync

This command first fetches the updates from the source server, then attempts to automatically rebase your HEAD onto the new remote HEAD.

If the automatic rebase is unsuccessful, you will have to perform a manual rebase.

$ git rebase master

Using git mergetool may help you deal with the rebase conflict. Once you have successfully merged the conflicting files,

$ git rebase --continue

After either automatic or manual rebase is complete, run repo upload to submit your rebased patch.

After a submission is approved

After a submission makes it through the review and verification process, Gerrit automatically merges the change into the public repository. The change will now be visible in gitweb, and others users will be able to run repo sync to pull the update into their local client.

For reviewers and verifiers

Reviewing a change

If you are assigned to be the Approver for a change, you need to determine the following:

If you approve of the change, mark it with LGTM ("Looks Good to Me") within Gerrit.

Verifying a change

If you are assigned to be the Verifier for a change, you need to do the following:

Downloading changes from Gerrit

A submission that has been verified and merged will be downloaded with the next repo sync. If you wish to download a specific change that has not yet been approved, run

$ repo download TARGET CHANGE

where TARGET is the local directory into which the change should be downloaded and CHANGE is the change number as listed in Gerrit. For more information, see the Repo reference.

How do I become a Verifier or Approver?

In short, contribute high-quality code to one or more of the Android projects. For details about the different roles in the Android Open Source community and who plays them, see Project Roles.

Diffs and comments

To open the details of the change within Gerrit, click on the "Id number" or "Subject" of a change. To compare the established code with the updated code, click the file name under "Side-by-side diffs."

Adding comments

Anyone in the community can use Gerrit to add inline comments to code submissions. A good comment will be relevant to the line or section of code to which it is attached in Gerrit. It might be a short and constructive suggestion about how a line of code could be improved, or it might be an explanation from the author about why the code makes sense the way it is.

To add an inline comment, double-click the relevant line of the code and write your comment in the text box that opens. When you click Save, only you can see your comment.

To publish your comments so that others using Gerrit will be able to see them, click the Publish Comments button. Your comments will be emailed to all relevant parties for this change, including the change owner, the patch set uploader (if different from the owner), and all current reviewers.

Using GitWeb to track patch histories

To view snapshots of the files that are in the public Android repositories and view file histories, use the Android instance of GitWeb.

Upstream Projects

Android makes use of a number of other open-source projects, such as the Linux kernel and WebKit, as described in Branches and Releases. For the upstream projects detailed below, changes should be made directly upstream. Such changes will be incorporated into the Android tree as part of the usual process of pulling these projects.

WebKit

All changes to the WebKit project at external/webkit should be made upstream at webkit.org. The process begins by filing a WebKit bug. This bug should use Android for the Platform and OS fields only if the bug is specific to Android. Bugs are far more likely to receive the reviewers' attention once a proposed fix is added and tests are included. See Contributing Code to WebKit for details.

V8

All changes to the V8 project at external/v8 should be submitted upstream at code.google.com/p/v8. See Contributing to V8 for details.