Skip to content

Commit 021a9a7

Browse files
authored
Merge pull request #651 from libgit2/xcode-9.3
πŸ‘·πŸ»β€β™€οΈπŸ›  Xcode 9.3
2 parents e22dfba + 7895ba9 commit 021a9a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+425
-271
lines changed

β€Ž.travis.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
osx_image: xcode8.3
1+
#
2+
# .travis.yml
3+
# Objective-Git
4+
#
5+
# https://docs.travis-ci.com/user/reference/osx/
6+
# https://docs.travis-ci.com/user/build-stages/matrix-expansion/
7+
#
8+
---
9+
os: osx
10+
osx_image: xcode9.3
211
language: objective-c
12+
313
matrix:
414
fast_finish: true
515
include:
6-
- osx_image: xcode8.3
16+
- osx_image: xcode9.3
717
env:
818
- SCHEME="ObjectiveGit Mac"
9-
- osx_image: xcode8.3
19+
- osx_image: xcode9.3
1020
env:
1121
- SCHEME="ObjectiveGit iOS"
22+
1223
before_install:
1324
- gem install xcpretty
1425
- gem install xcpretty-travis-formatter
1526
install: script/bootstrap
1627
script: script/cibuild
28+
1729
notifications:
1830
email: false

β€ŽCartfile.private

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "jspahrsummers/xcconfigs" >= 0.7.1
2-
github "Quick/Quick" ~> 1.1.0
3-
github "Quick/Nimble" ~> 5.0
4-
github "ZipArchive/ZipArchive" ~> 1.1
1+
github "jspahrsummers/xcconfigs" "master"
2+
github "Quick/Quick" ~> 1.2.0
3+
github "Quick/Nimble" ~> 7.0.3
4+
github "ZipArchive/ZipArchive" ~> 2.1.2

β€ŽCartfile.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "Quick/Nimble" "v5.1.1"
2-
github "Quick/Quick" "v1.1.0"
3-
github "ZipArchive/ZipArchive" "v1.8.1"
4-
github "jspahrsummers/xcconfigs" "0.10"
1+
github "Quick/Nimble" "v7.0.3"
2+
github "Quick/Quick" "v1.2.0"
3+
github "ZipArchive/ZipArchive" "v2.1.2"
4+
github "jspahrsummers/xcconfigs" "bb795558a76e5daf3688500055bbcfe243bffa8d"

β€ŽCarthage/Checkouts/Nimble

Submodule Nimble updated 146 files

β€ŽCarthage/Checkouts/Quick

Submodule Quick updated 46 files

β€ŽCarthage/Checkouts/ZipArchive

Submodule ZipArchive updated 87 files

β€ŽCarthage/Checkouts/xcconfigs

β€ŽObjectiveGit/GTBlob.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ NS_ASSUME_NONNULL_BEGIN
104104
- (git_blob *)git_blob __attribute__((objc_returns_inner_pointer));
105105

106106
- (git_off_t)size;
107-
- (NSString *)content;
108-
- (NSData * _Nullable)data;
107+
- (NSString * _Nullable)content;
108+
- (NSData *)data;
109109

110110
/// Attempts to apply the filter list for `path` to the blob.
111111
///

β€ŽObjectiveGit/GTBranch.m

+34-12
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,23 @@ - (NSString *)remoteName {
124124
}
125125

