8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ce3947 commit b0be581Copy full SHA for b0be581
LibGit2Sharp.Tests/TreeFixture.cs
@@ -92,6 +92,17 @@ public void CanGetEntryByName()
92
}
93
94
95
+ [Test]
96
+ public void GettingAnUknownTreeEntryReturnsNull()
97
+ {
98
+ using (var repo = new Repository(Constants.BareTestRepoPath))
99
100
+ var tree = repo.Lookup<Tree>(sha);
101
+ TreeEntry treeEntry = tree["I-do-not-exist"];
102
+ treeEntry.ShouldBeNull();
103
+ }
104
105
+
106
[Test]
107
public void CanGetEntryCountFromTree()
108
{
LibGit2Sharp/Tree.cs
@@ -24,6 +24,12 @@ public TreeEntry this[string name]
24
using (var obj = new ObjectSafeWrapper(Id, repo))
25
26
IntPtr e = NativeMethods.git_tree_entry_byname(obj.ObjectPtr, name);
27
28
+ if (e == IntPtr.Zero)
29
30
+ return null;
31
32
33
return new TreeEntry(e, Id, repo);
34
35
0 commit comments