[PATCH 2 of 2 stable v2] tests: prevent Git system and global configuration from loading
Mads Kiilerich
mads at kiilerich.com
Wed Apr 19 12:27:16 UTC 2023
On 18/04/2023 20:35, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me at manueljacob.de>
> # Date 1680139355 -7200
> # Thu Mar 30 03:22:35 2023 +0200
> # Branch stable
> # Node ID e5251abd0a3c677d7bb0828f3a744789bd6fe4cb
> # Parent 30082bb9719eb00f3be0081b7221d7c3061d4345
> # EXP-Topic tests-git
> tests: prevent Git system and global configuration from loading
>
> This reduces differences between different testing environments. Something
> similar is already done for Mercurial (in the lines directly above this
> change).
Yes, I agree that it is a problem/bug that the global configuration is
used at all. Global configuration should be disabled for git, as we do
for hg.
> The parent changeset has originally been added to support user.useconfigonly.
> With this changeset, the original motivation for it becomes obsolete. However,
> it is still necessary to set the committer name via a environment variable, at
> least on my machine.
I think this changeset should come first. As you say, it makes the test
work the same way everywhere. user.useconfigonly is probably just one of
many settings that could break it.
If it still doesn't work for you with this change (without the previous
change), it can't be because your setup has user.useconfigonly set.
There must be some other explanation.
(Note that the GIT_CONFIG_ environment variables were introduced two
years ago, and Kallithea still supports the 10 year old Git 1.7.4 . We
must thus make sure we don't rely too much on the new feature.)
> diff --git a/kallithea/tests/other/test_vcs_operations.py b/kallithea/tests/other/test_vcs_operations.py
> --- a/kallithea/tests/other/test_vcs_operations.py
> +++ b/kallithea/tests/other/test_vcs_operations.py
> @@ -150,6 +150,8 @@
> testenv['LANGUAGE'] = 'en_US:en'
> testenv['HGPLAIN'] = ''
> testenv['HGRCPATH'] = ''
> + testenv['GIT_CONFIG_SYSTEM'] = ''
> + testenv['GIT_CONFIG_GLOBAL'] = ''
As mentioned before: the git man page is very clear that the variables
should be set to /dev/null to skip reading configuration files.
There is no indication in the git man page (or anywhere else I have
found) that setting to /dev/null shouldn't work across all platforms. It
seems like git in compat/mingw.c takes care of making it cross platform.
There is no mention of the semantics of setting it to an empty string. I
do not like relying on undefined behaviour.
If you disagree and have found a good reason to use an empty string
instead of /dev/null, then please be explicit in code or commit message.
/Mads
More information about the kallithea-general
mailing list