Skip to content

Commit 39477a1

Browse files
committed
Wrap git_index_add_all
1 parent e3a95be commit 39477a1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ObjectiveGit/GTIndex.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ NS_ASSUME_NONNULL_BEGIN
155155
/// Returns whether reading the tree was successful.
156156
- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error;
157157

158+
/// Add all the content of the working directory to the index. Like `git add -A`
159+
///
160+
/// error - If not NULL, set to any error that occurs.
161+
///
162+
/// Returns whether the operation was successful
163+
- (BOOL)addAll:(NSError **)error;
164+
158165
/// Remove an entry (by relative path) from the index.
159166
/// Will fail if the receiver's repository is nil.
160167
///

ObjectiveGit/GTIndex.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ - (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error {
218218
return YES;
219219
}
220220

221+
- (BOOL)addAll:(NSError **)error {
222+
int status = git_index_add_all(self.git_index, nil, GIT_INDEX_ADD_CHECK_PATHSPEC, nil, nil);
223+
if (status != GIT_OK) {
224+
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to add all the contents of the working tree to the index"];
225+
return NO;
226+
}
227+
228+
return YES;
229+
}
230+
221231
- (BOOL)removeFile:(NSString *)file error:(NSError **)error {
222232
NSString *unicodeString = [self composedUnicodeStringWithString:file];
223233

0 commit comments

Comments
 (0)