-
Notifications
You must be signed in to change notification settings - Fork 899
WorktreeCollection.Add throws exception on NET6 Preview 4 (0.27.0-preview-0096) #1885
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
This same problem is appearing for me after the .NET upgrade was automatically pushed out for release I believe the below previously worked with Expected behaviorWorktrees.Add executes without exception Actual behaviorDiffers between
When running in
This sounds like a few existing issues logged recently so one of my suspicions was something to do with how calls are being marshalled to unmanaged code in the new runtime with dlls from an older sdk, but pulling down the LibGit2Sharp repo and rebuilding results in the same error. Version of LibGit2Sharp (release number or SHA1) Reproduction StepsSame principal as above, but have included a empty repo to pull down to make reproducing a little bit easier. Included as LinqPad script <Query Kind="Program">
<NuGetReference Version="0.27.0-preview-0100" Prerelease="true">LibGit2Sharp</NuGetReference>
<Namespace>LibGit2Sharp</Namespace>
<RuntimeVersion>5.0</RuntimeVersion>
</Query>
void Main()
{
var basePath = @"C:\Temp\Something\"+ Guid.NewGuid().ToString().Substring(0,5);
Directory.CreateDirectory(basePath);
//var rootWorktree = Path.Combine(basePath, "master");
var worktreeName = "random-tree";
Repository.Clone("https://github.com/zentron/libg2sharp-bugtest", basePath, new CloneOptions { IsBare = false, RecurseSubmodules = false, BranchName = "main" });
using (var repo = new Repository(basePath))
{
var workingDirectory = new DirectoryInfo(Path.Combine(basePath, worktreeName));
var remoteBranchName = $"origin/second-branch";
repo.Worktrees.Add(remoteBranchName, worktreeName, workingDirectory.FullName, false);
Console.Write($"Branch in {workingDirectory.FullName}");
}
} Interestingly when I run the above code in LinqPad and toggle between .NET 5 (3.0.7) and .NET 3.1 (3.1.6) it works in the older runtime. If I run the |
Located fix and added a PR 👇 @bording Let me know if there is anything else I can help with to get this merged and published. |
@zentron Thanks for the PR. I suspect there might more of these lurking around now that .NET seems to be caring about them. 0.27.0-preview-0102 includes the fix. |
Reproduction steps
Expected behavior
Worktrees.Add executes without exception
Actual behavior
Throws "LibGit2Sharp.LibGit2SharpException: reference is not a branch".
Version of LibGit2Sharp (release number or SHA1)
0.27.0-preview-0096
Operating system(s) tested; .NET runtime tested
Windows 10 Version 2004 (OS Build 19041.985) x64
LibGit2SharpWorktreeIssue.zip
The text was updated successfully, but these errors were encountered: