Skip to content

Commit 61de520

Browse files
committed
Wire support for revspec in enumerator
Fixes #146
1 parent 71d6c77 commit 61de520

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

Classes/git/PBGitRevList.mm

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "PBGitGrapher.h"
1313
#import "PBGitRevSpecifier.h"
1414
#import "PBGitBinary.h"
15+
#import "PBError.h"
1516

1617
#import <ObjectiveGit/ObjectiveGit.h>
1718
#import "ObjectiveGit+PBCategories.h"
@@ -169,23 +170,33 @@ - (void) setupEnumerator:(GTEnumerator*)enumerator
169170

170171
// Handle the rest of our (less obvious) parameters
171172
for (NSString *param in parameters) {
173+
GTObject *obj = nil;
172174
if ([param hasPrefix:@"--glob="]) {
173175
success = [enumerator pushGlob:[param substringFromIndex:@"--glob=".length] error:&error];
174-
if (!success) {
175-
NSLog(@"Failed to push glob %@: %@", param, error);
176-
}
176+
} else if ([param isEqualToString:@"HEAD"]) {
177+
success = [enumerator pushHEAD:&error];
178+
} else if ((obj = [repo lookUpObjectByRevParse:param error:&error])) {
179+
success = [enumerator pushSHA:obj.SHA error:&error];
177180
} else {
178-
NSError *lookupError = nil;
179-
GTObject *obj = [repo lookUpObjectByRevParse:param error:&lookupError];
180-
if (obj) {
181-
success = [enumerator pushSHA:obj.SHA error:&error];
181+
int gitError = git_revwalk_push_range(enumerator.git_revwalk, param.UTF8String);
182+
if (gitError != GIT_OK) {
183+
NSString *desc = [NSString stringWithFormat:@"Failed to push range"];
184+
NSString *fail = [NSString stringWithFormat:@"The range %@ couldn't be pushed", param];
185+
error = [NSError errorWithDomain:GTGitErrorDomain
186+
code:gitError
187+
userInfo:@{
188+
NSLocalizedDescriptionKey: desc,
189+
NSLocalizedFailureReasonErrorKey: fail,
190+
}];
191+
success = NO;
182192
} else {
183-
success = [enumerator pushGlob:param error:&error];
184-
}
185-
if (!success) {
186-
NSLog(@"Failed to push remaining parameter %@: %@", param, error);
193+
success = YES;
187194
}
188195
}
196+
197+
if (!success) {
198+
NSLog(@"Failed to push remaining parameter %@: %@", param, error);
199+
}
189200
}
190201

191202
}

0 commit comments

Comments
 (0)