summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/project.py b/project.py
index 3a7ac9e8..5bead641 100644
--- a/project.py
+++ b/project.py
@@ -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: