Skip to content

Commit 9594659

Browse files
committed
Add documentation on addData
1 parent 16a57f0 commit 9594659

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

ObjectiveGit/GTIndex.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
- (GTIndexEntry *)entryWithName:(NSString *)name error:(NSError **)error;
116116

117117
///TODO: Document
118+
/// Get the
118119
- (NSData *)dataWithName:(NSString *)name error:(NSError **)error;
119120

120121
/// Add an entry to the index.
@@ -138,6 +139,14 @@
138139
/// Returns YES if successful, NO otherwise.
139140
- (BOOL)addFile:(NSString *)file error:(NSError **)error;
140141

142+
/// Add an entry (with the provided data and name) to the index.
143+
/// Will fail if the receiver's repository is nil.
144+
///
145+
/// data - The content of the entry to add
146+
/// name - The name of the entry to add
147+
/// error - The error if one occurred.
148+
- (BOOL)addData:(NSData *)data withName:(NSString *)name error:(NSError **)error;
149+
141150
/// Reads the contents of the given tree into the index.
142151
///
143152
/// tree - The tree to add to the index. This must not be nil.
@@ -146,9 +155,6 @@
146155
/// Returns whether reading the tree was successful.
147156
- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error;
148157

149-
///TODO: Document
150-
- (BOOL)addData:(NSData *)data withName:(NSString *)name error:(NSError **)error;
151-
152158
/// Remove an entry (by relative path) from the index.
153159
/// Will fail if the receiver's repository is nil.
154160
///

ObjectiveGit/GTIndex.m

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ - (void)dealloc {
7777

7878
+ (instancetype)inMemoryIndexWithRepository:(GTRepository *)repository error:(NSError **)error {
7979
git_index *index = NULL;
80+
8081
int status = git_index_new(&index);
8182
if (status != GIT_OK) {
8283
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to initialize in-memory index"];
@@ -193,17 +194,6 @@ - (BOOL)addFile:(NSString *)file error:(NSError **)error {
193194
return YES;
194195
}
195196

196-
- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error {
197-
NSParameterAssert(tree != nil);
198-
199-
int status = git_index_read_tree(self.git_index, tree.git_tree);
200-
if (status != GIT_OK) {
201-
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to read tree %@ into index.", tree];
202-
return NO;
203-
}
204-
205-
return YES;
206-
}
207197
- (BOOL)addData:(NSData *)data withName:(NSString *)name error:(NSError **)error {
208198
NSParameterAssert(data != nil);
209199
NSParameterAssert(name != nil);
@@ -223,6 +213,18 @@ - (BOOL)addData:(NSData *)data withName:(NSString *)name error:(NSError **)error
223213
return YES;
224214
}
225215

216+
- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error {
217+
NSParameterAssert(tree != nil);
218+
219+
int status = git_index_read_tree(self.git_index, tree.git_tree);
220+
if (status != GIT_OK) {
221+
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to read tree %@ into index.", tree];
222+
return NO;
223+
}
224+
225+
return YES;
226+
}
227+
226228
- (BOOL)removeFile:(NSString *)file error:(NSError **)error {
227229
NSString *unicodeString = [self composedUnicodeStringWithString:file];
228230

0 commit comments

Comments
 (0)