OLD | NEW |
---|---|
(Empty) | |
1 depot_tools_tutorial(7) | |
2 ======================= | |
3 | |
4 NAME | |
5 ---- | |
6 depot_tools_tutorial - A tutorial introduction to the Chromium depot_tools git | |
7 extensions. | |
8 | |
9 DESCRIPTION | |
10 ----------- | |
11 | |
12 The Chromium linkgit:depot_tools[7] suite contains many git workflow-enhancing | |
13 tools which are designed to work together to enable anyone to wrangle the | |
14 Chromium codebase expertly. This tutorial explains how to do development on | |
agable
2014/04/04 23:34:12
nit: two spaces? Really?
iannucci
2014/04/05 01:31:13
Picky picky...
| |
15 Chromium using these tools. This will cover: | |
16 | |
17 * <<_setting_up,Setting up>> | |
18 * <<_getting_the_code,Getting the code>> | |
19 * <<_creating_uploading_a_cl,Creating / Uploading a CL>> | |
20 * <<_updating_the_code,Updating the code>> | |
21 * <<_managing_multiple_cls,Managing multiple CLs>> | |
22 * <<_managing_dependent_cls,Managing dependent CLs>> | |
23 | |
24 Please refer to the manpages (or `--help` output) for details about any of the | |
25 commands mentioned in this tutorial. | |
26 | |
27 [NOTE] | |
28 If your platform does not support manpages (or you prefer something a bit more | |
29 expressive than plain text) you can find all documentation in 'html' form in the | |
30 `[DEPOT_TOOLS]/docs/html` folder. | |
31 | |
32 PREREQUISITES | |
33 ~~~~~~~~~~~~~ | |
34 This tutorial will assume some basic familarity with git terminology and basic | |
35 premises. If you need to brush up on these, the following are very good | |
36 resources: | |
37 | |
38 * link:http://git-scm.com/book[Pro Git book] - Pretty good overview of git to | |
Ryan Tseng
2014/04/05 00:51:20
While a good resource, I wouldn't list it as the f
iannucci
2014/04/05 01:31:13
I restructured this section a bit. PTAL.
| |
39 bootstrap a working knowledge. | |
40 * link:http://gitimmersion.com/[Git Immersion Tutorial] - An in-depth git | |
41 tutorial. | |
42 * link:http://pcottle.github.io/learnGitBranching[pcottle's Visual Git | |
43 Branching] - An excellent interactive/graphical demo on how git handles | |
44 commits, branches, and shows the operations git performs on them. | |
45 | |
46 SETTING UP | |
47 ---------- | |
48 | |
49 GET DEPOT TOOLS | |
50 ~~~~~~~~~~~~~~~ | |
51 | |
52 ifdef::backend-xhtml11[] | |
53 LINUX / MAC | |
54 ^^^^^^^^^^^ | |
55 endif::backend-xhtml11[] | |
56 Clone the 'depot_tools' repository: | |
57 | |
58 [subs="quotes"] | |
59 ---- | |
60 [white]**$ git clone https://chromium.googlesource.com/chromium/tools/depot_tool s** | |
61 ---- | |
62 | |
63 Add 'depot_tools' to the 'end' of your PATH and MANPATH (you will probably want | |
64 to put this in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned | |
65 'depot_tools' to `/path/to/depot_tools`: | |
66 | |
67 [postsubs="quotes"] | |
68 ---- | |
69 [white]**$ export PATH=$PATH:/path/to/depot_tools** | |
70 [white]**$ export MANPATH=$MANPATH:/path/to/depot_tools/docs** <1> | |
71 ---- | |
72 <1> Observe that this path is +depot_tools/+**+docs+**. | |
73 | |
74 // No need to show the Windows stuff on the manpage output. | |
75 ifdef::backend-xhtml11[] | |
76 WINDOWS | |
77 ^^^^^^^ | |
78 Download the 'depot_tools' | |
79 link:https://src.chromium.org/svn/trunk/tools/depot_tools.zip[bundle] and | |
80 extract it somewhere. | |
81 | |
82 [WARNING] | |
83 *DO NOT* use drag-n-drop or copy-n-paste extract from Explorer, this will not | |
84 extract the hidden ``.git'' folder which is necessary for 'depot_tools' to | |
85 autoupdate itself. You can use ``Extract all...'' from the context menu though. | |
86 | |
87 Add 'depot_tools' to the 'end' of your PATH. Assuming you unzipped the | |
88 bundle to `C:\workspace\depot_tools`: | |
89 | |
90 With Administrator access: :: | |
91 *Control Panel -> System and Security -> System -> Advanced system settings* | |
92 + | |
93 Modify the PATH system variable to include `C:\workspace\depot_tools`. | |
94 | |
95 Without Administrator access: :: | |
96 *Control Panel -> User Accounts -> User Accounts -> Change my environment vari ables* | |
97 + | |
98 Add a PATH user variable: `%PATH%;C:\workspace\depot_tools`. | |
99 | |
100 From a `cmd.exe` shell, run the command `gclient` (without arguments). On first | |
101 run, gclient will install all the Windows-specific bits needed to work with the | |
102 code, including msysgit and python. | |
103 | |
104 [NOTE] | |
105 ===== | |
106 * If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell), it | |
107 may appear to run properly, but msysgit, python, and other tools may not get | |
108 installed correctly. | |
109 * If you see strange errors with the file system on the first run of gclient, | |
110 you may want to link:http://tortoisesvn.tigris.org/faq.html#cantmove2[disable | |
111 Windows Indexing]. | |
112 * If you are running Windows XP and see errors like ``The system cannot execute | |
113 the specified program'', try installing the | |
114 link:http://code.google.com/p/chromium/issues/detail?id=75886[``Microsoft | |
115 Visual C++ 2008 Redistributable Package'']. | |
116 ===== | |
117 endif::backend-xhtml11[] | |
118 | |
119 BOOTSTRAPPING CONFIGURATION | |
120 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
121 If you have never used git before, you’ll need to set some global git | |
122 configurations; substitute your name and email address in the following | |
123 commands: | |
124 | |
125 [subs="quotes,attributes"] | |
126 ---- | |
127 [white]**$ git config --global user.name ``John Doe''** | |
128 [white]**$ git config --global user.email ``jdoe@email.com''** | |
129 [white]**$ git config --global core.autocrlf false** | |
130 [white]**$ git config --global core.filemode false** | |
131 [white]**$** # and for fun! | |
132 [white]**$ git config --global color.ui true** | |
133 ---- | |
134 | |
135 GETTING THE CODE | |
136 ---------------- | |
137 Pick an empty directory and run one of the following: | |
138 | |
139 [subs="quotes"] | |
140 ---- | |
141 [white]**$ fetch chromium** # Basic checkout for desktop Chromium | |
142 [white]**$ fetch blink** # Chromium code with blink checked out to tip-of-tr ee | |
Ryan Tseng
2014/04/05 00:51:20
Blink (is a proper noun)
iannucci
2014/04/05 01:31:13
Done.
| |
143 [white]**$ fetch android** # Chromium checkout for Android platform | |
144 [white]**$ fetch ios** # Chromium checkout for iOS platform | |
145 ---- | |
146 | |
147 When the `fetch` tool completes you should have the following in your working | |
148 directory: | |
149 | |
150 [subs="quotes"] | |
151 ---- | |
152 [white]**.gclient** # A configuration file for you source checkout | |
153 [white]**src/** # Top-level Chromium source checkout. | |
154 ---- | |
155 | |
156 If you are on linux, then you'll need to run: | |
157 | |
158 [subs="specialcharacters,quotes"] | |
159 ---- | |
160 [white]**$ cd src && ./build/install-build-deps.sh** | |
161 ---- | |
162 | |
163 And finally: | |
164 | |
165 [postsubs="quotes"] | |
166 ---- | |
167 [white]**$ gclient sync** <1> | |
168 ---- | |
169 <1> This will pull all dependencies of the Chromium src checkout. You will need | |
170 to run this any time you update the main src checkout. | |
171 | |
172 | |
173 CREATING / UPLOADING A CL | |
174 ------------------------- | |
175 NOTE: The remainder of the tutorial assumes that your current working directory | |
176 is the `src/` folder mentioned in <<_getting_the_code,Getting the code>>. | |
177 | |
178 Each CL corresponds exactly with a single branch in git. Any time you want to | |
179 begin a new CL, just: | |
180 | |
181 [subs="specialcharacters,quotes"] | |
182 ---- | |
183 [white]**$ git new-branch <branch_name>** | |
184 ---- | |
185 | |
186 This will create and checkout a new branch named `branch_name` which will track | |
187 the default upstream (which is `origin/master`). See linkgit:git-new-branch[1] | |
188 for more features, such as the ability to track 'LKGR'. | |
189 | |
190 Commit as many changes as you like to this branch. When you want to upload it | |
191 for review, run: | |
192 | |
193 [subs="quotes"] | |
194 ---- | |
195 [white]**$ git cl upload** | |
196 ---- | |
197 | |
198 This will take the diff of your branch against it's upstream (`origin/master`), | |
agable
2014/04/04 23:18:58
its
iannucci
2014/04/05 01:31:13
Done.
| |
199 and will post it to the link:https://codereview.chromium.org[Chromium code | |
200 review site]. | |
201 | |
202 | |
203 UPDATING THE CODE | |
204 ----------------- | |
205 Inevitably, you'll want to pull in changes from the main Chromium repo. This is | |
206 pretty easy with 'depot_tools': | |
207 | |
208 [subs="quotes"] | |
209 ---- | |
210 [white]**$ git rebase-update** | |
211 ---- | |
212 | |
213 This command will update all of your CLs to contain the latest code from their | |
Ryan Tseng
2014/04/05 00:51:20
'Like "svn update", this command will....'
If we
iannucci
2014/04/05 01:31:13
Erg, I'd rather not. I'm not really doing that any
| |
214 upstreams. It will also automatically clean up CLs which have been committed and | |
215 a couple other nice things :). See linkgit:git-rebase-update[1] for the full | |
agable
2014/04/04 23:34:12
ditch smiley
iannucci
2014/04/05 01:31:13
:(
| |
216 scoop. | |
217 | |
218 One thing to look out for are 'merge conflicts'. These happen for exactly the | |
219 same as they do with SVN, but the experience is a little more controllable with | |
220 git. `git rebase-update` will try to rebase all your branches for you, but if it | |
Ryan Tseng
2014/04/05 00:51:20
"Rebase" isn't really in my vocabulary when i was
iannucci
2014/04/05 01:31:13
They'll have to learn what rebasing is. Is the pre
| |
221 encounters a merge conflict in one, it will halt and leave you in a rebase | |
222 conflict state (see linkgit:git-rebase[1]). Resolving `git rebase` merge | |
223 conflicts is beyond the scope of this tutorial, but there are many good sources | |
224 online (see the <<_prerequisites,Prerequisites>> for some). | |
225 | |
226 Sometimes you're pretty certain that you've committed a certain branch, but `git | |
agable
2014/04/04 23:34:12
This is a poorly constructed sentence: "Sometimes,
iannucci
2014/04/05 01:31:13
PTAL
| |
227 rebase-update` isn't able to tell that because your branch doesn't rebase | |
228 cleanly, and you'd like to double check the diff of your branch against its | |
229 upstream before deleting it. If this is the case you can abort the rebase, and | |
230 then run linkgit:git-squash-branch[1] to flatten your branch into a single | |
231 commit. When you run `git rebase-update` again, you'll get a (hopefully) much | |
232 smaller / saner diff. If it turns out you were wrong, you can use | |
233 linkgit:git-reflog[1] to reset your branch back to where it was. | |
234 | |
235 Once you're done resolving all of the merge conflict, just run `git | |
236 rebase-update`, and it will pick up where it left off. Once the command has | |
237 finished updating all of your branches, it will return you back to the branch | |
238 you started on. | |
239 | |
240 [NOTE] | |
241 Running `git rebase-update` will update all your branches, but it will not | |
242 automatically run `gclient sync` to update your dependencies. | |
243 | |
244 | |
245 MANAGING MULTIPLE CLS | |
246 --------------------- | |
247 Sometimes you want to work on more than one CL at once (say, you have a CL | |
248 posted for review and want to work on something else). For each CL that you | |
249 want to work on, just use `git new-branch <branchname>`. | |
250 | |
251 Once you start to have more than one CL at a time, it can be easy to lose your | |
252 bearings. Fortunately, 'depot_tools' has two tools to help you out: | |
253 | |
254 [subs="specialcharacters,quotes,attributes"] | |
255 ---- | |
256 [white]**$ git map** | |
257 [white blue-background]##*##{zwsp}[blue-background red]** 7dcfe47 ** [gree n]##(##{zwsp}[aqua]**frozen_changes**{zwsp}[green]##)## [yellow]##2014-03-12## \ ~ FREEZE.unindexed | |
258 * [red]**4b0c180** [yellow]##2014-03-12## \~ modfile | |
259 * [red]**59a7cca** [yellow]##2014-03-12## \~ a deleted file | |
260 * [red]**6bec695** [green]##(##{zwsp}[red]##origin/master##{zwsp}[green]# #)## [yellow]##2014-03-11## \~ Add neat feature [white]**<(frozen_changes)** | |
261 * [red]**d15a38a** [yellow]##2014-03-11## \~ Epic README update | |
262 * [red]**d559894** [green]##(##{zwsp}[lime]**master**{zwsp}[green]##)## [ yellow]##2014-03-11## \~ Important upstream change | |
263 [red]##|## * [red]**9c311fd** [green]##(##{zwsp}[lime]**cool_feature**{zwsp }[green]##)## [yellow]##2014-03-11## \~ Respond to CL comments | |
264 [red]##|## [green]##|## * [red]**2a1eeb2** [green]##(##{zwsp}[lime]**subfeatu re**{zwsp}[green]##)## [yellow]##2014-03-11## \~ integrate with CoolService | |
265 [red]##|## [green]##|## * [red]**d777af6** [yellow]##2014-03-11## \~ slick co mmenting action | |
266 [red]##|## [green]##|/## | |
267 [red]##|## * [red]**265803a** [yellow]##2014-03-11## \~ another improvement [white]**<(subfeature)** | |
268 [red]##|## * [red]**6d831ac** [green]##(##{zwsp}[fuchsia]**spleen_tag**{zws p}[green]##)## [yellow]##2014-03-11## \~ Refactor spleen | |
269 [red]##|## * [red]**82e74ab** [yellow]##2014-03-11## \~ Add widget | |
270 [red]##|/## | |
271 * [red]**d08c5b3** [green]##(##{zwsp}[lime]**bogus_noparent**{zwsp}[green ]##)## [yellow]##2014-03-11## ~ Wonderful beginnings [white]**<(cool_feature) ** | |
272 ---- | |
273 Note that this example repo is in dire need of a linkgit:git-rebase-update[1]! | |
274 | |
275 [subs="quotes"] | |
276 ---- | |
277 [white]**$ git map-branches** | |
278 [red]#origin/master# | |
279 [green]#cool_feature# | |
280 [green]#subfeature# | |
281 [aqua]#frozen_changes *# | |
282 [green]#master# | |
283 ---- | |
284 | |
285 linkgit:git-map[1]:: | |
286 This tool shows you the history of all of your branches in a pseudo-graphical | |
287 format. In particular, it will show you which commits all of your branches | |
288 are on, which commit you currently have checked out, and more. Check out the | |
289 doc for the full details. | |
290 | |
291 linkgit:git-map-branches[1]:: | |
292 This tool just shows you which branches you have in your repo, and thier | |
293 upstream relationship to each other (as well as which branch you have checked | |
294 out at the moment). | |
295 | |
296 Additionally, sometimes you need to switch between branches, but you've got work | |
297 in progress. You could use linkgit:git-stash[1], but that can be tricky to | |
298 manage because you need to remember which branches you stashed what changes on. | |
299 Helpfully 'depot_tools' includes two tools which can greatly assist in case: | |
300 | |
301 linkgit:git-freeze[1] allows you to put the current branch in \'suspended | |
302 animation' by committing your changes to a specially-named commit on the top of | |
303 your current branch. When you come back to your branch later, you can just run | |
304 linkgit:git-thaw[1] to get your work-in-progress changes back to what they were. | |
305 | |
306 Another useful tool is linkgit:git-rename-branch[1]. No, I'm not going to | |
agable
2014/04/04 23:34:12
dry humor
iannucci
2014/04/05 01:31:13
Done.
| |
307 explain what it does. | |
308 | |
309 Finally, take a look at linkgit:git-upstream-diff[1]. This will show you the | |
310 combined diff for all the commits on your branch against the upstream tracking | |
311 branch. This is 'exactly' what `git cl upload` will push up to code review. | |
312 Additionally, consider trying the `--wordwise` argument to get a colorized | |
313 per-word diff (instead of a per-line diff). | |
314 | |
315 MANAGING DEPENDENT CLS | |
316 ---------------------- | |
317 Now that you know how to manage <<_managing_multiple_cls,'independent' CLs>>, | |
agable
2014/04/04 23:34:12
No need to reference previous section.
iannucci
2014/04/05 01:31:13
Done.
| |
318 we'll see how to manage 'dependent' CLs. Dependent CLs are useful when your | |
319 second (or third or fourth or ...) CL depends on the changes in one of your | |
320 other CLs (such as: CL 2 won't compile without CL 1, but you want to submit | |
321 them as two separate reviews). | |
322 | |
323 Like all of the other CLs we've created, we use linkgit:git-new-branch[1], but | |
324 this time with a (not very surprising) twist. First, `git checkout` the branch | |
agable
2014/04/04 23:34:12
with a twist? Really?
iannucci
2014/04/05 01:31:13
*sigh*
| |
325 you want to base the new one on (i.e. CL 1), and then run: | |
326 | |
327 [subs="specialcharacters,quotes"] | |
328 ---- | |
329 [white]**$ git new-branch --upstream_current <branch_name>** | |
330 ---- | |
331 | |
332 This will make a new branch which tracks the 'current' branch as its upstream | |
333 (as opposed to 'origin/master'). All changes you commit to this branch will be | |
334 in addition to the previous branch, but when you `git cl upload`, you will only | |
335 upload the diff for the dependent (child) branch. You may have as many branches | |
336 nested in this fashion as you like. | |
337 | |
338 linkgit:git-map[1] and linkgit:git-map-branches[1] are particularly helpful when | |
339 you have dependent branches. In addition, there are two helper commands which | |
340 let you traverse your working copy up and down this tree of branches: | |
341 linkgit:git-nav-upstream[1] and linkgit:git-nav-downstream[1]. | |
342 | |
343 Sometimes when dealing with dependent CLs, it turns out that you accidentally | |
344 based a branch on the wrong upstream, but since then you've committed changes to | |
345 it, or even based 'another' branch off of that one. Or say that you have two | |
agable
2014/04/04 23:34:12
"Or say that you..." is a bad construction; it doe
iannucci
2014/04/05 01:31:13
Done.
| |
346 independent CLs that would actually be much better off as dependent CLs. Not to | |
agable
2014/04/04 23:34:12
"Not to worry..." -> "This can be fixed by..." or
iannucci
2014/04/05 01:31:13
Done.
| |
347 worry, because you can just check out the offending branch and use | |
348 linkgit:git-reparent-branch[1] to move it around the tree. | |
349 | |
350 | |
351 CONCLUSION | |
352 ---------- | |
353 Well that wraps up the whirlwind tour of the 'depot_tools' helper tools. If you | |
agable
2014/04/04 23:34:12
This paragraph is too cute. You're a teacher, not
iannucci
2014/04/05 01:31:13
Done.
| |
354 have questions which weren't answered by this tutorial or the man pages for the | |
355 tools (see the index of all tools here: linkgit:depot_tools[7]), please ask :). | |
356 | |
357 | |
358 GLOSSARY | |
359 -------- | |
360 | |
361 CL:: | |
362 A 'change-list'. This is a diff which you would like to commit to the | |
363 codebase. | |
364 | |
365 DEPS:: | |
366 A file in the chromium checkout which `gclient sync` uses to determine what | |
367 dependencies to pull in. This file also contains 'hooks'. | |
368 | |
369 LKGR:: | |
370 Last Known Good Revision. This is a linkgit:git-tag[1] which tracks the last | |
371 version of `origin/master` which has passed the full set of testing on the | |
372 link:http://build.chromium.org[main Chromium waterfall]. | |
373 | |
374 include::_footer.txt[] | |
375 | |
376 // vim: ft=asciidoc: | |
OLD | NEW |