-
Notifications
You must be signed in to change notification settings - Fork 899
Interacting with configuration where not ProgramData config does not exists now throws an exception #2021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can confirm this issue with the V0.27 Release |
@zentron From my testing so far, libgit2/libgit2#6547 does seem to have fixed the exception you mentioned, but it's not really clear what behavior you're expecting after that fix. When I run your repro code using LibGit2Sharp 0.26.2, it wasn't valid to access the config when using the default |
@bording this is the exception I was getting in GitVersion when trying to update from 0.27.0-preview-0182 to 0.27.1 https://github.com/GitTools/GitVersion/actions/runs/4680350775/jobs/8291675407#step:4:119 Error Message:
LibGit2Sharp.LibGit2SharpException : the ProgramData file 'config' doesn't exist:
Stack Trace:
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in /_/LibGit2Sharp/Core/Proxy.cs:line 3801
at LibGit2Sharp.Core.Proxy.git_config_find_programdata() in /_/LibGit2Sharp/Core/Proxy.cs:line 497
at LibGit2Sharp.Configuration..ctor(Repository repository, String repositoryConfigurationFileLocation, String globalConfigurationFileLocation, String xdgConfigurationFileLocation, String systemConfigurationFileLocation) in /_/LibGit2Sharp/Configuration.cs:line 47
at LibGit2Sharp.Repository.<>c__DisplayClass25_1.<.ctor>b__3() in /_/LibGit2Sharp/Repository.cs:line 220
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at LibGit2Sharp.Repository.get_Config() in /_/LibGit2Sharp/Repository.cs:line 323
at LibGit2Sharp.Core.PathCase..ctor(IRepository repo) in /_/LibGit2Sharp/Core/PathCase.cs:line 12
at LibGit2Sharp.RepositoryExtensions.PathStartsWith(IRepository repository, String path, String value) in /_/LibGit2Sharp/RepositoryExtensions.cs:line 226
at LibGit2Sharp.RepositoryExtensions.BuildRelativePathFrom(IRepository repo, String path) in /_/LibGit2Sharp/RepositoryExtensions.cs:line 213
at LibGit2Sharp.Repository.ToFilePaths(IEnumerable`1 paths) in /_/LibGit2Sharp/Repository.cs:line 1652
at LibGit2Sharp.Diff.BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever, DiffModifiers diffOptions, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) in /_/LibGit2Sharp/Diff.cs:line 545
at LibGit2Sharp.Diff.Compare[T](DiffModifiers diffOptions, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) in /_/LibGit2Sharp/Diff.cs:line 484
at LibGit2Sharp.Commands.Stage(IRepository repository, IEnumerable`1 paths, StageOptions stageOptions) in /_/LibGit2Sharp/Commands/Stage.cs:line 77
at LibGit2Sharp.Commands.Stage(IRepository repository, String path) in /_/LibGit2Sharp/Commands/Stage.cs:line 25
|
@arturcic Yes, that is also what I've observed, and I have confirmed that it will be fixed with the native binaries that include libgit2/libgit2#6547. That's not what I'm asking about in my previous comment though. Using LibGit2Sharp 0.26.2, using the repro code in this issue: var repo = new Repository();
repo.Config.Get<bool>("core.autocrlf"); That doesn't appear to have ever worked, and it doesn't work with libgit2/libgit2#6547 included either. For the scenario where you're passing a repo path to |
Updating to newer version of LibGit2Sharp is currently blocked. See libgit2/libgit2sharp#2021, libgit2/libgit2sharp.nativebinaries#149, libgit2/libgit2#6547
@bording , you are probably right. The repro in the original issue was simply to show the minimal way to specifically reproduce that listed exception. The "real world" usage of the code will presumably work fine once I update to use the libgit2/libgit2#6547 change. Thanks ill keep you posted. |
@zentron LibGit2Sharp 0.27.2 is out and includes the change, so you can try it now. |
Thanks @bording all looks good now after updating (via our fork). In the actual usage the repository is created with a specific location so it doesn't get the follow-up error noticed in the repro once the NativeBinaries dependency was updated. |
It'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 testsTry to read any config
Expected behavior
The
Configuration.cs
constructor should load what configuration it can and continue on its way.libgit2
should presumably be returning a0
as some of the other missing config paths do, which would result in the path resolving "successfully" tonull
Actual behavior
The call down to
NativeMethods.git_config_find_programdata
returns a-1
with an error message that resolves asTesting against the previous version it looks like this was previously not an enforced configuration file.
Version of LibGit2Sharp (release number or SHA1)
master
(commit70d62d5
)Operating system(s) tested; .NET runtime tested
Windows 11
The text was updated successfully, but these errors were encountered: