blob: 0ea530d8742dc9ec0d33007080cb299be9c490f3 [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
Jean-Baptiste Queruc173c702012-04-12 15:26:24 -070019This page describes the full process of submitting a patch to the AOSP, including
20reviewing and tracking changes with [Gerrit](https://android-review.googlesource.com/).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070021
22## Prerequisites ##
23
24- Before you follow the instructions on this page, you will need to set up your
25local working environment and get the Android source files. For instructions,
26follow the "Getting Started" section [here](downloading.html).
27
28- For details about Repo and Git, see [Version Control](version-control.html).
29
30- For information about the different roles you can play within the Android
Dan Morrill669d3642011-04-07 14:37:55 -070031Open Source community, see [Project roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070032
33- If you plan to contribute code to the Android platform, be sure to read
Dan Morrill669d3642011-04-07 14:37:55 -070034the [AOSP's licensing information](/source/licenses.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070035
36- Note that changes to some of the upstream projects used by Android should be
37made directly to that project, as described in [Upstream Projects](#upstream-projects).
38
Skyler Kaufman44436912011-04-07 15:11:52 -070039# For contributors #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070040
Jean-Baptiste Queru67de3762012-04-27 17:41:59 -070041## Authenticate with the server ##
42
43Before you can upload to Gerrit, you need to establish a password that
44will identify you with the server. You only need to do this once.
45
46- Sign in on the [AOSP Gerrit Server](https://android-review.googlesource.com/).
47
48- Go to Settings -> HTTP Password -> Obtain Password
49
50- Follow the instructions on the subsquent pages, and copy-paste your
51password in `~/.netrc`. If there are two password lines, copy both.
52
Skyler Kaufman44436912011-04-07 15:11:52 -070053## Start a repo branch ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070054
Skyler Kaufman44436912011-04-07 15:11:52 -070055For each change you intend to make, start a new branch within the relevant git repository:
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070056
Yegor Yefremov01902492012-02-21 22:18:44 +010057 $ repo start NAME .
Skyler Kaufman44436912011-04-07 15:11:52 -070058
59You 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.
60
61## Make your change ##
62
63Once you have modified the source files (and validated them, please) commit the changes to your local repository:
64
65 $ git add -A
66 $ git commit -s
67
68Provide 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:
69
70- 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.
71
72 short description on first line
73
74 more detailed description of your patch,
75 which is likely to take up multiple lines.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070076
77- 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.
78
Skyler Kaufman44436912011-04-07 15:11:52 -070079- 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 -070080
Skyler Kaufman44436912011-04-07 15:11:52 -070081A 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 -070082
Skyler Kaufman44436912011-04-07 15:11:52 -070083## Upload to gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070084
Skyler Kaufman44436912011-04-07 15:11:52 -070085Once you have committed your change to your personal history, upload it to gerrit with
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070086
Skyler Kaufman44436912011-04-07 15:11:52 -070087 $ repo upload
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070088
Skyler Kaufman44436912011-04-07 15:11:52 -070089If 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 -070090
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -080091After a successful upload, repo will provide you the URL of a new page on
92[Gerrit](https://android-review.googlesource.com/). Visit this link to view
93your patch on the review server, add comments, or request specific reviewers
94for your patch.
Skyler Kaufman44436912011-04-07 15:11:52 -070095
96## Uploading a replacement patch ##
97
98Suppose 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.
99
100*Note that if you have made other commits since uploading this patch, you will need to manually move your git HEAD.*
101
102 $ git add -A
103 $ git commit --amend
104
105When you upload the amended patch, it will replace the original on gerrit and in your local git history.
106
107## Resolving sync conflicts ##
108
109If 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
110
111 $ repo sync
112
113This command first fetches the updates from the source server, then attempts to automatically rebase your HEAD onto the new remote HEAD.
114
115If the automatic rebase is unsuccessful, you will have to perform a manual rebase.
116
117 $ git rebase master
118
119Using `git mergetool` may help you deal with the rebase conflict. Once you have successfully merged the conflicting files,
120
121 $ git rebase --continue
122
123After either automatic or manual rebase is complete, run `repo upload` to submit your rebased patch.
124
125## After a submission is approved ##
126
Conley Owens75539812012-02-21 11:53:05 -0800127After a submission makes it through the review and verification process, Gerrit automatically merges the change into the public repository. Other users will be able to run `repo sync` to pull the update into their local client.
Skyler Kaufman44436912011-04-07 15:11:52 -0700128
129# For reviewers and verifiers #
130
131## Reviewing a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700132
133If you are assigned to be the Approver for a change, you need to determine the following:
134
135- Does this change fit within this project's stated purpose?
136
137- Is this change valid within the project's existing architecture?
138
139- Does this change introduce design flaws that will cause problems in the future?
140
141- Does this change follow the best practices that have been established for this project?
142
143- Is this change a good way to perform the described function?
144
145- Does this change introduce any security or instability risks?
146
147If you approve of the change, mark it with LGTM ("Looks Good to Me") within Gerrit.
148
Skyler Kaufman44436912011-04-07 15:11:52 -0700149## Verifying a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700150
151If you are assigned to be the Verifier for a change, you need to do the following:
152
153- Patch the change into your local client using one of the Download commands.
154
155- Build and test the change.
156
157- Within Gerrit use Publish Comments to mark the commit as "Verified" or "Fails," and add a message explaining what problems were identified.
158
Skyler Kaufman44436912011-04-07 15:11:52 -0700159## Downloading changes from Gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700160
161A 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
162
163 $ repo download TARGET CHANGE
164
165where TARGET is the local directory into which the change should be downloaded and CHANGE is the
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -0800166change number as listed in [Gerrit](https://android-review.googlesource.com/). For more information,
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700167see the [Repo reference](/source/using-repo.html).
168
Skyler Kaufman44436912011-04-07 15:11:52 -0700169## How do I become a Verifier or Approver? ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700170
171In short, contribute high-quality code to one or more of the Android projects.
172For details about the different roles in the Android Open Source community and
Dan Morrill669d3642011-04-07 14:37:55 -0700173who plays them, see [Project Roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700174
Skyler Kaufman44436912011-04-07 15:11:52 -0700175## Diffs and comments ##
176
177To 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."
178
179## Adding comments ##
180
181Anyone 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.
182
183To 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.
184
185To 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.
186
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700187<a name="upstream-projects"></a>
188
Skyler Kaufman44436912011-04-07 15:11:52 -0700189# Upstream Projects #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700190
191Android 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 -0700192[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.
193
194One 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.)
195
196## ICU4C ##
197
198All changes to the ICU4C project at `external/icu4c` should be made upstream at
199[icu-project.org/](http://site.icu-project.org/).
200See [Submitting ICU Bugs and Feature Requests](http://site.icu-project.org/bugs) for more.
201
202## OpenSSL ##
203
204All changes to the OpenSSL project at `external/openssl` should be made upstream at
205[openssl.org](http://www.openssl.org).
206
207## V8 ##
208
209All changes to the V8 project at `external/v8` should be submitted upstream at
Jean-Baptiste Queru60c81412012-04-19 15:00:44 -0700210[code.google.com/p/v8](https://code.google.com/p/v8). See [Contributing to V8](https://code.google.com/p/v8/wiki/Contributing)
Elliott Hughes26ff7042012-03-20 18:50:58 -0700211for details.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700212
Skyler Kaufman44436912011-04-07 15:11:52 -0700213## WebKit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700214
215All changes to the WebKit project at `external/webkit` should be made
216upstream at [webkit.org](http://www.webkit.org). The process begins by filing a WebKit bug.
217This bug should use `Android` for the `Platform` and `OS`
218fields only if the bug is specific to Android. Bugs are far more likely to receive the reviewers'
219attention once a proposed fix is added and tests are included. See
220[Contributing Code to WebKit](http://webkit.org/coding/contributing.html) for details.
221
Elliott Hughes26ff7042012-03-20 18:50:58 -0700222## zlib ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700223
Elliott Hughes26ff7042012-03-20 18:50:58 -0700224All changes to the zlib project at `external/zlib` should be made upstream at
225[zlib.net](http://zlib.net).