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
117117// / Returns a (possibly empty) array of GTCommits, or nil if an error occurs.
118118- (nullable NSArray <GTCommit *> *)allObjectsWithError : (NSError **)error ;
119119
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+
120130// / Gets the next commit.
121131// /
122132// / 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 {
145145
146146#pragma mark Enumerating
147147
148- - (GTCommit *)nextObjectWithSuccess : (BOOL *)success error : (NSError **)error {
148+ - (GTOID *)nextOIDWithSuccess : (BOOL *)success error : (NSError **)error {
149149 git_oid oid;
150+
150151 int gitError = git_revwalk_next (&oid, self.walk );
151152 if (gitError == GIT_ITEROVER) {
152153 if (success != NULL ) *success = YES ;
153154 return nil ;
154155 }
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+ }
155173
156174 // 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];
158176 if (success != NULL ) *success = (commit != nil );
159177 return commit;
160178}
You can’t perform that action at this time.
0 commit comments