[PATCH 2 of 2 stable v2] tests: prevent Git system and global configuration from loading

Manuel Jacob me at manueljacob.de
Wed Apr 19 13:14:40 UTC 2023


On 19/04/2023 14.27, Mads Kiilerich wrote:
> 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.

If I have only this changeset without the parent, command `git commit -m 
"committed new 0" --author "User ǝɯɐᴎ <me at example.com>" 
"97u1nbm0setup.py"` fails with:

Committer identity unknown

*** Please tell me who you are.

Run

   git config --global user.email "you at example.com"
   git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <me at example.com>) not allowed
[end of output]

Because the error shouldn’t be the result of my configuration after this 
changeset, I would expect that it fails without the parent changeset on 
other machines as well (at least those with the same Git version as me 
(2.40.0)).

I never intended to imply that user.useconfigonly is the only reason why 
the previous changeset is required. Sorry for the confusion!

> (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.

You’re right that the Git documentation mentions `/dev/null` but the 
empty string. I’ll change it.

> 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