Skip to content

Commit

Permalink
unset git global configs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
M0ses committed Aug 5, 2024
1 parent 0a2955f commit eafa0f5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion TarSCM/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit eafa0f5

Please sign in to comment.