summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2019-06-03 11:24:30 -0700
committerDavid Pursehouse <dpursehouse@collab.net>2019-07-16 00:23:16 +0000
commit745be2ede1e67421275afc00c04d996d9d6908ee (patch)
tree6b7bfbd187a33eeeb14108518ece5440ce9456c0 /subcmds/init.py
parent87fb5a1894354ec0e34ccec427a9803e24157847 (diff)
downloadgit-repo-745be2ede1e67421275afc00c04d996d9d6908ee.tar.gz
Add support for partial clone.v1.13.4
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 <vapier@google.com> Tested-by: Xin Li <delphij@google.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 1c809ab4..eaa6da50 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -115,6 +115,13 @@ to update the working directory files.
115 g.add_option('--depth', type='int', default=None, 115 g.add_option('--depth', type='int', default=None,
116 dest='depth', 116 dest='depth',
117 help='create a shallow clone with given depth; see git clone') 117 help='create a shallow clone with given depth; see git clone')
118 g.add_option('--partial-clone', action='store_true',
119 dest='partial_clone',
120 help='perform partial clone (https://git-scm.com/'
121 'docs/gitrepository-layout#_code_partialclone_code)')
122 g.add_option('--clone-filter', action='store', default='blob:none',
123 dest='clone_filter',
124 help='filter for use with --partial-clone [default: %default]')
118 g.add_option('--archive', 125 g.add_option('--archive',
119 dest='archive', action='store_true', 126 dest='archive', action='store_true',
120 help='checkout an archive instead of a git repository for ' 127 help='checkout an archive instead of a git repository for '
@@ -253,13 +260,25 @@ to update the working directory files.
253 'in another location.', file=sys.stderr) 260 'in another location.', file=sys.stderr)
254 sys.exit(1) 261 sys.exit(1)
255 262
263 if opt.partial_clone:
264 if opt.mirror:
265 print('fatal: --mirror and --partial-clone are mutually exclusive',
266 file=sys.stderr)
267 sys.exit(1)
268 m.config.SetString('repo.partialclone', 'true')
269 if opt.clone_filter:
270 m.config.SetString('repo.clonefilter', opt.clone_filter)
271 else:
272 opt.clone_filter = None
273
256 if opt.submodules: 274 if opt.submodules:
257 m.config.SetString('repo.submodules', 'true') 275 m.config.SetString('repo.submodules', 'true')
258 276
259 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, 277 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet,
260 clone_bundle=not opt.no_clone_bundle, 278 clone_bundle=not opt.no_clone_bundle,
261 current_branch_only=opt.current_branch_only, 279 current_branch_only=opt.current_branch_only,
262 no_tags=opt.no_tags, submodules=opt.submodules): 280 no_tags=opt.no_tags, submodules=opt.submodules,
281 clone_filter=opt.clone_filter):
263 r = m.GetRemote(m.remote.name) 282 r = m.GetRemote(m.remote.name)
264 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) 283 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
265 284