blob: 24a59a27e1592291d2d47f930b48f69c7589ac4c [file] [log] [blame] [view]
Skyler Kaufman44436912011-04-07 15:11:52 -07001<!--
2 Copyright 2010 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070017# Submitting Patches #
18
19This page describes the full process of submitting a patch to the AOSP, including reviewing and tracking changes with Gerrit.
20
21## Prerequisites ##
22
23- Before you follow the instructions on this page, you will need to set up your
24local working environment and get the Android source files. For instructions,
25follow the "Getting Started" section [here](downloading.html).
26
27- For details about Repo and Git, see [Version Control](version-control.html).
28
29- For information about the different roles you can play within the Android
Dan Morrill669d3642011-04-07 14:37:55 -070030Open Source community, see [Project roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070031
32- If you plan to contribute code to the Android platform, be sure to read
Dan Morrill669d3642011-04-07 14:37:55 -070033the [AOSP's licensing information](/source/licenses.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070034
35- Note that changes to some of the upstream projects used by Android should be
36made directly to that project, as described in [Upstream Projects](#upstream-projects).
37
Skyler Kaufman44436912011-04-07 15:11:52 -070038# For contributors #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070039
Skyler Kaufman44436912011-04-07 15:11:52 -070040## Start a repo branch ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070041
Skyler Kaufman44436912011-04-07 15:11:52 -070042For each change you intend to make, start a new branch within the relevant git repository:
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070043
Skyler Kaufman44436912011-04-07 15:11:52 -070044 $ repo start NAME
45
46You 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.
47
48## Make your change ##
49
50Once you have modified the source files (and validated them, please) commit the changes to your local repository:
51
52 $ git add -A
53 $ git commit -s
54
55Provide 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:
56
57- Start with a one-line summary (60 characters max), followed by a blank line. This format is used by git and gerrit for various displays.
58
59 short description on first line
60
61 more detailed description of your patch,
62 which is likely to take up multiple lines.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070063
64- The description should focus on what issue it solves, and how it solves it. The second part is somewhat optional when implementing new features, though desirable.
65
Skyler Kaufman44436912011-04-07 15:11:52 -070066- Include a brief note of any assumptions or background information that may be important when another contributor works on this feature next year.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070067
Skyler Kaufman44436912011-04-07 15:11:52 -070068A unique change ID and your name and email as provided during `repo init` will be automatically added to your commit message.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070069
Skyler Kaufman44436912011-04-07 15:11:52 -070070## Upload to gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070071
Skyler Kaufman44436912011-04-07 15:11:52 -070072Once you have committed your change to your personal history, upload it to gerrit with
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070073
Skyler Kaufman44436912011-04-07 15:11:52 -070074 $ repo upload
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070075
Skyler Kaufman44436912011-04-07 15:11:52 -070076If you have started multiple branches in the same repository, you will be prompted to select which one(s) to upload.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070077
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -080078After a successful upload, repo will provide you the URL of a new page on
79[Gerrit](https://android-review.googlesource.com/). Visit this link to view
80your patch on the review server, add comments, or request specific reviewers
81for your patch.
Skyler Kaufman44436912011-04-07 15:11:52 -070082
83## Uploading a replacement patch ##
84
85Suppose 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.
86
87*Note that if you have made other commits since uploading this patch, you will need to manually move your git HEAD.*
88
89 $ git add -A
90 $ git commit --amend
91
92When you upload the amended patch, it will replace the original on gerrit and in your local git history.
93
94## Resolving sync conflicts ##
95
96If 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
97
98 $ repo sync
99
100This command first fetches the updates from the source server, then attempts to automatically rebase your HEAD onto the new remote HEAD.
101
102If the automatic rebase is unsuccessful, you will have to perform a manual rebase.
103
104 $ git rebase master
105
106Using `git mergetool` may help you deal with the rebase conflict. Once you have successfully merged the conflicting files,
107
108 $ git rebase --continue
109
110After either automatic or manual rebase is complete, run `repo upload` to submit your rebased patch.
111
112## After a submission is approved ##
113
114After 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.
115
116# For reviewers and verifiers #
117
118## Reviewing a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700119
120If you are assigned to be the Approver for a change, you need to determine the following:
121
122- Does this change fit within this project's stated purpose?
123
124- Is this change valid within the project's existing architecture?
125
126- Does this change introduce design flaws that will cause problems in the future?
127
128- Does this change follow the best practices that have been established for this project?
129
130- Is this change a good way to perform the described function?
131
132- Does this change introduce any security or instability risks?
133
134If you approve of the change, mark it with LGTM ("Looks Good to Me") within Gerrit.
135
Skyler Kaufman44436912011-04-07 15:11:52 -0700136## Verifying a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700137
138If you are assigned to be the Verifier for a change, you need to do the following:
139
140- Patch the change into your local client using one of the Download commands.
141
142- Build and test the change.
143
144- Within Gerrit use Publish Comments to mark the commit as "Verified" or "Fails," and add a message explaining what problems were identified.
145
Skyler Kaufman44436912011-04-07 15:11:52 -0700146## Downloading changes from Gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700147
148A 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
149
150 $ repo download TARGET CHANGE
151
152where TARGET is the local directory into which the change should be downloaded and CHANGE is the
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -0800153change number as listed in [Gerrit](https://android-review.googlesource.com/). For more information,
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700154see the [Repo reference](/source/using-repo.html).
155
Skyler Kaufman44436912011-04-07 15:11:52 -0700156## How do I become a Verifier or Approver? ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700157
158In short, contribute high-quality code to one or more of the Android projects.
159For details about the different roles in the Android Open Source community and
Dan Morrill669d3642011-04-07 14:37:55 -0700160who plays them, see [Project Roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700161
Skyler Kaufman44436912011-04-07 15:11:52 -0700162## Diffs and comments ##
163
164To 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."
165
166## Adding comments ##
167
168Anyone 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.
169
170To 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.
171
172To 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.
173
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700174## Using GitWeb to track patch histories ##
175
176To view snapshots of the files that are in the public Android repositories and view file histories, use the [Android instance of GitWeb](http://android.git.kernel.org/).
177
178<a name="upstream-projects"></a>
179
Skyler Kaufman44436912011-04-07 15:11:52 -0700180# Upstream Projects #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700181
182Android makes use of a number of other open-source projects, such as the Linux kernel and WebKit, as described in
Elliott Hughes26ff7042012-03-20 18:50:58 -0700183[Branches and Releases](/source/code-lines.html). For most projects under `external/`, changes should be made upstream and then the Android maintainers informed of the new upstream release containing these changes. It may also be useful to upload patches that move us to track a new upstream release, though these can be difficult changes to make if the project is widely used within Android like most of the larger ones mentioned below, where we tend to upgrade with every release.
184
185One interesting special case is bionic. Much of the code there is from BSD, so unless the change is to code that's new to bionic, we'd much rather see an upstream fix and then pull a whole new file from the appropriate BSD. (Sadly we have quite a mix of different BSDs at the moment, but we hope to address that in future, and get into a position where we track upstream much more closely.)
186
187## ICU4C ##
188
189All changes to the ICU4C project at `external/icu4c` should be made upstream at
190[icu-project.org/](http://site.icu-project.org/).
191See [Submitting ICU Bugs and Feature Requests](http://site.icu-project.org/bugs) for more.
192
193## OpenSSL ##
194
195All changes to the OpenSSL project at `external/openssl` should be made upstream at
196[openssl.org](http://www.openssl.org).
197
198## V8 ##
199
200All changes to the V8 project at `external/v8` should be submitted upstream at
201[code.google.com/p/v8](http://code.google.com/p/v8). See [Contributing to V8](http://code.google.com/p/v8/wiki/Contributing)
202for details.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700203
Skyler Kaufman44436912011-04-07 15:11:52 -0700204## WebKit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700205
206All changes to the WebKit project at `external/webkit` should be made
207upstream at [webkit.org](http://www.webkit.org). The process begins by filing a WebKit bug.
208This bug should use `Android` for the `Platform` and `OS`
209fields only if the bug is specific to Android. Bugs are far more likely to receive the reviewers'
210attention once a proposed fix is added and tests are included. See
211[Contributing Code to WebKit](http://webkit.org/coding/contributing.html) for details.
212
Elliott Hughes26ff7042012-03-20 18:50:58 -0700213## zlib ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700214
Elliott Hughes26ff7042012-03-20 18:50:58 -0700215All changes to the zlib project at `external/zlib` should be made upstream at
216[zlib.net](http://zlib.net).