126126
- (GTCommit *)targetCommitWithError:(NSError **)error {
127-
if (self.OID == nil) {
127+
GTOID *oid = self.OID;
128+
if (oid == nil) {
128129
if (error != NULL) *error = GTReference.invalidReferenceError;
129130
return nil;
130131
}
131132

132-
return [self.repository lookUpObjectByOID:self.OID objectType:GTObjectTypeCommit error:error];
133+
return [self.repository lookUpObjectByOID:oid objectType:GTObjectTypeCommit error:error];
133134
}
134135

135136
- (NSUInteger)numberOfCommitsWithError:(NSError **)error {
136137
GTEnumerator *enumerator = [[GTEnumerator alloc] initWithRepository:self.repository error:error];
137138
if (enumerator == nil) return NSNotFound;
138139

139-
if (![enumerator pushSHA:self.OID.SHA error:error]) return NSNotFound;
140+
GTOID *oid = self.OID;
141+
if (oid == nil) return NSNotFound;
142+
143+
if (![enumerator pushSHA:oid.SHA error:error]) return NSNotFound;
140144
return [enumerator countRemainingObjects:error];
141145
}
142146

@@ -157,7 +161,9 @@ - (BOOL)isHEAD {
157161
}
158162

159163
- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error {
160-
GTEnumerator *enumerator = [self.repository enumeratorForUniqueCommitsFromOID:self.OID relativeToOID:otherBranch.OID error:error];
164+
GTOID *oid = self.OID;
165+
GTOID *otherOID = otherBranch.OID;
166+
GTEnumerator *enumerator = [self.repository enumeratorForUniqueCommitsFromOID:oid relativeToOID:otherOID error:error];
161167
return [enumerator allObjectsWithError:error];
162168
}
163169

@@ -179,14 +185,21 @@ - (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error {
179185
return NO;
180186
}
181187

182-
_reference = [[GTReference alloc] initWithGitReference:git_ref repository:self.repository];
188+
GTReference *renamedRef = [[GTReference alloc] initWithGitReference:git_ref repository:self.repository];
189+
NSAssert(renamedRef, @"Unable to allocate renamed ref");
190+
_reference = renamedRef;
183191

184192
return YES;
185193
}
186194

187195
- (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success {
196+
BOOL underSuccess = NO;
197+
if (success == NULL) {
198+
success = &underSuccess;
199+
}
200+
188201
if (self.branchType == GTBranchTypeRemote) {
189-
if (success != NULL) *success = YES;
202+
*success = YES;
190203
return self;
191204
}
192205

@@ -195,25 +208,32 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success
195208

196209
// GIT_ENOTFOUND means no tracking branch found.
197210
if (gitError == GIT_ENOTFOUND) {
198-
if (success != NULL) *success = YES;
211+
*success = YES;
199212
return nil;
200213
}
201214

202215
if (gitError != GIT_OK) {
203-
if (success != NULL) *success = NO;
216+
*success = NO;
204217
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create reference to tracking branch from %@", self];
205218
return nil;
206219
}
207220

208221
if (trackingRef == NULL) {
209-
if (success != NULL) *success = NO;
222+
*success = NO;
210223
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Got a NULL remote ref for %@", self];
211224
return nil;
212225
}
213226

214-
if (success != NULL) *success = YES;
227+
GTReference *upsteamRef = [[GTReference alloc] initWithGitReference:trackingRef repository:self.repository];
228+
if (upsteamRef == nil) {
229+
*success = NO;
230+
if (error != NULL) *error = [NSError git_errorFor:GIT_ERROR description:@"Failed to allocate upstream ref"];
231+
return nil;
232+
}
233+
234+
*success = YES;
215235

216-
return [[self class] branchWithReference:[[GTReference alloc] initWithGitReference:trackingRef repository:self.repository]];
236+
return [[self class] branchWithReference:upsteamRef];
217237
}
218238

219239
- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error {
@@ -239,7 +259,9 @@ - (GTBranch *)reloadedBranchWithError:(NSError **)error {
239259
}
240260

241261
- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError **)error {
242-
return [self.repository calculateAhead:ahead behind:behind ofOID:self.OID relativeToOID:branch.OID error:error];
262+
GTOID *oid = self.OID;
263+
GTOID *branchOID = branch.OID;
264+
return [self.repository calculateAhead:ahead behind:behind ofOID:oid relativeToOID:branchOID error:error];
243265
}
244266

245267
@end

β€ŽObjectiveGit/GTCheckoutOptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ typedef NS_OPTIONS(NSInteger, GTCheckoutNotifyFlags) {
8787
@property (assign) GTCheckoutStrategyType strategy;
8888

8989
/// The checkout progress block that was passed in.
90-
@property (copy) void (^progressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);
90+
@property (copy, nullable) void (^progressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);
9191

9292
/// The notification flags currently enabled.
9393
@property (assign) GTCheckoutNotifyFlags notifyFlags;
9494

9595
/// The checkout notification block that was passed in.
96-
@property (copy) int (^notifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir);
96+
@property (copy, nullable) int (^notifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir);
9797

9898
/// An array of strings used to restrict what will be checked out.
9999
@property (copy) NSArray <NSString *> *pathSpecs;

β€ŽObjectiveGit/GTConfiguration.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ - (NSArray *)remotes {
134134
NSMutableArray *remotes = [NSMutableArray arrayWithCapacity:names.count];
135135
for (size_t i = 0; i < names.count; i++) {
136136
const char *name = names.strings[i];
137-
git_remote *remote = NULL;
137+
git_remote *git_remote = NULL;
138138

139-
if (git_remote_lookup(&remote, repository.git_repository, name) == 0) {
140-
[remotes addObject:[[GTRemote alloc] initWithGitRemote:remote inRepository:repository]];
139+
if (git_remote_lookup(&git_remote, repository.git_repository, name) == 0) {
140+
GTRemote *remote = [[GTRemote alloc] initWithGitRemote:git_remote inRepository:repository];
141+
if (remote)
142+
[remotes addObject:remote];
141143
}
142144
}
143145

β€ŽObjectiveGit/GTDiffDelta.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ NS_ASSUME_NONNULL_BEGIN
6363
@property (nonatomic, assign, readonly) GTDiffFileFlag flags;
6464

6565
/// The file to the "left" of the diff.
66-
@property (nonatomic, readonly, copy) GTDiffFile *oldFile;
66+
@property (nonatomic, readonly, copy) GTDiffFile * _Nullable oldFile;
6767

6868
/// The file to the "right" of the diff.
69-
@property (nonatomic, readonly, copy) GTDiffFile *newFile __attribute__((ns_returns_not_retained));
69+
@property (nonatomic, readonly, copy) GTDiffFile * _Nullable newFile __attribute__((ns_returns_not_retained));
7070

7171
/// The type of change that this delta represents.
7272
///

β€ŽObjectiveGit/GTDiffHunk.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ - (instancetype)initWithPatch:(GTDiffPatch *)patch hunkIndex:(NSUInteger)hunkInd
4747

4848
_patch = patch;
4949
_hunkIndex = hunkIndex;
50-
_header = [[[NSString alloc] initWithBytes:self.git_hunk->header length:self.git_hunk->header_len encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:NSCharacterSet.newlineCharacterSet];
50+
NSString *hunkHeader = [[[NSString alloc] initWithBytes:self.git_hunk->header length:self.git_hunk->header_len encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:NSCharacterSet.newlineCharacterSet];
51+
NSAssert(hunkHeader != nil, @"Failed to build hunk header");
52+
_header = hunkHeader;
5153

5254
return self;
5355
}

β€ŽObjectiveGit/GTEnumerator.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ - (NSUInteger)countRemainingObjects:(NSError **)error {
259259
#pragma mark NSEnumerator
260260

261261
- (NSArray *)allObjects {
262-
return [self allObjectsWithError:NULL];
262+
NSArray *objects = [self allObjectsWithError:NULL];
263+
return objects ? objects : [NSArray array];
263264
}
264265

265266
- (id)nextObject {

β€ŽObjectiveGit/GTFilter.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ static void GTFilterShutdown(git_filter *filter) {
9696

9797
static int GTFilterCheck(git_filter *filter, void **payload, const git_filter_source *src, const char **attr_values) {
9898
GTFilter *self = GTFiltersGitFilterToRegisteredFilters[[NSValue valueWithPointer:filter]];
99-
BOOL accept = self.checkBlock(payload, [[GTFilterSource alloc] initWithGitFilterSource:src], attr_values);
99+
GTFilterSource *source = [[GTFilterSource alloc] initWithGitFilterSource:src];
100+
NSCAssert(source != nil, @"Unexpected nil filter source");
101+
BOOL accept = self.checkBlock(payload, source, attr_values);
100102
return accept ? 0 : GIT_PASSTHROUGH;
101103
}
102104

β€ŽObjectiveGit/GTIndex.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ - (GTTree *)writeTreeToRepository:(GTRepository *)repository error:(NSError **)e
278278
- (NSArray *)entries {
279279
NSMutableArray *entries = [NSMutableArray arrayWithCapacity:self.entryCount];
280280
for (NSUInteger i = 0; i < self.entryCount; i++) {
281-
[entries addObject:[self entryAtIndex:i]];
281+
GTIndexEntry *entry = [self entryAtIndex:i];
282+
if (entry)
283+
[entries addObject:entry];
282284
}
283285

284286
return entries;

β€ŽObjectiveGit/GTOID.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
1616
@interface GTOID : NSObject <NSCopying>
1717

1818
/// The SHA pointed to by the OID.
19-
@property (nonatomic, readonly, copy) NSString * _Nullable SHA;
19+
@property (nonatomic, readonly, copy) NSString *SHA;
2020

2121
/// Is the OID all zero? This usually indicates that the object has not been
2222
/// inserted into the ODB yet.

β€ŽObjectiveGit/GTOID.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ - (instancetype)initWithGitOid:(const git_oid *)oid {
5555

5656
- (instancetype)initWithSHA:(NSString *)SHA error:(NSError **)error {
5757
NSParameterAssert(SHA != nil);
58-
return [self initWithSHACString:SHA.UTF8String error:error];
58+
const char *SHACString = SHA.UTF8String;
59+
NSAssert(SHACString, @"Unexpected nil SHA");
60+
return [self initWithSHACString:SHACString error:error];
5961
}
6062

6163
- (instancetype)initWithSHA:(NSString *)SHA {

β€ŽObjectiveGit/GTObject.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ NS_ASSUME_NONNULL_BEGIN
5252
@interface GTObject : NSObject
5353

5454
@property (nonatomic, readonly) NSString *type;
55-
@property (nonatomic, readonly) NSString * _Nullable SHA;
56-
@property (nonatomic, readonly) NSString * _Nullable shortSHA;
55+
@property (nonatomic, readonly) NSString *SHA;
56+
@property (nonatomic, readonly) NSString *shortSHA;
5757
@property (nonatomic, readonly, strong) GTRepository *repository;
58-
@property (nonatomic, readonly) GTOID * _Nullable OID;
58+
@property (nonatomic, readonly) GTOID *OID;
5959

6060
- (instancetype)init NS_UNAVAILABLE;
6161

β€ŽObjectiveGit/GTObject.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ + (id)objectWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo
123123
}
124124

125125
- (NSString *)type {
126-
return [NSString stringWithUTF8String:git_object_type2string(git_object_type(self.git_object))];
126+
NSString *type = [NSString stringWithUTF8String:git_object_type2string(git_object_type(self.git_object))];
127+
NSAssert(type != nil, @"type was nil");
128+
return type;
127129
}
128130

129131
- (GTOID *)OID {

β€ŽObjectiveGit/GTReference.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
6767
@property (nonatomic, readonly, getter = isNote) BOOL note;
6868

6969
/// The reflog for the reference.
70-
@property (nonatomic, readonly, strong) GTReflog *reflog;
70+
@property (nonatomic, readonly, strong) GTReflog * _Nullable reflog;
7171

7272
/// Convenience initializers
7373
+ (instancetype _Nullable)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
@@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
9696
@property (nonatomic, readonly, copy) GTReference *resolvedReference;
9797

9898
/// The OID of the target object.
99-
@property (nonatomic, readonly, copy) GTOID *targetOID;
99+
@property (nonatomic, readonly, copy, nullable) GTOID *targetOID;
100100

101101
/// Updates the on-disk reference to point to the target and returns the updated
102102
/// reference.
@@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
112112
- (GTReference * _Nullable)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString * _Nullable)message error:(NSError **)error;
113113

114114
/// The name of the reference.
115-
@property (nonatomic, readonly, copy) NSString * _Nullable name;
115+
@property (nonatomic, readonly, copy) NSString *name;
116116

117117
/// Updates the on-disk reference to the name and returns the renamed reference.
118118
///

β€ŽObjectiveGit/GTReference.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ - (BOOL)isNote {
119119

120120
- (NSString *)name {
121121
const char *refName = git_reference_name(self.git_reference);
122-
if (refName == NULL) return nil;
122+
NSAssert(refName != nil, @"Unexpected nil name");
123123

124124
return @(refName);
125125
}
@@ -166,7 +166,8 @@ - (id)resolvedTarget {
166166
}
167167

168168
- (GTReference *)resolvedReference {
169-
return [self.class referenceByResolvingSymbolicReference:self error:NULL];
169+
GTReference *resolvedReference = [self.class referenceByResolvingSymbolicReference:self error:NULL];
170+
return resolvedReference ? resolvedReference : self;
170171
}
171172

172173
- (GTOID *)targetOID {

β€ŽObjectiveGit/GTRepository.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
417417
/// defaults will be used instead. Will never return nil.
418418
///
419419
/// Returns the signature.
420-
- (GTSignature *)userSignatureForNow;
420+
- (GTSignature * _Nullable)userSignatureForNow;
421421

422422
/// Enumerates over all the tracked submodules in the repository.
423423
///

β€ŽObjectiveGit/GTRepository.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ - (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceiling
196196
if (idx < ceilingDirURLs.count - 1) {
197197
[ceilingDirsString appendString:[NSString stringWithFormat:@"%@%c", url.path, GIT_PATH_LIST_SEPARATOR]];
198198
} else {
199-
[ceilingDirsString appendString:url.path];
199+
NSString *path = url.path;
200+
NSAssert(path != nil, @"Unexpected nil path component");
201+
[ceilingDirsString appendString:path];
200202
}
201203
}];
202204
}

0 commit comments

Comments
Β (0)