File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,17 @@ public void CanGetEntryByName()
92
92
}
93
93
}
94
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
+
95
106
[ Test ]
96
107
public void CanGetEntryCountFromTree ( )
97
108
{
Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ public TreeEntry this[string name]
24
24
using ( var obj = new ObjectSafeWrapper ( Id , repo ) )
25
25
{
26
26
IntPtr e = NativeMethods . git_tree_entry_byname ( obj . ObjectPtr , name ) ;
27
+
28
+ if ( e == IntPtr . Zero )
29
+ {
30
+ return null ;
31
+ }
32
+
27
33
return new TreeEntry ( e , Id , repo ) ;
28
34
}
29
35
}
You can’t perform that action at this time.
0 commit comments