Skip to content

[6.0.100-preview.4.21206.10][main branch] LibGit2Sharp System.NullReferenceException at git_diff_find_similar native method #50841

Closed

Description

Application Name: LibGit2Sharp (https://github.com/libgit2/libgit2sharp)
OS: Windows 10 RS5
CPU: X64
.NET Build Number: 6.0.100-preview.4.21206.10
Affected Application: git-istage global tool app (GlobalToolsNETCore21Part01)
https://github.com/terrajobst/git-istage

Verify Scenarios:
1). Windows 10 RS5 X64 + .NET Core SDK build 6.0.100-preview.4.21206.1 - main branch: Fail
2). Windows 10 RS5 X64 + .NET Core SDK build 6.0.100-preview.3.21202.5 - Preview 3 branch: Pass
3). Windows 10 RS5 X64 + .NET Core SDK build 5.0.104 : Pass

DevDiv bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1307298

Repro steps to run

  1. Create a .net core console app
  2. Add <PackageReference Include="LibGit2Sharp" Version="0.26.2" />
  3. In Program.cs
var _repository = new Repository(@".git folder path in the project");
var tipTree = _repository.Head.Tip?.Tree;
var comp = _repository.Diff.Compare<TreeChanges>(tipTree, DiffTargets.Index);  //exception here
Console.WriteLine(comp.Count); //changes count

Expected Result:
Should return the number of staged changes

Actual Result:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at LibGit2Sharp.Core.NativeMethods.git_diff_find_similar(git_diff* diff, GitDiffFindOptions options)
   at LibGit2Sharp.Core.Proxy.git_diff_find_similar(DiffHandle diff, GitDiffFindOptions options)
   at LibGit2Sharp.Diff.DetectRenames(DiffHandle diffList, CompareOptions compareOptions)
   at LibGit2Sharp.Diff.BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever, DiffModifiers diffOptions, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions)
   at LibGit2Sharp.Diff.Compare[T](Tree oldTree, DiffTargets diffTargets, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions)
   at LibGit2Sharp.Diff.Compare[T](Tree oldTree, DiffTargets diffTargets)
   at ConsoleApp1.Program.Main(String[] args) in C:\Users\v-altunc\source\repos\ConsoleApp12\ConsoleApp1\Program.cs:line 14

@dotnet-actwx-bot @dotnet/compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions