Skip to content

Commit 75e5356

Browse files
committed
Merge remote-tracking branch 'upstream/master' into git-notes
2 parents 73037a4 + 4673546 commit 75e5356

File tree

19 files changed

+136
-29
lines changed

19 files changed

+136
-29
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
osx_image: xcode7
1+
osx_image: xcode8
22
language: objective-c
33
matrix:
44
fast_finish: true
55
include:
6-
- osx_image: xcode7.3
6+
- osx_image: xcode8
77
env:
88
- SCHEME="ObjectiveGit Mac"
9-
- osx_image: xcode7.3
9+
- osx_image: xcode8
1010
env:
1111
- SCHEME="ObjectiveGit iOS"
1212
before_install:

Cartfile.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "Quick/Nimble" "v4.0.0"
2-
github "Quick/Quick" "v0.9.2"
3-
github "ZipArchive/ZipArchive" "v1.1"
1+
github "Quick/Nimble" "v4.1.0"
2+
github "Quick/Quick" "v0.9.3"
3+
github "ZipArchive/ZipArchive" "v1.6.2"
44
github "jspahrsummers/xcconfigs" "0.9"

Carthage/Checkouts/ZipArchive

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2012 libgit2 contributors
3+
Copyright (c) 2016 libgit2 contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

ObjectiveGit/Categories/NSError+Git.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929

3030
#import <Foundation/Foundation.h>
3131

32+
/// The error domain used by Objective-Git
3233
extern NSString * const GTGitErrorDomain;
3334

35+
/// Error userinfo keys
36+
extern NSString * const GTGitErrorOID;
37+
3438
@interface NSError (Git)
3539

3640
/// Describes the given libgit2 error code, using any message provided by

ObjectiveGit/Categories/NSError+Git.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "git2/errors.h"
3232

3333
NSString * const GTGitErrorDomain = @"GTGitErrorDomain";
34+
NSString * const GTGitErrorOID = @"GTOID";
3435

3536
@implementation NSError (Git)
3637

ObjectiveGit/GTEnumerator.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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

ObjectiveGit/GTEnumerator.m

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)