diff options
-rw-r--r-- | project.py | 22 | ||||
-rw-r--r-- | subcmds/sync.py | 3 |
2 files changed, 21 insertions, 4 deletions
@@ -2186,6 +2186,24 @@ class Project(object): | |||
2186 | return result | 2186 | return result |
2187 | 2187 | ||
2188 | # Direct Git Commands ## | 2188 | # Direct Git Commands ## |
2189 | def EnableRepositoryExtension(self, key, value='true', version=1): | ||
2190 | """Enable git repository extension |key| with |value|. | ||
2191 | |||
2192 | Args: | ||
2193 | key: The extension to enabled. Omit the "extensions." prefix. | ||
2194 | value: The value to use for the extension. | ||
2195 | version: The minimum git repository version needed. | ||
2196 | """ | ||
2197 | # Make sure the git repo version is new enough already. | ||
2198 | found_version = self.config.GetInt('core.repositoryFormatVersion') | ||
2199 | if found_version is None: | ||
2200 | found_version = 0 | ||
2201 | if found_version < version: | ||
2202 | self.config.SetString('core.repositoryFormatVersion', str(version)) | ||
2203 | |||
2204 | # Enable the extension! | ||
2205 | self.config.SetString('extensions.%s' % (key,), value) | ||
2206 | |||
2189 | def _CheckForImmutableRevision(self): | 2207 | def _CheckForImmutableRevision(self): |
2190 | try: | 2208 | try: |
2191 | # if revision (sha or tag) is not present then following function | 2209 | # if revision (sha or tag) is not present then following function |
@@ -2314,7 +2332,7 @@ class Project(object): | |||
2314 | if clone_filter: | 2332 | if clone_filter: |
2315 | git_require((2, 19, 0), fail=True, msg='partial clones') | 2333 | git_require((2, 19, 0), fail=True, msg='partial clones') |
2316 | cmd.append('--filter=%s' % clone_filter) | 2334 | cmd.append('--filter=%s' % clone_filter) |
2317 | self.config.SetString('extensions.partialclone', self.remote.name) | 2335 | self.EnableRepositoryExtension('partialclone', self.remote.name) |
2318 | 2336 | ||
2319 | if depth: | 2337 | if depth: |
2320 | cmd.append('--depth=%s' % depth) | 2338 | cmd.append('--depth=%s' % depth) |
@@ -2630,7 +2648,7 @@ class Project(object): | |||
2630 | # Enable per-worktree config file support if possible. This is more a | 2648 | # Enable per-worktree config file support if possible. This is more a |
2631 | # nice-to-have feature for users rather than a hard requirement. | 2649 | # nice-to-have feature for users rather than a hard requirement. |
2632 | if self.use_git_worktrees and git_require((2, 19, 0)): | 2650 | if self.use_git_worktrees and git_require((2, 19, 0)): |
2633 | self.config.SetString('extensions.worktreeConfig', 'true') | 2651 | self.EnableRepositoryExtension('worktreeConfig') |
2634 | 2652 | ||
2635 | # If we have a separate directory to hold refs, initialize it as well. | 2653 | # If we have a separate directory to hold refs, initialize it as well. |
2636 | if self.objdir != self.gitdir: | 2654 | if self.objdir != self.gitdir: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 49867a97..eada76a7 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -576,8 +576,7 @@ later is required to fix a server side protocol bug. | |||
576 | print('%s: Shared project %s found, disabling pruning.' % | 576 | print('%s: Shared project %s found, disabling pruning.' % |
577 | (project.relpath, project.name)) | 577 | (project.relpath, project.name)) |
578 | if git_require((2, 7, 0)): | 578 | if git_require((2, 7, 0)): |
579 | project.config.SetString('core.repositoryFormatVersion', '1') | 579 | project.EnableRepositoryExtension('preciousObjects') |
580 | project.config.SetString('extensions.preciousObjects', 'true') | ||
581 | else: | 580 | else: |
582 | # This isn't perfect, but it's the best we can do with old git. | 581 | # This isn't perfect, but it's the best we can do with old git. |
583 | print('%s: WARNING: shared projects are unreliable when using old ' | 582 | print('%s: WARNING: shared projects are unreliable when using old ' |