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 ,
@@ -42,6 +45,22 @@ NS_ASSUME_NONNULL_BEGIN
4245
4346@interface GTIndexEntry : NSObject
4447
48+ // / Initializes the receiver with the given libgit2 index entry.
49+ // /
50+ // / entry - The libgit2 index entry. Cannot be NULL.
51+ // / index - The index this entry belongs to.
52+ // / error - will be filled if an error occurs
53+ // /
54+ // / Returns the initialized object.
55+ - (instancetype )initWithGitIndexEntry : (const git_index_entry *)entry index : (GTIndex *)index error : (NSError **)error NS_DESIGNATED_INITIALIZER;
56+ - (instancetype )initWithGitIndexEntry : (const git_index_entry *)entry ;
57+
58+ // / The underlying `git_index_entry` object.
59+ - (const git_index_entry *)git_index_entry __attribute__((objc_returns_inner_pointer));
60+
61+ // / The entry's index. This may be nil if nil is passed in to -initWithGitIndexEntry:
62+ @property (nonatomic, strong, readonly) GTIndex *index;
63+
4564// / The repository-relative path for the entry.
4665@property (nonatomic , readonly , copy ) NSString *path;
4766
@@ -51,15 +70,22 @@ NS_ASSUME_NONNULL_BEGIN
5170// / What is the entry's status?
5271@property (nonatomic , readonly ) GTIndexEntryStatus status;
5372
54- // / Initializes the receiver with the given libgit2 index entry. Designated initializer.
73+ // / The OID of the entry.
74+ @property (nonatomic , strong , readonly ) GTOID *OID;
75+
76+ // / Convert the entry into an GTObject
5577// /
56- // / entry - The libgit2 index entry. Cannot be NULL.
78+ // / error - will be filled if an error occurs
5779// /
58- // / Returns the initialized object .
59- - (nullable instancetype ) initWithGitIndexEntry : ( const git_index_entry *) entry NS_DESIGNATED_INITIALIZER ;
80+ // / Returns this entry as a GTObject or nil if an error occurred .
81+ - (GTObject *) GTObject : ( NSError **) error ;
6082
61- // / The underlying `git_index_entry` object.
62- - (const git_index_entry *)git_index_entry __attribute__((objc_returns_inner_pointer));
83+ @end
84+
85+ @interface GTObject (GTIndexEntry)
86+
87+ + (instancetype )objectWithIndexEntry : (GTIndexEntry *)treeEntry error : (NSError **)error ;
88+ - (instancetype )initWithIndexEntry : (GTIndexEntry *)treeEntry error : (NSError **)error ;
6389
6490@end
6591
0 commit comments