|
UsingGit
Using Git to work on Chromium
Some people working on Chromium prefer to use the Git version control system. This document explains how we have best found to use Git. NOTE: If you just git clone the Chromium repo, your checkout will not work.
Getting the codeFirst checkout
Advanced Tricks
Staying up to date
ContributingConfigure your checkoutSince contributing code using git requires git-cl, read git-cl's README and README.codereview to learn how to use it. Since you already have depot_tools in your PATH, git-cl will "just work." Configure it with: git cl config http://src.chromium.org/svn/ You must add the junk to your ~/.subversion/config that's specified on http://dev.chromium.org/developers/coding-style under "Subversion properties". Else git won't set svn properties correctly and people might yell at you. Making local changesThe first step to contributing a patch is to write it. Create a branch and make your changes: git checkout -q -b mywork origin vi ... git commit -a -v Presubmit testsAfter committing your changes locally, use git-cl to run all of the presubmit tests associated with your change. git cl presubmit This runs both upload and dcommit presubmit tests. They will alert you to any problems with your change that you should address before completing or dcommitting your patch. Code ReviewsAll code changes are reviewed using http://codereview.chromium.org. Use git-cl to easily upload a branch as a proposed change. You can associate each git branch you work on with a code review by running the following: git checkout mywork git cl upload Uploading your change will also run the upload presubmit tests on your change. To skip the presubmit tests, use the flag --bypass-hooks. Subsequent invocations of 'upload' on the same branch will add updates to the same code review. See git cl help for more. Trybotsgit-try, part of depot_tools, will run git branches through the try bots. If your patch depends on specific branches in Chromium and WebKit, you can run git-try with: git try -b BOT --webkit WEBKIT_BRANCH [CHROMIUM_BRANCH] where WEBKIT_BRANCH and CHROMIUM_BRANCH are branches to compare with. In most cases, they will be master and trunk, respectively. If you are running the patch on try bots, use BOT as layout_win,layout_mac,layout_linux. Renames and CopiesGit has a strange notion of how copies and renames work; see the Git FAQ about it. If git diff -M -C shows that git knows a file was renamed, then git cl upload and git cl dcommit will include the proper metadata for reviewing and committing the rename. If not, ask evan@chromium.org about it -- this code isn't tested well so there are surely bugs. CommittingTo commit from your checkout, you must (obviously) first have commit access.
Initial SetupMake sure you are in src/ folder when you run this command: git svn init --prefix=origin/ -T trunk/src svn://svn.chromium.org/chrome (If you're a git ninja, you might notice that this sets up refs/remotes/origin to naturally point at the git server, with the twist that git-svn also uses refs/remotes/origin/trunk.) Run git svn fetch once just to let it rebuild its revision database. Really CommittingShould Just Work. Always use git cl dcommit. It runs git svn dcommit for you along with running the very important presubmit tests. To bypass the presubmit tests (eg. to committ on a closed tree), use the flag --bypass-hooks. WindowsIf you are using msysgit, you are asking for trouble. Using both msysgit (including TortoiseGit) and cygwin's version of git is a path to lead to repository corruption so it's safer to stick with the cygwin's version. So if you still have msysgit in your PATH, you are on your own. Sane people will install the following cygwin packages:
After installation, sanity check your git-svn binaries by running "git svn info". If you see an error message like , you'll need to remap your binaries. Be sure to turn off git's crlf munging: git config --global core.autocrlf false Binaries may not work out of the box: cygwin 1.7 (and also 1.5 on Windows 7) may throw error message like $ git svn info 6 [main] perl 4760 C:\cygwin\bin\perl.exe: *** fatal error - unable to remap <library> to same address as parent while using git. You'll need to rebase your dlls with ash.exe and 'rebaseall'. TroubleshootingSometimes (it seems to happen on Windows, but not other platforms?) git-svn will get confused about things. Symptoms include it trying to refetch commits you've already fetched, or printing "transaction out of date" errors on unrelated files. Try this recipe: rm -rf .git/svn # clobber git-svn metadata git svn find-rev r1 # run a no-op command to rebuild metadata Tips & TricksFinding Files FastUse git-gs located in src/depot_tools to search the source tree. Since git keeps an index of all files it knows about, it can filter the master list of files by file extension and only grep through those files. It doesn't have to crawl your tree (and all those layout test results) to grep over source code. Performing a git gs [searchterm] from /src/ gets results in a couple seconds with a cold disk. It's often instant with a warm disk. Note this won't search dependencies pulled by gclient. |