From 46b874144e0dd034ffa96d20b4f544a77a6ff0a4 Mon Sep 17 00:00:00 2001 From: "hinoka@chromium.org" Date: Thu, 15 May 2014 00:42:05 +0000 Subject: [PATCH] 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 --- gclient.py | 3 +++ gclient_scm.py | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gclient.py b/gclient.py index 3ac66e7639..33f7911f0f 100755 --- a/gclient.py +++ b/gclient.py @@ -1738,6 +1738,9 @@ def CMDsync(parser, args): 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 00b8145bb4..594515dc16 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -765,7 +765,15 @@ class GitWrapper(SCMWrapper): 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