File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,16 @@ NS_ASSUME_NONNULL_BEGIN
117
117
// / Returns a (possibly empty) array of GTCommits, or nil if an error occurs.
118
118
- (nullable NSArray <GTCommit *> *)allObjectsWithError : (NSError **)error ;
119
119
120
+ // / Get the next OID.
121
+ // /
122
+ // / success - If not NULL, this will be set to whether getting the next object
123
+ // / was successful. This will be YES if the receiver is exhausted, so
124
+ // / it can be used to interpret the meaning of a nil return value.
125
+ // / error - If not NULL, set to any error that occurs during traversal.
126
+ // /
127
+ // / Returns nil if an error occurs or the enumeration is done.
128
+ - (nullable GTOID *)nextOIDWithSuccess : (nullable BOOL *)success error : (NSError **)error ;
129
+
120
130
// / Gets the next commit.
121
131
// /
122
132
// / success - If not NULL, this will be set to whether getting the next object
Original file line number Diff line number Diff line change @@ -145,16 +145,34 @@ - (void)resetWithOptions:(GTEnumeratorOptions)options {
145
145
146
146
#pragma mark Enumerating
147
147
148
- - (GTCommit *)nextObjectWithSuccess : (BOOL *)success error : (NSError **)error {
148
+ - (GTOID *)nextOIDWithSuccess : (BOOL *)success error : (NSError **)error {
149
149
git_oid oid;
150
+
150
151
int gitError = git_revwalk_next (&oid, self.walk );
151
152
if (gitError == GIT_ITEROVER) {
152
153
if (success != NULL ) *success = YES ;
153
154
return nil ;
154
155
}
156
+ if (gitError != GIT_OK) {
157
+ if (success != NULL ) *success = NO ;
158
+ if (error != NULL ) *error = [NSError git_errorFor: gitError description: @" Enumeration failed" ];
159
+ return nil ;
160
+ }
161
+
162
+ if (success != NULL ) *success = YES ;
163
+ return [GTOID oidWithGitOid: &oid];
164
+ }
165
+
166
+ - (GTCommit *)nextObjectWithSuccess : (BOOL *)success error : (NSError **)error {
167
+ GTOID *oid = [self nextOIDWithSuccess: success error: error];
168
+ if (oid == nil ) {
169
+ // We don't care whether the iteration completed, or an error occurred,
170
+ // there's nothing to lookup.
171
+ return nil ;
172
+ }
155
173
156
174
// Ignore error if we can't lookup object and just return nil.
157
- GTCommit *commit = [self .repository lookUpObjectByGitOid: & oid objectType: GTObjectTypeCommit error: error];
175
+ GTCommit *commit = [self .repository lookUpObjectByOID: oid objectType: GTObjectTypeCommit error: error];
158
176
if (success != NULL ) *success = (commit != nil );
159
177
return commit;
160
178
}
You can’t perform that action at this time.
0 commit comments