summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-05-20 16:03:45 -0700
committerJonathan Nieder <jrn@google.com>2020-05-21 19:47:36 +0000
commitd79a4bc51b6ca5b47bbea861143c72bccc0ad13a (patch)
treef2d8de86fc76c9207af7be2b0c7ff683471df761
parent682f0b6426a06ed1e89b130d50c6521b1c67d529 (diff)
downloadgit-repo-d79a4bc51b6ca5b47bbea861143c72bccc0ad13a.tar.gz
Make partial clone imply no-clone-bundle by default.
For large projects, clone bundle is useful because it provided a way to efficiently transfer a large portion of git objects through CDN, without needing to interact with git server. However, with partial clones, the intention is to not download most of the objects, so the use of clone bundles would defeat the space savings normally seen with partial clones, as they are downloaded before the first fetch. A new option, --clone-bundle is added to override this behavior. Add a new repo.clonebundle variable which remembers the choice if explicitly given from command line at repo init. Change-Id: I03638474af303a82af34579e16cd4700690b5f43 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/268452 Tested-by: Xin Li <delphij@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
-rw-r--r--docs/internal-fs-layout.md1
-rw-r--r--manifest_xml.py8
-rwxr-xr-xrepo9
-rw-r--r--subcmds/init.py11
-rw-r--r--subcmds/sync.py8
5 files changed, 31 insertions, 6 deletions
diff --git a/docs/internal-fs-layout.md b/docs/internal-fs-layout.md
index 5e8690b8..3537dfda 100644
--- a/docs/internal-fs-layout.md
+++ b/docs/internal-fs-layout.md
@@ -134,6 +134,7 @@ User controlled settings are initialized when running `repo init`.
134|-------------------|---------------------------|-------------| 134|-------------------|---------------------------|-------------|
135| manifest.groups | `--groups` & `--platform` | The manifest groups to sync | 135| manifest.groups | `--groups` & `--platform` | The manifest groups to sync |
136| repo.archive | `--archive` | Use `git archive` for checkouts | 136| repo.archive | `--archive` | Use `git archive` for checkouts |
137| repo.clonebundle | `--clone-bundle` | Whether the initial sync used clone.bundle explicitly |
137| repo.clonefilter | `--clone-filter` | Filter setting when using [partial git clones] | 138| repo.clonefilter | `--clone-filter` | Filter setting when using [partial git clones] |
138| repo.depth | `--depth` | Create shallow checkouts when cloning | 139| repo.depth | `--depth` | Create shallow checkouts when cloning |
139| repo.dissociate | `--dissociate` | Dissociate from any reference/mirrors after initial clone | 140| repo.dissociate | `--dissociate` | Dissociate from any reference/mirrors after initial clone |
diff --git a/manifest_xml.py b/manifest_xml.py
index b2918cac..b6aef510 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -502,6 +502,14 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
502 return self._manifest_server 502 return self._manifest_server
503 503
504 @property 504 @property
505 def CloneBundle(self):
506 clone_bundle = self.manifestProject.config.GetBoolean('repo.clonebundle')
507 if clone_bundle is None:
508 return False if self.manifestProject.config.GetBoolean('repo.partialclone') else True
509 else:
510 return clone_bundle
511
512 @property
505 def CloneFilter(self): 513 def CloneFilter(self):
506 if self.manifestProject.config.GetBoolean('repo.partialclone'): 514 if self.manifestProject.config.GetBoolean('repo.partialclone'):
507 return self.manifestProject.config.GetString('repo.clonefilter') 515 return self.manifestProject.config.GetString('repo.clonefilter')
diff --git a/repo b/repo
index be59c87f..18c7e77a 100755
--- a/repo
+++ b/repo
@@ -317,9 +317,11 @@ def GetParser(gitc_init=False):
317 help='restrict manifest projects to ones with a specified ' 317 help='restrict manifest projects to ones with a specified '
318 'platform group [auto|all|none|linux|darwin|...]', 318 'platform group [auto|all|none|linux|darwin|...]',
319 metavar='PLATFORM') 319 metavar='PLATFORM')
320 group.add_option('--clone-bundle', action='store_true',
321 help='enable use of /clone.bundle on HTTP/HTTPS (default if not --partial-clone)')
320 group.add_option('--no-clone-bundle', 322 group.add_option('--no-clone-bundle',
321 dest='clone_bundle', default=True, action='store_false', 323 dest='clone_bundle', action='store_false',
322 help='disable use of /clone.bundle on HTTP/HTTPS') 324 help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)')
323 group.add_option('--no-tags', 325 group.add_option('--no-tags',
324 dest='tags', default=True, action='store_false', 326 dest='tags', default=True, action='store_false',
325 help="don't fetch tags in the manifest") 327 help="don't fetch tags in the manifest")
@@ -502,6 +504,9 @@ def _Init(args, gitc_init=False):
502 opt.quiet = opt.output_mode is False 504 opt.quiet = opt.output_mode is False
503 opt.verbose = opt.output_mode is True 505 opt.verbose = opt.output_mode is True
504 506
507 if opt.clone_bundle is None:
508 opt.clone_bundle = False if opt.partial_clone else True
509
505 url = opt.repo_url or REPO_URL 510 url = opt.repo_url or REPO_URL
506 rev = opt.repo_rev or REPO_REV 511 rev = opt.repo_rev or REPO_REV
507 512
diff --git a/subcmds/init.py b/subcmds/init.py
index ce8b0187..eb82e2e4 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -155,9 +155,11 @@ to update the working directory files.
155 help='restrict manifest projects to ones with a specified ' 155 help='restrict manifest projects to ones with a specified '
156 'platform group [auto|all|none|linux|darwin|...]', 156 'platform group [auto|all|none|linux|darwin|...]',
157 metavar='PLATFORM') 157 metavar='PLATFORM')
158 g.add_option('--clone-bundle', action='store_true',
159 help='force use of /clone.bundle on HTTP/HTTPS (default if not --partial-clone)')
158 g.add_option('--no-clone-bundle', 160 g.add_option('--no-clone-bundle',
159 dest='clone_bundle', default=True, action='store_false', 161 dest='clone_bundle', action='store_false',
160 help='disable use of /clone.bundle on HTTP/HTTPS') 162 help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)')
161 g.add_option('--no-tags', 163 g.add_option('--no-tags',
162 dest='tags', default=True, action='store_false', 164 dest='tags', default=True, action='store_false',
163 help="don't fetch tags in the manifest") 165 help="don't fetch tags in the manifest")
@@ -303,6 +305,11 @@ to update the working directory files.
303 else: 305 else:
304 opt.clone_filter = None 306 opt.clone_filter = None
305 307
308 if opt.clone_bundle is None:
309 opt.clone_bundle = False if opt.partial_clone else True
310 else:
311 m.config.SetString('repo.clonebundle', 'true' if opt.clone_bundle else 'false')
312
306 if opt.submodules: 313 if opt.submodules:
307 m.config.SetString('repo.submodules', 'true') 314 m.config.SetString('repo.submodules', 'true')
308 315
diff --git a/subcmds/sync.py b/subcmds/sync.py
index efd39616..a40dd5e0 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -247,8 +247,9 @@ later is required to fix a server side protocol bug.
247 p.add_option('-m', '--manifest-name', 247 p.add_option('-m', '--manifest-name',
248 dest='manifest_name', 248 dest='manifest_name',
249 help='temporary manifest to use for this sync', metavar='NAME.xml') 249 help='temporary manifest to use for this sync', metavar='NAME.xml')
250 p.add_option('--no-clone-bundle', 250 p.add_option('--clone-bundle', action='store_true',
251 dest='clone_bundle', default=True, action='store_false', 251 help='enable use of /clone.bundle on HTTP/HTTPS')
252 p.add_option('--no-clone-bundle', dest='clone_bundle', action='store_false',
252 help='disable use of /clone.bundle on HTTP/HTTPS') 253 help='disable use of /clone.bundle on HTTP/HTTPS')
253 p.add_option('-u', '--manifest-server-username', action='store', 254 p.add_option('-u', '--manifest-server-username', action='store',
254 dest='manifest_server_username', 255 dest='manifest_server_username',
@@ -836,6 +837,9 @@ later is required to fix a server side protocol bug.
836 smart_sync_manifest_path = os.path.join( 837 smart_sync_manifest_path = os.path.join(
837 self.manifest.manifestProject.worktree, 'smart_sync_override.xml') 838 self.manifest.manifestProject.worktree, 'smart_sync_override.xml')
838 839
840 if opt.clone_bundle is None:
841 opt.clone_bundle = self.manifest.CloneBundle
842
839 if opt.smart_sync or opt.smart_tag: 843 if opt.smart_sync or opt.smart_tag:
840 manifest_name = self._SmartSyncSetup(opt, smart_sync_manifest_path) 844 manifest_name = self._SmartSyncSetup(opt, smart_sync_manifest_path)
841 else: 845 else: