From 745be2ede1e67421275afc00c04d996d9d6908ee Mon Sep 17 00:00:00 2001 From: Xin Li Date: Mon, 3 Jun 2019 11:24:30 -0700 Subject: Add support for partial clone. A new option, --partial-clone is added to 'repo init' which tells repo to utilize git's partial clone functionality, which reduces disk and bandwidth usage when downloading by omitting blob downloads initially. Different from restricting clone-depth, the user will have full access to change history, etc., as the objects are downloaded on demand. Change-Id: I60326744875eac16521a007bd7d5481112a98749 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/229532 Reviewed-by: Mike Frysinger Tested-by: Xin Li --- project.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 67d3bb20..9702e9da 100755 --- a/project.py +++ b/project.py @@ -1226,7 +1226,8 @@ class Project(object): archive=False, optimized_fetch=False, prune=False, - submodules=False): + submodules=False, + clone_filter=None): """Perform only the network IO portion of the sync process. Local working directory/branch state is not affected. """ @@ -1309,7 +1310,8 @@ class Project(object): not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, current_branch_only=current_branch_only, no_tags=no_tags, prune=prune, depth=depth, - submodules=submodules, force_sync=force_sync)): + submodules=submodules, force_sync=force_sync, + clone_filter=clone_filter)): return False mp = self.manifest.manifestProject @@ -1959,7 +1961,8 @@ class Project(object): prune=False, depth=None, submodules=False, - force_sync=False): + force_sync=False, + clone_filter=None): is_sha1 = False tag_name = None @@ -2050,6 +2053,11 @@ class Project(object): cmd = ['fetch'] + if clone_filter: + git_require((2, 19, 0), fail=True, msg='partial clones') + cmd.append('--filter=%s' % clone_filter) + self.config.SetString('extensions.partialclone', self.remote.name) + if depth: cmd.append('--depth=%s' % depth) else: @@ -2150,12 +2158,12 @@ class Project(object): return self._RemoteFetch(name=name, current_branch_only=current_branch_only, initial=False, quiet=quiet, alt_dir=alt_dir, - depth=None) + depth=None, clone_filter=clone_filter) else: # Avoid infinite recursion: sync all branches with depth set to None return self._RemoteFetch(name=name, current_branch_only=False, initial=False, quiet=quiet, alt_dir=alt_dir, - depth=None) + depth=None, clone_filter=clone_filter) return ok -- cgit v1.2.3-54-g00ecf