4
4
5
5
namespace LibGit2Sharp
6
6
{
7
+ /// <summary>
8
+ /// Representation of an entry in a <see cref="Tree"/>.
9
+ /// </summary>
7
10
public class TreeEntry : IEquatable < TreeEntry >
8
11
{
9
12
private readonly ObjectId parentTreeId ;
@@ -14,29 +17,46 @@ public class TreeEntry : IEquatable<TreeEntry>
14
17
private static readonly LambdaEqualityHelper < TreeEntry > equalityHelper =
15
18
new LambdaEqualityHelper < TreeEntry > ( new Func < TreeEntry , object > [ ] { x => x . Name , x => x . parentTreeId } ) ;
16
19
17
- public TreeEntry ( IntPtr obj , ObjectId parentTreeId , Repository repo )
20
+ internal TreeEntry ( IntPtr obj , ObjectId parentTreeId , Repository repo )
18
21
{
19
22
this . parentTreeId = parentTreeId ;
20
23
this . repo = repo ;
21
24
IntPtr gitTreeEntryId = NativeMethods . git_tree_entry_id ( obj ) ;
22
25
targetOid = new ObjectId ( ( GitOid ) Marshal . PtrToStructure ( gitTreeEntryId , typeof ( GitOid ) ) ) ;
26
+ Type = NativeMethods . git_tree_entry_type ( obj ) ;
23
27
24
28
Attributes = NativeMethods . git_tree_entry_attributes ( obj ) ;
25
29
Name = NativeMethods . git_tree_entry_name ( obj ) . MarshallAsString ( ) ;
26
30
}
27
31
32
+ /// <summary>
33
+ /// Gets the UNIX file attributes.
34
+ /// </summary>
28
35
public int Attributes { get ; private set ; }
29
-
36
+
37
+ /// <summary>
38
+ /// Gets the filename.
39
+ /// <para>The filename is expressed in a relative form. Path segments are separated with a forward slash."/></para>
40
+ /// </summary>
30
41
public string Name { get ; private set ; }
31
42
43
+ /// <summary>
44
+ /// Gets the <see cref="GitObject"/> being pointed at.
45
+ /// </summary>
32
46
public GitObject Target { get { return target ?? ( target = RetreiveTreeEntryTarget ( ) ) ; } }
33
47
48
+ /// <summary>
49
+ /// Gets the <see cref="GitObjectType"/> of the <see cref="Target"/> being pointed at.
50
+ /// </summary>
51
+ public GitObjectType Type { get ; private set ; }
52
+
34
53
private GitObject RetreiveTreeEntryTarget ( )
35
54
{
36
55
GitObject treeEntryTarget = repo . Lookup ( targetOid ) ;
37
56
57
+ //TODO: Warning submodules will appear as targets of type Commit
38
58
Ensure . ArgumentConformsTo ( treeEntryTarget . GetType ( ) , t => typeof ( Blob ) . IsAssignableFrom ( t ) || typeof ( Tree ) . IsAssignableFrom ( t ) , "treeEntryTarget" ) ;
39
4FED
code>
-
59
+
40
60
return treeEntryTarget ;
41
61
}
42
62
0 commit comments