Pass shallow flag through gclient to git_cache.py
BUG=261741
Review URL: https://codereview.chromium.org/278043005
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@270542 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient.py b/gclient.py
index 3ac66e7..33f7911 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1738,6 +1738,9 @@
parser.add_option('--output-json',
help='Output a json document to this path containing '
'summary information about the sync.')
+ parser.add_option('--shallow', action='store_true',
+ help='GIT ONLY - Do a shallow clone into the cache dir. '
+ 'Requires Git 1.9+')
(options, args) = parser.parse_args(args)
client = GClient.LoadCurrentConfig(options)
diff --git a/gclient_scm.py b/gclient_scm.py
index 00b8145..594515d 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -765,7 +765,15 @@
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)
+ if options.shallow:
+ # HACK(hinoka): These repositories should be super shallow.
+ if 'flash' in url:
+ depth = 10
+ else:
+ depth = 10000
+ else:
+ depth = None
+ mirror.populate(verbose=options.verbose, bootstrap=True, depth=depth)
mirror.unlock()
return mirror.mirror_path if mirror.exists() else None