diff --git a/Classes/GTIndex.h b/Classes/GTIndex.h index ca8de4360..15c8aab69 100644 --- a/Classes/GTIndex.h +++ b/Classes/GTIndex.h @@ -89,7 +89,11 @@ // Clear all the entries from the index. This happens in memory. Changes can be // written to the datastore by calling -write:. -- (void)clear; +// +// error - The error if one ocurred. +// +// Returns whether the clear operation was successful. +- (BOOL)clear:(NSError **)error; // Get the entry at the given index. // diff --git a/Classes/GTIndex.m b/Classes/GTIndex.m index d6c61fafb..892ec0422 100644 --- a/Classes/GTIndex.m +++ b/Classes/GTIndex.m @@ -124,8 +124,13 @@ - (BOOL)refresh:(NSError **)error { return YES; } -- (void)clear { - git_index_clear(self.git_index); +- (BOOL)clear:(NSError **)error { + int gitError = git_index_clear(self.git_index); + if (gitError != GIT_OK) { + if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to clear index"]; + return NO; + } + return YES; } - (GTIndexEntry *)entryAtIndex:(NSUInteger)index { diff --git a/ObjectiveGitTests/GTIndexSpec.m b/ObjectiveGitTests/GTIndexSpec.m index eee8d32bf..f9b11f288 100644 --- a/ObjectiveGitTests/GTIndexSpec.m +++ b/ObjectiveGitTests/GTIndexSpec.m @@ -30,7 +30,7 @@ }); it(@"should clear all entries", ^{ - [index clear]; + [index clear:NULL]; expect(index.entryCount).to.equal(0); });