From eafa0f5d3b08be5fb4003c2ce3f40dd26badb90b Mon Sep 17 00:00:00 2001 From: Frank Schreiner Date: Mon, 5 Aug 2024 14:53:08 +0200 Subject: [PATCH] unset git global configs git is highly configurable and esp. for the `log` command its very popular to modify the config to the users needs/preferences. Unfortunatly these settings are also active in scripted environments like tar_scm/obs_scm and can cause various errors. This patch sets the ENV VAR GIT_CONFIG_GLOBAL to /dev/null so configs in ~/.gitconfig and $XDG_CONFIG_HOME/git/config should be ignored. --- TarSCM/scm/git.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/TarSCM/scm/git.py b/TarSCM/scm/git.py index 8625f89d..7eb78d1d 100644 --- a/TarSCM/scm/git.py +++ b/TarSCM/scm/git.py @@ -25,6 +25,11 @@ class Git(Scm): _stash_pop_required = False partial_clone = False + def __init__(self, args, task): + super().__init__(args, task) + if not os.getenv('GIT_CONFIG_GLOBAL', None): + os.putenv('GIT_CONFIG_GLOBAL', '/dev/null') + def _get_scm_cmd(self): """Compose a GIT-specific command line using http proxies""" # git should honor the http[s]_proxy variables, but we need to @@ -228,7 +233,9 @@ def update_cache(self): self.auth_url() try: self.helpers.safe_run( - self._get_scm_cmd() + ['config', 'remote.origin.url', + self._get_scm_cmd() + ['config', + '--local', + 'remote.origin.url', self.url], cwd=self.clone_dir, interactive=sys.stdout.isatty()