When a slash is included when indexing into a tree to a subtree, the resulting TreeEntry has a path with a duplicated last path part.
using System.Text;
using LibGit2Sharp;
var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
using var repo = new Repository(Repository.Init(path, isBare: true));
var bytes = Encoding.UTF8.GetBytes("Hello, World!");
var blob = repo.ObjectDatabase.CreateBlob(new MemoryStream(bytes));
var td = new TreeDefinition();
td.Add("some/deeply/nested/file", blob, Mode.NonExecutableFile);
var tree = repo.ObjectDatabase.CreateTree(td);
var withSlash = tree["some/deeply/"].Path;
var withoutSlash = tree["some/deeply"].Path;
Console.WriteLine(withSlash); // some/deeply/deeply
Console.WriteLine(withoutSlash); // some/deeply
I was seeing this across Linux and Windows, on versions 0.31 and 0.32 and .NET 10 and Framework 4.8
When a slash is included when indexing into a tree to a subtree, the resulting
TreeEntryhas a path with a duplicated last path part.I was seeing this across Linux and Windows, on versions 0.31 and 0.32 and .NET 10 and Framework 4.8