Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Classes/GTIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
9 changes: 7 additions & 2 deletions Classes/GTIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGitTests/GTIndexSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
});

it(@"should clear all entries", ^{
[index clear];
[index clear:NULL];
expect(index.entryCount).to.equal(0);
});

Expand Down