branch heads fix

--with_branch_heads doesn't work with cache_dir, this fixes it.

BUG=

Review URL: https://codereview.chromium.org/239083007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@264331 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index e0a9091..79a0adf 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -732,9 +732,14 @@
     """
     if not self.cache_dir:
       return url
-    mirror_kwargs = { 'print_func': self.filter }
+    mirror_kwargs = {
+        'print_func': self.filter,
+        'refs': []
+    }
     if url == CHROMIUM_SRC_URL or url + '.git' == CHROMIUM_SRC_URL:
-      mirror_kwargs['refs'] = ['refs/tags/lkgr', 'refs/tags/lkcr']
+      mirror_kwargs['refs'].extend(['refs/tags/lkgr', 'refs/tags/lkcr'])
+    if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
+      mirror_kwargs['refs'].append('refs/branch-heads/*')
     mirror = git_cache.Mirror(url, **mirror_kwargs)
     mirror.populate(verbose=options.verbose, bootstrap=True)
     mirror.unlock()