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