Upstreaming patches to AOSP

Using git

Generally, we recommend using git to push patches upstream over using repo as AOSP documentation recommends - using git directly makes it easier to work with multiple repositories, such as pushing to android.git.linaro.org and android-review.googlesource.com in parallel.

On this page, we assume you've checked out the code you're working on from android.git.linaro.org and you've already submitted patches to the Linaro tree. If you haven't submitted patches/worked with git and gerrit before, instructions can be found here.

Upstream AOSP's infrastructure is in many ways the same as Linaro's -- when submitting a change upstream, you'll also push to a gerrit instance and request code review there.

To submit to upstream gerrit, you first have to tell git where to find it: git remote add aosp https://android-review.googlesource.com/path/to/the/project.git, e.g. git remote add aosp https://android-review.googlesource.com/platform/bionic.git for Bionic.

Next, use git fetch --all to fetch new revisions from upstream's repository (which may be a few commits ahead of Linaro's mirror on the master branch).

Create a new branch that is based on upstream master for submitting: git checkout -b upstream aosp/master

Apply your patch -- if it is already applied on a Linaro branch, you can use git cherry-pick <revision> to get the patch into your new branch.

If you have multiple patches that depend on each other, cherry-pick or apply them all in order -- this will create a chain of depending patches in upstream gerrit. If you have multiple patches that are unrelated to each other (e.g. a "fix build" type patch followed by an optimization patch), submit them separately (cherry-pick one branch, submit, start over with the next patch) -- this makes sure one patch can be accepted even if the other is rejected.

Next, make sure everything looks ok and there were no merge conflicts - then submit the patch upstream: git push aosp upstream:refs/for/master (note that for now, AOSP only accepts patch submissions to the master branch -- if you think a patch needs to be applied to a release branch, push it to the master branch anyway and ask for backporting in the gerrit web ui).

The output of git push will include an URL with the gerrit web interface link to your submission. Visit that URL and make sure everything is ok. Add your tech lead as a reviewer in the form on the URL so we get notifications and know when there's a need to follow up.

Next, AOSP's build server will run an auto-test, and post feedback ("applies and merges on AOSP master, fails on internal" is the typically the worst feedback you can get -- it means everything is ok, but it conflicts with a change on the internal tree we don't have access to, so finding someone to review and port it will be harder). A while later (this can be anything from a few minutes to a few months), someone will manually look at the patch and add comments and/or decide whether or not to merge the patch. Please make sure you reply to any comments added by anyone other than the review bot in a timely manner. Rework patches as required (and also feel free to post comments explaining why you think your variant is actually better than what someone suggests in a comment).

Using repo

Please refer to the official documentation of repo -- the interesting commands are repo start and repo upload


CategoryAndroidTips

Platform/Android/Upstreaming (last modified 2015-06-05 11:00:30)