Indexing a tree by path yields different result with trailing slash
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Reproduce the discrepancy using the provided TreeDefinition and tree indexer example, comparing the paths returned for "some/deeply/" and "some/deeply". Trace the TreeEntry path construction for indexed subtrees and add a regression test covering both inputs. Done means trailing-slash indexing returns the same non-duplicated path as the equivalent path without the slash.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from libgit2/libgit2sharp
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
libgit2/libgit2sharp#2193 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
libgit2/libgit2sharp#2192 · 1 comment ·
-
Website is down Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
libgit2/libgit2sharp#2191 · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
libgit2/libgit2sharp#2187 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
libgit2/libgit2sharp#2184 · 1 comment ·
All issues in libgit2/libgit2sharp
Similar issues
-
Status: Waiting triage Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nanoframework/Home#1857 ·
-
kind/bug kind/regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno.toolkit.ui#1646 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
elastic/esql-dotnet#47 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100