Skip to content

Commit aa11226

Browse files
committed
Merge pull request #394 from pbendersky/master
Added success and error information to -[GTIndex clear:]
2 parents bf24a8d + 8ca8597 commit aa11226

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Classes/GTIndex.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@
8989

9090
// Clear all the entries from the index. This happens in memory. Changes can be
9191
// written to the datastore by calling -write:.
92-
- (void)clear;
92+
//
93+
// error - The error if one ocurred.
94+
//
95+
// Returns whether the clear operation was successful.
96+
- (BOOL)clear:(NSError **)error;
9397

9498
// Get the entry at the given index.
9599
//

Classes/GTIndex.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ - (BOOL)refresh:(NSError **)error {
124124
return YES;
125125
}
126126

127-
- (void)clear {
128-
git_index_clear(self.git_index);
127+
- (BOOL)clear:(NSError **)error {
128+
int gitError = git_index_clear(self.git_index);
129+
if (gitError != GIT_OK) {
130+
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to clear index"];
131+
return NO;
132+
}
133+
return YES;
129134
}
130135

131136
- (GTIndexEntry *)entryAtIndex:(NSUInteger)index {

ObjectiveGitTests/GTIndexSpec.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
});
3131

3232
it(@"should clear all entries", ^{
33-
[index clear];
33+
[index clear:NULL];
3434
expect(index.entryCount).to.equal(0);
3535
});
3636

0 commit comments

Comments
 (0)