Interacting with configuration where not ProgramData config does not exists now throws an exception
See original GitHub issueIt’s not immediately clear what side the bug is on, but the latest upgrade to libgit2 v1.6.2 seems to have introduced an issue with the loading of the ProgramData config path in lib2git.
Reproduction steps
-
Ensure you have no configuration file in the program data directory. In the LibGit2Sharp tests these are generated automatically in
%userprofile%\AppData\Local\Temp\LibGit2Sharp-TestRepos
which may explain why it wasnt picked up in the tests -
Try to read any config
var repo = new Repository();
repo.Config.Get<bool>("core.autocrlf");
Expected behavior
The Configuration.cs
constructor should load what configuration it can and continue on its way. libgit2
should presumably be returning a 0
as some of the other missing config paths do, which would result in the path resolving “successfully” to null
Actual behavior
The call down to NativeMethods.git_config_find_programdata
returns a -1
with an error message that resolves as
LibGit2Sharp.LibGit2SharpException: the ProgramData file 'config' doesn't exist:
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in D:\Development\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3801
at LibGit2Sharp.Core.Proxy.git_config_find_programdata() in D:\Development\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 497
at LibGit2Sharp.Configuration..ctor(Repository repository, String repositoryConfigurationFileLocation, String globalConfigurationFileLocation, String xdgConfigurationFileLocation, String systemConfigurationFileLocation) in D:\Development\libgit2sharp\LibGit2Sharp\Configuration.cs:line 47
at LibGit2Sharp.Repository.<>c__DisplayClass25_1.<.ctor>b__3() in D:\Development\libgit2sharp\LibGit2Sharp\Repository.cs:line 220
at System.Lazy`1.CreateValue()
Testing against the previous version it looks like this was previously not an enforced configuration file.
Version of LibGit2Sharp (release number or SHA1)
master
(commit 70d62d5
)
Operating system(s) tested; .NET runtime tested
Windows 11
Issue Analytics
- State:
- Created 6 months ago
- Reactions:2
- Comments:8 (7 by maintainers)
Top GitHub Comments
https://github.com/libgit2/libgit2/pull/6547
@zentron LibGit2Sharp 0.27.2 is out and includes the change, so you can try it now.