2929
3030#import < Foundation/Foundation.h>
3131#include " git2/index.h"
32+ #import " GTObject.h"
33+
34+ @class GTIndex;
3235
3336typedef NS_ENUM (NSInteger , GTIndexEntryStatus) {
3437 GTIndexEntryStatusUpdated = 0 ,
@@ -40,6 +43,22 @@ typedef NS_ENUM(NSInteger, GTIndexEntryStatus) {
4043
4144@interface GTIndexEntry : NSObject
4245
46+ // / Initializes the receiver with the given libgit2 index entry.
47+ // /
48+ // / entry - The libgit2 index entry. Cannot be NULL.
49+ // / index - The index this entry belongs to.
50+ // / error - will be filled if an error occurs
51+ // /
52+ // / Returns the initialized object.
53+ - (instancetype )initWithGitIndexEntry : (const git_index_entry *)entry index : (GTIndex *)index error : (NSError **)error NS_DESIGNATED_INITIALIZER;
54+ - (instancetype )initWithGitIndexEntry : (const git_index_entry *)entry ;
55+
56+ // / The underlying `git_index_entry` object.
57+ - (const git_index_entry *)git_index_entry __attribute__((objc_returns_inner_pointer));
58+
59+ // / The entry's index. This may be nil if nil is passed in to -initWithGitIndexEntry:
60+ @property (nonatomic, strong, readonly) GTIndex *index;
61+
4362// / The repository-relative path for the entry.
4463@property (nonatomic , readonly , copy ) NSString *path;
4564
@@ -49,14 +68,21 @@ typedef NS_ENUM(NSInteger, GTIndexEntryStatus) {
4968// / What is the entry's status?
5069@property (nonatomic , readonly ) GTIndexEntryStatus status;
5170
52- // / Initializes the receiver with the given libgit2 index entry.
71+ // / The OID of the entry.
72+ @property (nonatomic , strong , readonly ) GTOID *OID;
73+
74+ // / Convert the entry into an GTObject
5375// /
54- // / entry - The libgit2 index entry. Cannot be NULL.
76+ // / error - will be filled if an error occurs
5577// /
56- // / Returns the initialized object .
57- - (id ) initWithGitIndexEntry : ( const git_index_entry *) entry NS_DESIGNATED_INITIALIZER ;
78+ // / Returns this entry as a GTObject or nil if an error occurred .
79+ - (GTObject *) GTObject : ( NSError **) error ;
5880
59- // / The underlying `git_index_entry` object.
60- - (const git_index_entry *)git_index_entry __attribute__((objc_returns_inner_pointer));
81+ @end
82+
83+ @interface GTObject (GTIndexEntry)
84+
85+ + (instancetype )objectWithIndexEntry : (GTIndexEntry *)treeEntry error : (NSError **)error ;
86+ - (instancetype )initWithIndexEntry : (GTIndexEntry *)treeEntry error : (NSError **)error ;
6187
6288@end
0 commit comments