summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/git_config.py b/git_config.py
index 84d347b1a..4facccda6 100644
--- a/git_config.py
+++ b/git_config.py
@@ -266,6 +266,13 @@ class GitConfig:
266 except KeyError: 266 except KeyError:
267 old = [] 267 old = []
268 268
269 if self.file != self._SYSTEM_CONFIG:
270 # `git config --file` does not create missing parent directories
271 # (e.g. ~/.repoconfig/ on first use).
272 parent_dir = os.path.dirname(self.file)
273 if parent_dir:
274 os.makedirs(parent_dir, exist_ok=True)
275
269 if value is None: 276 if value is None:
270 if old: 277 if old:
271 del self._cache[key] 278 del self._cache[key]
@@ -444,6 +451,11 @@ class GitConfig:
444class RepoConfig(GitConfig): 451class RepoConfig(GitConfig):
445 """User settings for repo itself.""" 452 """User settings for repo itself."""
446 453
454 # Keep separate caches from GitConfig, otherwise ForUser()/ForSystem()
455 # would return the already-cached ~/.gitconfig instance of the parent.
456 _ForUser = None
457 _ForSystem = None
458
447 @staticmethod 459 @staticmethod
448 def _getUserConfig(): 460 def _getUserConfig():
449 repo_config_dir = os.getenv("REPO_CONFIG_DIR", os.path.expanduser("~")) 461 repo_config_dir = os.getenv("REPO_CONFIG_DIR", os.path.expanduser("~"))