From 1efc9f8aa0f33f809fdd499e3c17ed719a769449 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 7 May 2021 23:38:11 +0200 Subject: [PATCH 01/12] Fix double quotes in our headers --- ObjectiveGit/Categories/NSArray+StringArray.h | 2 +- ObjectiveGit/Categories/NSData+Git.h | 4 ++-- ObjectiveGit/Categories/NSDate+GTTimeAdditions.h | 2 +- ObjectiveGit/GTDiffDelta.h | 4 ++-- ObjectiveGit/GTOID.h | 4 ++-- ObjectiveGit/GTObject.h | 2 +- ObjectiveGit/GTReflogEntry+Private.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ObjectiveGit/Categories/NSArray+StringArray.h b/ObjectiveGit/Categories/NSArray+StringArray.h index 026521ba2..119e894d1 100644 --- a/ObjectiveGit/Categories/NSArray+StringArray.h +++ b/ObjectiveGit/Categories/NSArray+StringArray.h @@ -7,7 +7,7 @@ // #import -#import "git2/strarray.h" +#import @interface NSArray (StringArray) diff --git a/ObjectiveGit/Categories/NSData+Git.h b/ObjectiveGit/Categories/NSData+Git.h index ddc2a91e4..7f9de6c6b 100644 --- a/ObjectiveGit/Categories/NSData+Git.h +++ b/ObjectiveGit/Categories/NSData+Git.h @@ -3,8 +3,8 @@ // #import -#import "git2/buffer.h" -#import "git2/oid.h" +#import +#import @interface NSData (Git) diff --git a/ObjectiveGit/Categories/NSDate+GTTimeAdditions.h b/ObjectiveGit/Categories/NSDate+GTTimeAdditions.h index e87210310..e219be506 100644 --- a/ObjectiveGit/Categories/NSDate+GTTimeAdditions.h +++ b/ObjectiveGit/Categories/NSDate+GTTimeAdditions.h @@ -7,7 +7,7 @@ // #import -#import "git2/types.h" +#import @interface NSDate (GTTimeAdditions) diff --git a/ObjectiveGit/GTDiffDelta.h b/ObjectiveGit/GTDiffDelta.h index 35b8969b3..2ea104166 100644 --- a/ObjectiveGit/GTDiffDelta.h +++ b/ObjectiveGit/GTDiffDelta.h @@ -7,8 +7,8 @@ // #import -#import "git2/diff.h" -#import "GTDiffFile.h" +#import +#import @class GTBlob; @class GTDiff; diff --git a/ObjectiveGit/GTOID.h b/ObjectiveGit/GTOID.h index ab0590ee7..bd0502990 100644 --- a/ObjectiveGit/GTOID.h +++ b/ObjectiveGit/GTOID.h @@ -7,8 +7,8 @@ // #import -#import "git2/oid.h" -#import "GTObject.h" +#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/ObjectiveGit/GTObject.h b/ObjectiveGit/GTObject.h index a74ed418c..3167dc139 100644 --- a/ObjectiveGit/GTObject.h +++ b/ObjectiveGit/GTObject.h @@ -28,7 +28,7 @@ // #import -#import "git2/types.h" +#import typedef NS_ENUM(int, GTObjectType) { GTObjectTypeAny = GIT_OBJECT_ANY, /**< Object can be any of the following */ diff --git a/ObjectiveGit/GTReflogEntry+Private.h b/ObjectiveGit/GTReflogEntry+Private.h index b30415160..498bb4860 100644 --- a/ObjectiveGit/GTReflogEntry+Private.h +++ b/ObjectiveGit/GTReflogEntry+Private.h @@ -23,4 +23,4 @@ NS_ASSUME_NONNULL_BEGIN @end -NS_ASSUME_NONNULL_END \ No newline at end of file +NS_ASSUME_NONNULL_END From 24290f210d375b18b819ffeff5e713e48aeab854 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 7 May 2021 23:16:37 +0200 Subject: [PATCH 02/12] Globally add __autoreleasing to NSError parameters --- ObjectiveGit/Categories/NSData+Git.h | 2 +- ObjectiveGit/Categories/NSData+Git.m | 2 +- ObjectiveGit/GTBlob.h | 14 +-- ObjectiveGit/GTBlob.m | 16 +-- ObjectiveGit/GTBranch.h | 18 ++-- ObjectiveGit/GTBranch.m | 18 ++-- ObjectiveGit/GTCommit.h | 2 +- ObjectiveGit/GTCommit.m | 2 +- ObjectiveGit/GTConfiguration.h | 2 +- ObjectiveGit/GTConfiguration.m | 2 +- ObjectiveGit/GTCredential.h | 6 +- ObjectiveGit/GTCredential.m | 6 +- ObjectiveGit/GTDiff.h | 16 +-- ObjectiveGit/GTDiff.m | 16 +-- ObjectiveGit/GTDiffDelta.h | 8 +- ObjectiveGit/GTDiffDelta.m | 8 +- ObjectiveGit/GTDiffFile.h | 2 +- ObjectiveGit/GTDiffHunk.h | 2 +- ObjectiveGit/GTDiffHunk.m | 2 +- ObjectiveGit/GTEnumerator.h | 26 ++--- ObjectiveGit/GTEnumerator.m | 26 ++--- ObjectiveGit/GTFilter.h | 4 +- ObjectiveGit/GTFilter.m | 4 +- ObjectiveGit/GTFilterList.h | 6 +- ObjectiveGit/GTFilterList.m | 6 +- ObjectiveGit/GTIndex.h | 34 +++--- ObjectiveGit/GTIndex.m | 34 +++--- ObjectiveGit/GTIndexEntry.h | 8 +- ObjectiveGit/GTIndexEntry.m | 8 +- ObjectiveGit/GTNote.h | 6 +- ObjectiveGit/GTNote.m | 6 +- ObjectiveGit/GTOID.h | 6 +- ObjectiveGit/GTOID.m | 6 +- ObjectiveGit/GTObject.h | 4 +- ObjectiveGit/GTObject.m | 4 +- ObjectiveGit/GTObjectDatabase.h | 10 +- ObjectiveGit/GTObjectDatabase.m | 10 +- ObjectiveGit/GTReference.h | 14 +-- ObjectiveGit/GTReference.m | 14 +-- ObjectiveGit/GTReflog.h | 2 +- ObjectiveGit/GTReflog.m | 2 +- ObjectiveGit/GTRemote.h | 12 +-- ObjectiveGit/GTRemote.m | 12 +-- ObjectiveGit/GTRepository+Blame.h | 2 +- ObjectiveGit/GTRepository+Blame.m | 2 +- ObjectiveGit/GTRepository+Committing.h | 4 +- ObjectiveGit/GTRepository+Committing.m | 4 +- ObjectiveGit/GTRepository+Merging.h | 10 +- ObjectiveGit/GTRepository+Merging.m | 12 +-- ObjectiveGit/GTRepository+Private.h | 4 +- ObjectiveGit/GTRepository+Pull.h | 2 +- ObjectiveGit/GTRepository+Pull.m | 2 +- ObjectiveGit/GTRepository+References.h | 2 +- ObjectiveGit/GTRepository+References.m | 2 +- ObjectiveGit/GTRepository+RemoteOperations.h | 14 +-- ObjectiveGit/GTRepository+RemoteOperations.m | 16 +-- ObjectiveGit/GTRepository+Reset.h | 4 +- ObjectiveGit/GTRepository+Reset.m | 4 +- ObjectiveGit/GTRepository+Stashing.h | 8 +- ObjectiveGit/GTRepository+Stashing.m | 8 +- ObjectiveGit/GTRepository+Status.h | 8 +- ObjectiveGit/GTRepository+Status.m | 8 +- ObjectiveGit/GTRepository.h | 96 ++++++++--------- ObjectiveGit/GTRepository.m | 106 +++++++++---------- ObjectiveGit/GTSubmodule.h | 16 +-- ObjectiveGit/GTSubmodule.m | 16 +-- ObjectiveGit/GTTag.h | 4 +- ObjectiveGit/GTTag.m | 4 +- ObjectiveGit/GTTree.h | 6 +- ObjectiveGit/GTTree.m | 8 +- ObjectiveGit/GTTreeBuilder.h | 10 +- ObjectiveGit/GTTreeBuilder.m | 10 +- ObjectiveGit/GTTreeEntry.h | 10 +- ObjectiveGit/GTTreeEntry.m | 10 +- 74 files changed, 410 insertions(+), 410 deletions(-) diff --git a/ObjectiveGit/Categories/NSData+Git.h b/ObjectiveGit/Categories/NSData+Git.h index 7f9de6c6b..70b26cccb 100644 --- a/ObjectiveGit/Categories/NSData+Git.h +++ b/ObjectiveGit/Categories/NSData+Git.h @@ -9,7 +9,7 @@ @interface NSData (Git) + (NSData *)git_dataWithOid:(git_oid *)oid; -- (BOOL)git_getOid:(git_oid *)oid error:(NSError **)error; +- (BOOL)git_getOid:(git_oid *)oid error:(NSError * __autoreleasing *)error; /// Creates an NSData object that will take ownership of a libgit2 buffer. /// diff --git a/ObjectiveGit/Categories/NSData+Git.m b/ObjectiveGit/Categories/NSData+Git.m index 6498dfbe0..cf8d70371 100644 --- a/ObjectiveGit/Categories/NSData+Git.m +++ b/ObjectiveGit/Categories/NSData+Git.m @@ -13,7 +13,7 @@ + (NSData *)git_dataWithOid:(git_oid *)oid { return [NSData dataWithBytes:oid length:sizeof(git_oid)]; } -- (BOOL)git_getOid:(git_oid *)oid error:(NSError **)error { +- (BOOL)git_getOid:(git_oid *)oid error:(NSError * __autoreleasing *)error { if ([self length] != sizeof(git_oid)) { if (error != NULL) { *error = [NSError errorWithDomain:GTGitErrorDomain diff --git a/ObjectiveGit/GTBlob.h b/ObjectiveGit/GTBlob.h index 6865ee8a6..5c617558f 100644 --- a/ObjectiveGit/GTBlob.h +++ b/ObjectiveGit/GTBlob.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Return a newly created blob object, or nil if an error occurs. -+ (instancetype _Nullable)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error; ++ (instancetype _Nullable)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Creates a new blob from the given data. /// @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Return a newly created blob object, or nil if an error occurs. -+ (instancetype _Nullable)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error; ++ (instancetype _Nullable)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Creates a new blob given an NSURL to a file. /// @@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Return a newly created blob object, or nil if an error occurs. -+ (instancetype _Nullable)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error; ++ (instancetype _Nullable)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Creates a new blob from the given string. /// @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Return a newly created blob object, or nil if an error occurs. -- (instancetype _Nullable)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error; +- (instancetype _Nullable)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Creates a new blob from the passed data. /// @@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Returns a newly created blob object, or nil if an error occurs. -- (instancetype _Nullable)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error; +- (instancetype _Nullable)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Creates a new blob from the specified file. /// @@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be set if an error occurs. This may be nil. /// /// Returns a newly created blob object, or nil if an error occurs. -- (instancetype _Nullable)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error; +- (instancetype _Nullable)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// The underlying `git_object` as a `git_blob` object. - (git_blob *)git_blob __attribute__((objc_returns_inner_pointer)); @@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the filtered data, or nil if an error occurs. -- (NSData * _Nullable)applyFiltersForPath:(NSString *)path error:(NSError **)error; +- (NSData * _Nullable)applyFiltersForPath:(NSString *)path error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTBlob.m b/ObjectiveGit/GTBlob.m index a1634dcf5..6f2d1e8cb 100644 --- a/ObjectiveGit/GTBlob.m +++ b/ObjectiveGit/GTBlob.m @@ -46,19 +46,19 @@ - (NSString *)description { #pragma mark API -+ (instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error { ++ (instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { return [[self alloc] initWithString:string inRepository:repository error:error]; } -+ (instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error { ++ (instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { return [[self alloc] initWithData:data inRepository:repository error:error]; } -+ (instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error { ++ (instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { return [[self alloc] initWithFile:file inRepository:repository error:error]; } -- (instancetype)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)repository error:(NSError **)error { +- (instancetype)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(oid != NULL); NSParameterAssert(repository != nil); @@ -74,12 +74,12 @@ - (instancetype)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)re return [self initWithObj:obj inRepository:repository]; } -- (instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error { +- (instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; return [self initWithData:data inRepository:repository error:error]; } -- (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error { +- (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(data != nil); NSParameterAssert(repository != nil); @@ -95,7 +95,7 @@ - (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)reposit return [self initWithOid:&oid inRepository:repository error:error]; } -- (instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error { +- (instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(file != nil); NSParameterAssert(repository != nil); @@ -133,7 +133,7 @@ - (NSData *)data { return [NSData dataWithBytes:git_blob_rawcontent(self.git_blob) length:(NSUInteger)s]; } -- (NSData *)applyFiltersForPath:(NSString *)path error:(NSError **)error { +- (NSData *)applyFiltersForPath:(NSString *)path error:(NSError * __autoreleasing *)error { NSCParameterAssert(path != nil); git_buf buffer = GIT_BUF_INIT_CONST(0, NULL); diff --git a/ObjectiveGit/GTBranch.h b/ObjectiveGit/GTBranch.h index 3b3be239d..e2c420210 100644 --- a/ObjectiveGit/GTBranch.h +++ b/ObjectiveGit/GTBranch.h @@ -76,17 +76,17 @@ NS_ASSUME_NONNULL_BEGIN /// error(out) - will be filled if an error occurs /// /// returns a GTCommit object or nil if an error occurred -- (GTCommit * _Nullable)targetCommitWithError:(NSError **)error; +- (GTCommit * _Nullable)targetCommitWithError:(NSError * __autoreleasing *)error; /// Renames the branch. Setting `force` to YES to delete another branch with the same name. -- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error; +- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError * __autoreleasing *)error; /// Count all commits in this branch /// /// error(out) - will be filled if an error occurs /// /// returns number of commits in the branch or NSNotFound if an error occurred -- (NSUInteger)numberOfCommitsWithError:(NSError **)error; +- (NSUInteger)numberOfCommitsWithError:(NSError * __autoreleasing *)error; /// Get unique commits /// @@ -94,15 +94,15 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns a (possibly empty) array of GTCommits, or nil if an error occurs. -- (NSArray * _Nullable)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error; +- (NSArray * _Nullable)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError * __autoreleasing *)error; /// Deletes the local branch and nils out the reference. -- (BOOL)deleteWithError:(NSError **)error; +- (BOOL)deleteWithError:(NSError * __autoreleasing *)error; /// If the receiver is a local branch, looks up and returns its tracking branch. /// If the receiver is a remote branch, returns self. If no tracking branch was /// found, returns nil and sets `success` to YES. -- (GTBranch * _Nullable)trackingBranchWithError:(NSError **)error success:(BOOL * _Nullable)success; +- (GTBranch * _Nullable)trackingBranchWithError:(NSError * __autoreleasing *)error success:(BOOL * _Nullable)success; /// Update the tracking branch. /// @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether it was successful. -- (BOOL)updateTrackingBranch:(GTBranch * _Nullable)trackingBranch error:(NSError **)error; +- (BOOL)updateTrackingBranch:(GTBranch * _Nullable)trackingBranch error:(NSError * __autoreleasing *)error; /// Reloads the branch's reference and creates a new branch based off that newly /// loaded reference. @@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the reloaded branch, or nil if an error occurred. -- (GTBranch * _Nullable)reloadedBranchWithError:(NSError **)error; +- (GTBranch * _Nullable)reloadedBranchWithError:(NSError * __autoreleasing *)error; /// Calculate the ahead/behind count from this branch to the given branch. /// @@ -132,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurs. /// /// Returns whether the calculation was successful. -- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError **)error; +- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTBranch.m b/ObjectiveGit/GTBranch.m index ec54cbd5d..419f5be72 100644 --- a/ObjectiveGit/GTBranch.m +++ b/ObjectiveGit/GTBranch.m @@ -123,7 +123,7 @@ - (NSString *)remoteName { return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; } -- (GTCommit *)targetCommitWithError:(NSError **)error { +- (GTCommit *)targetCommitWithError:(NSError * __autoreleasing *)error { GTOID *oid = self.OID; if (oid == nil) { if (error != NULL) *error = GTReference.invalidReferenceError; @@ -133,7 +133,7 @@ - (GTCommit *)targetCommitWithError:(NSError **)error { return [self.repository lookUpObjectByOID:oid objectType:GTObjectTypeCommit error:error]; } -- (NSUInteger)numberOfCommitsWithError:(NSError **)error { +- (NSUInteger)numberOfCommitsWithError:(NSError * __autoreleasing *)error { GTEnumerator *enumerator = [[GTEnumerator alloc] initWithRepository:self.repository error:error]; if (enumerator == nil) return NSNotFound; @@ -160,14 +160,14 @@ - (BOOL)isHEAD { return (git_branch_is_head(self.reference.git_reference) ? YES : NO); } -- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error { +- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError * __autoreleasing *)error { GTOID *oid = self.OID; GTOID *otherOID = otherBranch.OID; GTEnumerator *enumerator = [self.repository enumeratorForUniqueCommitsFromOID:oid relativeToOID:otherOID error:error]; return [enumerator allObjectsWithError:error]; } -- (BOOL)deleteWithError:(NSError **)error { +- (BOOL)deleteWithError:(NSError * __autoreleasing *)error { int gitError = git_branch_delete(self.reference.git_reference); if (gitError != GIT_OK) { if(error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to delete branch %@", self.name]; @@ -177,7 +177,7 @@ - (BOOL)deleteWithError:(NSError **)error { return YES; } -- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error { +- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError * __autoreleasing *)error { git_reference *git_ref; int gitError = git_branch_move(&git_ref, self.reference.git_reference, name.UTF8String, (force ? 1 : 0)); if (gitError != GIT_OK) { @@ -192,7 +192,7 @@ - (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error { return YES; } -- (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success { +- (GTBranch *)trackingBranchWithError:(NSError * __autoreleasing *)error success:(BOOL *)success { BOOL underSuccess = NO; if (success == NULL) { success = &underSuccess; @@ -236,7 +236,7 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success return [[self class] branchWithReference:upsteamRef]; } -- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error { +- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError * __autoreleasing *)error { int result = GIT_ENOTFOUND; if (trackingBranch.branchType == GTBranchTypeRemote) { result = git_branch_set_upstream(self.reference.git_reference, [trackingBranch.name stringByReplacingOccurrencesOfString:[GTBranch remoteNamePrefix] withString:@""].UTF8String); @@ -251,14 +251,14 @@ - (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error return YES; } -- (GTBranch *)reloadedBranchWithError:(NSError **)error { +- (GTBranch *)reloadedBranchWithError:(NSError * __autoreleasing *)error { GTReference *reloadedRef = [self.reference reloadedReferenceWithError:error]; if (reloadedRef == nil) return nil; return [[self.class alloc] initWithReference:reloadedRef]; } -- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError **)error { +- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError * __autoreleasing *)error { GTOID *oid = self.OID; GTOID *branchOID = branch.OID; return [self.repository calculateAhead:ahead behind:behind ofOID:oid relativeToOID:branchOID error:error]; diff --git a/ObjectiveGit/GTCommit.h b/ObjectiveGit/GTCommit.h index c9a666b76..7e60e87bc 100644 --- a/ObjectiveGit/GTCommit.h +++ b/ObjectiveGit/GTCommit.h @@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN /// /// Returns an index which represents the result of the merge, or nil if an error /// occurred. -- (GTIndex * _Nullable)merge:(GTCommit *)otherCommit error:(NSError **)error; +- (GTIndex * _Nullable)merge:(GTCommit *)otherCommit error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTCommit.m b/ObjectiveGit/GTCommit.m index 495877a22..f015391e8 100644 --- a/ObjectiveGit/GTCommit.m +++ b/ObjectiveGit/GTCommit.m @@ -151,7 +151,7 @@ - (NSArray *)parents { #pragma mark Merging -- (GTIndex *)merge:(GTCommit *)otherCommit error:(NSError **)error { +- (GTIndex *)merge:(GTCommit *)otherCommit error:(NSError * __autoreleasing *)error { NSParameterAssert(otherCommit != nil); git_index *index; diff --git a/ObjectiveGit/GTConfiguration.h b/ObjectiveGit/GTConfiguration.h index 6c4df90a4..aefc73860 100644 --- a/ObjectiveGit/GTConfiguration.h +++ b/ObjectiveGit/GTConfiguration.h @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)setInt64:(int64_t)i forKey:(NSString *)key; - (int64_t)int64ForKey:(NSString *)key; -- (BOOL)deleteValueForKey:(NSString *)key error:(NSError **)error; +- (BOOL)deleteValueForKey:(NSString *)key error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTConfiguration.m b/ObjectiveGit/GTConfiguration.m index acd46cd74..917f3552c 100644 --- a/ObjectiveGit/GTConfiguration.m +++ b/ObjectiveGit/GTConfiguration.m @@ -103,7 +103,7 @@ - (int64_t)int64ForKey:(NSString *)key { return i; } -- (BOOL)deleteValueForKey:(NSString *)key error:(NSError **)error { +- (BOOL)deleteValueForKey:(NSString *)key error:(NSError * __autoreleasing *)error { git_config_delete_entry(self.git_config, key.UTF8String); return YES; diff --git a/ObjectiveGit/GTCredential.h b/ObjectiveGit/GTCredential.h index 560a8ba18..5501bf04a 100644 --- a/ObjectiveGit/GTCredential.h +++ b/ObjectiveGit/GTCredential.h @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any errors that occur. /// /// Return a new GTCredential instance, or nil if an error occurred -+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error; ++ (instancetype _Nullable)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError * __autoreleasing *)error; /// Create a credential object from a SSH keyfile /// @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any errors that occur. /// /// Return a new GTCredential instance, or nil if an error occurred -+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL * _Nullable)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString * _Nullable)passphrase error:(NSError **)error; ++ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL * _Nullable)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString * _Nullable)passphrase error:(NSError * __autoreleasing *)error; /// Create a credential object from a SSH keyfile data string /// @@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any errors that occur. /// /// Return a new GTCredential instance, or nil if an error occurred -+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError **)error; ++ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError * __autoreleasing *)error; /// The underlying `git_cred` object. - (git_cred *)git_cred __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTCredential.m b/ObjectiveGit/GTCredential.m index 1d3894b44..fe435387e 100644 --- a/ObjectiveGit/GTCredential.m +++ b/ObjectiveGit/GTCredential.m @@ -44,7 +44,7 @@ @interface GTCredential () @implementation GTCredential -+ (instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error { ++ (instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError * __autoreleasing *)error { git_cred *cred; int gitError = git_cred_userpass_plaintext_new(&cred, userName.UTF8String, password.UTF8String); if (gitError != GIT_OK) { @@ -55,7 +55,7 @@ + (instancetype)credentialWithUserName:(NSString *)userName password:(NSString * return [[self alloc] initWithGitCred:cred]; } -+ (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString *)passphrase error:(NSError **)error { ++ (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString *)passphrase error:(NSError * __autoreleasing *)error { NSParameterAssert(privateKeyURL != nil); NSString *publicKeyPath = publicKeyURL.filePathURL.path; NSString *privateKeyPath = privateKeyURL.filePathURL.path; @@ -71,7 +71,7 @@ + (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL return [[self alloc] initWithGitCred:cred]; } -+ (instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(NSString *)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString *)passphrase error:(NSError **)error { ++ (instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(NSString *)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString *)passphrase error:(NSError * __autoreleasing *)error { NSParameterAssert(privateKeyString != nil); git_cred *cred; diff --git a/ObjectiveGit/GTDiff.h b/ObjectiveGit/GTDiff.h index 7264b4432..3ce74af5d 100644 --- a/ObjectiveGit/GTDiff.h +++ b/ObjectiveGit/GTDiff.h @@ -199,7 +199,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffOldTree:(GTTree * _Nullable)oldTree withNewTree:(GTTree * _Nullable)newTree inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffOldTree:(GTTree * _Nullable)oldTree withNewTree:(GTTree * _Nullable)newTree inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between `GTTree` and `GTIndex`. /// @@ -216,7 +216,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffOldTree:(GTTree * _Nullable)oldTree withNewIndex:(GTIndex * _Nullable)newIndex inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffOldTree:(GTTree * _Nullable)oldTree withNewIndex:(GTIndex * _Nullable)newIndex inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between two `GTIndex`es. /// @@ -233,7 +233,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffOldIndex:(GTIndex * _Nullable)oldIndex withNewIndex:(GTIndex * _Nullable)newIndex inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffOldIndex:(GTIndex * _Nullable)oldIndex withNewIndex:(GTIndex * _Nullable)newIndex inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between a repository's current index. /// @@ -253,7 +253,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffIndexFromTree:(GTTree * _Nullable)tree inRepository:(GTRepository * _Nullable)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffIndexFromTree:(GTTree * _Nullable)tree inRepository:(GTRepository * _Nullable)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between the index and working directory in a given repository. /// @@ -266,7 +266,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffIndexToWorkingDirectoryInRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffIndexToWorkingDirectoryInRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between a repository's working directory and a tree. /// @@ -279,7 +279,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// available. /// /// Returns a newly created `GTDiff` object or nil on error. -+ (instancetype _Nullable)diffWorkingDirectoryFromTree:(GTTree * _Nullable)tree inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffWorkingDirectoryFromTree:(GTTree * _Nullable)tree inRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Create a diff between the working directory and HEAD. /// @@ -292,7 +292,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// error - Populated if an error occurs. /// /// Returns a newly created GTDiff, or nil if an error occurred. -+ (instancetype _Nullable)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repository options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -335,7 +335,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// error - Populated if an error occurs /// /// Returns YES if the merge was successfull, and NO and sets `error` otherwise. -- (BOOL)mergeDiffWithDiff:(GTDiff *)diff error:(NSError **)error; +- (BOOL)mergeDiffWithDiff:(GTDiff *)diff error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTDiff.m b/ObjectiveGit/GTDiff.m index b3de61898..5c160be6a 100644 --- a/ObjectiveGit/GTDiff.m +++ b/ObjectiveGit/GTDiff.m @@ -80,7 +80,7 @@ + (int)handleParsedOptionsDictionary:(NSDictionary *)dictionary usingBlock:(int return block(optionsPtr); } -+ (instancetype)diffOldTree:(GTTree *)oldTree withNewTree:(GTTree *)newTree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffOldTree:(GTTree *)oldTree withNewTree:(GTTree *)newTree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); __block git_diff *diff; @@ -95,7 +95,7 @@ + (instancetype)diffOldTree:(GTTree *)oldTree withNewTree:(GTTree *)newTree inRe return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffOldTree:(GTTree *)oldTree withNewIndex:(GTIndex *)newIndex inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffOldTree:(GTTree *)oldTree withNewIndex:(GTIndex *)newIndex inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); __block git_diff *diff; @@ -110,7 +110,7 @@ + (instancetype)diffOldTree:(GTTree *)oldTree withNewIndex:(GTIndex *)newIndex i return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffOldIndex:(GTIndex *)oldIndex withNewIndex:(GTIndex *)newIndex inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error ++ (instancetype)diffOldIndex:(GTIndex *)oldIndex withNewIndex:(GTIndex *)newIndex inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); @@ -126,7 +126,7 @@ + (instancetype)diffOldIndex:(GTIndex *)oldIndex withNewIndex:(GTIndex *)newInde return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffIndexFromTree:(GTTree *)tree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffIndexFromTree:(GTTree *)tree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); NSParameterAssert(tree == nil || [tree.repository isEqual:repository]); @@ -142,7 +142,7 @@ + (instancetype)diffIndexFromTree:(GTTree *)tree inRepository:(GTRepository *)re return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffIndexToWorkingDirectoryInRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffIndexToWorkingDirectoryInRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); __block git_diff *diff; @@ -157,7 +157,7 @@ + (instancetype)diffIndexToWorkingDirectoryInRepository:(GTRepository *)reposito return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffWorkingDirectoryFromTree:(GTTree *)tree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffWorkingDirectoryFromTree:(GTTree *)tree inRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); NSParameterAssert(tree == nil || [tree.repository isEqual:repository]); @@ -173,7 +173,7 @@ + (instancetype)diffWorkingDirectoryFromTree:(GTTree *)tree inRepository:(GTRepo return [[self alloc] initWithGitDiff:diff repository:repository]; } -+ (instancetype)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repository options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); GTCommit *HEADCommit = [[repository headReferenceWithError:NULL] resolvedTarget]; @@ -268,7 +268,7 @@ - (void)findSimilarWithOptions:(NSDictionary *)options { git_diff_find_similar(self.git_diff, (findOptionsCreated ? &findOptions : NULL)); } -- (BOOL)mergeDiffWithDiff:(GTDiff *)diff error:(NSError **)error { +- (BOOL)mergeDiffWithDiff:(GTDiff *)diff error:(NSError * __autoreleasing *)error { int gitError = git_diff_merge(self.git_diff, diff.git_diff); if (gitError != GIT_OK) { if (error) *error = [NSError git_errorFor:gitError description:@"Merging diffs failed"]; diff --git a/ObjectiveGit/GTDiffDelta.h b/ObjectiveGit/GTDiffDelta.h index 2ea104166..4723ede89 100644 --- a/ObjectiveGit/GTDiffDelta.h +++ b/ObjectiveGit/GTDiffDelta.h @@ -88,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns a diff delta, or nil if an error occurs. -+ (instancetype _Nullable)diffDeltaFromBlob:(GTBlob * _Nullable)oldBlob forPath:(NSString * _Nullable)oldBlobPath toBlob:(GTBlob * _Nullable)newBlob forPath:(NSString * _Nullable)newBlobPath options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffDeltaFromBlob:(GTBlob * _Nullable)oldBlob forPath:(NSString * _Nullable)oldBlobPath toBlob:(GTBlob * _Nullable)newBlob forPath:(NSString * _Nullable)newBlobPath options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Diffs the given blob and data buffer. /// @@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns a diff delta, or nil if an error occurs. -+ (instancetype _Nullable)diffDeltaFromBlob:(GTBlob * _Nullable)blob forPath:(NSString * _Nullable)blobPath toData:(NSData * _Nullable)data forPath:(NSString * _Nullable)dataPath options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffDeltaFromBlob:(GTBlob * _Nullable)blob forPath:(NSString * _Nullable)blobPath toData:(NSData * _Nullable)data forPath:(NSString * _Nullable)dataPath options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Diffs the given data buffers. /// @@ -118,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns a diff delta, or nil if an error occurs. -+ (instancetype _Nullable)diffDeltaFromData:(NSData * _Nullable)oldData forPath:(NSString * _Nullable)oldDataPath toData:(NSData * _Nullable)newData forPath:(NSString * _Nullable)newDataPath options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)diffDeltaFromData:(NSData * _Nullable)oldData forPath:(NSString * _Nullable)oldDataPath toData:(NSData * _Nullable)newData forPath:(NSString * _Nullable)newDataPath options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns a new patch, or nil if an error occurs. -- (GTDiffPatch * _Nullable)generatePatch:(NSError **)error; +- (GTDiffPatch * _Nullable)generatePatch:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTDiffDelta.m b/ObjectiveGit/GTDiffDelta.m index 28358f14f..412ca8489 100644 --- a/ObjectiveGit/GTDiffDelta.m +++ b/ObjectiveGit/GTDiffDelta.m @@ -73,7 +73,7 @@ static int GTDiffDeltaCallback(const git_diff_delta *delta, float progress, void return GIT_OK; } -+ (instancetype)diffDeltaFromBlob:(GTBlob *)oldBlob forPath:(NSString *)oldBlobPath toBlob:(GTBlob *)newBlob forPath:(NSString *)newBlobPath options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffDeltaFromBlob:(GTBlob *)oldBlob forPath:(NSString *)oldBlobPath toBlob:(GTBlob *)newBlob forPath:(NSString *)newBlobPath options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { __block git_diff_delta diffDelta; int returnValue = [GTDiff handleParsedOptionsDictionary:options usingBlock:^(git_diff_options *optionsStruct) { @@ -94,7 +94,7 @@ + (instancetype)diffDeltaFromBlob:(GTBlob *)oldBlob forPath:(NSString *)oldBlobP }]; } -+ (instancetype)diffDeltaFromBlob:(GTBlob *)blob forPath:(NSString *)blobPath toData:(NSData *)data forPath:(NSString *)dataPath options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffDeltaFromBlob:(GTBlob *)blob forPath:(NSString *)blobPath toData:(NSData *)data forPath:(NSString *)dataPath options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { __block git_diff_delta diffDelta; int returnValue = [GTDiff handleParsedOptionsDictionary:options usingBlock:^(git_diff_options *optionsStruct) { @@ -115,7 +115,7 @@ + (instancetype)diffDeltaFromBlob:(GTBlob *)blob forPath:(NSString *)blobPath to }]; } -+ (instancetype)diffDeltaFromData:(NSData *)oldData forPath:(NSString *)oldDataPath toData:(NSData *)newData forPath:(NSString *)newDataPath options:(NSDictionary *)options error:(NSError **)error { ++ (instancetype)diffDeltaFromData:(NSData *)oldData forPath:(NSString *)oldDataPath toData:(NSData *)newData forPath:(NSString *)newDataPath options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { __block git_diff_delta diffDelta; int returnValue = [GTDiff handleParsedOptionsDictionary:options usingBlock:^(git_diff_options *optionsStruct) { @@ -166,7 +166,7 @@ - (instancetype)initWithGitDiffDeltaBlock:(git_diff_delta (^)(void))deltaAccesso #pragma mark Patch Generation -- (GTDiffPatch *)generatePatch:(NSError **)error { +- (GTDiffPatch *)generatePatch:(NSError * __autoreleasing *)error { git_patch *patch = NULL; int gitError = self.patchGenerator(&patch); if (gitError != GIT_OK) { diff --git a/ObjectiveGit/GTDiffFile.h b/ObjectiveGit/GTDiffFile.h index e88935ffb..6cd95ddcc 100644 --- a/ObjectiveGit/GTDiffFile.h +++ b/ObjectiveGit/GTDiffFile.h @@ -7,7 +7,7 @@ // #import -#import "git2/diff.h" +#import /// Flags which may be set on the file. /// diff --git a/ObjectiveGit/GTDiffHunk.h b/ObjectiveGit/GTDiffHunk.h index 164185e58..ba4a7ea2e 100644 --- a/ObjectiveGit/GTDiffHunk.h +++ b/ObjectiveGit/GTDiffHunk.h @@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN /// be nil. /// Return YES if the enumeration was successful, NO otherwise (and an error will /// be set in `error`). -- (BOOL)enumerateLinesInHunk:(NSError **)error usingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block; +- (BOOL)enumerateLinesInHunk:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block; @end diff --git a/ObjectiveGit/GTDiffHunk.m b/ObjectiveGit/GTDiffHunk.m index 0b822903f..5fcf1aca9 100644 --- a/ObjectiveGit/GTDiffHunk.m +++ b/ObjectiveGit/GTDiffHunk.m @@ -58,7 +58,7 @@ - (NSString *)debugDescription { return [NSString stringWithFormat:@"%@ hunkIndex: %ld, header: %@, lineCount: %ld", super.debugDescription, (unsigned long)self.hunkIndex, self.header, (unsigned long)self.lineCount]; } -- (BOOL)enumerateLinesInHunk:(NSError **)error usingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block { +- (BOOL)enumerateLinesInHunk:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block { NSParameterAssert(block != nil); for (NSUInteger idx = 0; idx < self.lineCount; idx ++) { diff --git a/ObjectiveGit/GTEnumerator.h b/ObjectiveGit/GTEnumerator.h index 4d8b27201..bf86ba619 100644 --- a/ObjectiveGit/GTEnumerator.h +++ b/ObjectiveGit/GTEnumerator.h @@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns an initialized enumerator, or nil if an error occurs. -- (id _Nullable)initWithRepository:(GTRepository *)repo error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (id _Nullable)initWithRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; /// Marks a commit to start traversal from. /// @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether pushing the commit was successful. -- (BOOL)pushSHA:(NSString *)sha error:(NSError **)error; +- (BOOL)pushSHA:(NSString *)sha error:(NSError * __autoreleasing *)error; /// Pushes all references matching `refGlob`. /// @@ -90,14 +90,14 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether pushing matching references was successful. -- (BOOL)pushGlob:(NSString *)refGlob error:(NSError **)error; +- (BOOL)pushGlob:(NSString *)refGlob error:(NSError * __autoreleasing *)error; /// Push HEAD reference. /// /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether pushing the HEAD reference was successful. -- (BOOL)pushHEAD:(NSError **)error; +- (BOOL)pushHEAD:(NSError * __autoreleasing *)error; /// Push a reference by name. /// @@ -105,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether pushing the reference name was successful. -- (BOOL)pushReferenceName:(NSString *)refName error:(NSError **)error; +- (BOOL)pushReferenceName:(NSString *)refName error:(NSError * __autoreleasing *)error; /// Hides the specified commit and all of its ancestors when enumerating. /// @@ -114,7 +114,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether marking the SHA for hiding was successful. -- (BOOL)hideSHA:(NSString *)sha error:(NSError **)error; +- (BOOL)hideSHA:(NSString *)sha error:(NSError * __autoreleasing *)error; /// Hides all references matching `refGlob`. /// @@ -122,14 +122,14 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether marking matching references for hiding was successful. -- (BOOL)hideGlob:(NSString *)refGlob error:(NSError **)error; +- (BOOL)hideGlob:(NSString *)refGlob error:(NSError * __autoreleasing *)error; /// Hide HEAD reference. /// /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether marking HEAD for hiding was successful. -- (BOOL)hideHEAD:(NSError **)error; +- (BOOL)hideHEAD:(NSError * __autoreleasing *)error; /// Hide a reference by name. @@ -138,7 +138,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, this will be set to any error that occurs. /// /// Returns whether hiding the reference name was successful. -- (BOOL)hideReferenceName:(NSString *)refName error:(NSError **)error; +- (BOOL)hideReferenceName:(NSString *)refName error:(NSError * __autoreleasing *)error; /// Resets the receiver, putting it back into a clean state for reuse, and /// replacing the receiver's `options`. @@ -149,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs during traversal. /// /// Returns a (possibly empty) array of GTCommits, or nil if an error occurs. -- (NSArray * _Nullable)allObjectsWithError:(NSError **)error; +- (NSArray * _Nullable)allObjectsWithError:(NSError * __autoreleasing *)error; /// Get the next OID. /// @@ -159,7 +159,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs during traversal. /// /// Returns nil if an error occurs or the enumeration is done. -- (GTOID * _Nullable)nextOIDWithSuccess:(BOOL * _Nullable)success error:(NSError **)error; +- (GTOID * _Nullable)nextOIDWithSuccess:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// Gets the next commit. /// @@ -169,7 +169,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs during traversal. /// /// Returns nil if an error occurs or the receiver is exhausted. -- (GTCommit * _Nullable)nextObjectWithSuccess:(BOOL * _Nullable)success error:(NSError **)error; +- (GTCommit * _Nullable)nextObjectWithSuccess:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// Counts the number of commits that were not enumerated, completely exhausting /// the receiver. @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs during traversal. /// /// Returns the number of commits remaining, or `NSNotFound` if an error occurs. -- (NSUInteger)countRemainingObjects:(NSError **)error; +- (NSUInteger)countRemainingObjects:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTEnumerator.m b/ObjectiveGit/GTEnumerator.m index b684d4e3e..535ccb603 100644 --- a/ObjectiveGit/GTEnumerator.m +++ b/ObjectiveGit/GTEnumerator.m @@ -57,7 +57,7 @@ - (git_revwalk *)git_revwalk { return self.walk; } -- (instancetype)initWithRepository:(GTRepository *)repo error:(NSError **)error { +- (instancetype)initWithRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error { NSParameterAssert(repo != nil); self = [super init]; @@ -84,7 +84,7 @@ - (void)dealloc { #pragma mark Pushing and Hiding -- (BOOL)pushSHA:(NSString *)sha error:(NSError **)error { +- (BOOL)pushSHA:(NSString *)sha error:(NSError * __autoreleasing *)error { NSParameterAssert(sha != nil); GTOID *oid = [[GTOID alloc] initWithSHA:sha error:error]; @@ -99,7 +99,7 @@ - (BOOL)pushSHA:(NSString *)sha error:(NSError **)error { return YES; } -- (BOOL)pushGlob:(NSString *)refGlob error:(NSError **)error { +- (BOOL)pushGlob:(NSString *)refGlob error:(NSError * __autoreleasing *)error { NSParameterAssert(refGlob != nil); int gitError = git_revwalk_push_glob(self.walk, refGlob.UTF8String); @@ -111,7 +111,7 @@ - (BOOL)pushGlob:(NSString *)refGlob error:(NSError **)error { return YES; } -- (BOOL)pushHEAD:(NSError **)error { +- (BOOL)pushHEAD:(NSError * __autoreleasing *)error { int gitError = git_revwalk_push_head(self.walk); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to push HEAD onto rev walker."]; @@ -120,7 +120,7 @@ - (BOOL)pushHEAD:(NSError **)error { return YES; } -- (BOOL)pushReferenceName:(NSString *)refName error:(NSError **)error { +- (BOOL)pushReferenceName:(NSString *)refName error:(NSError * __autoreleasing *)error { NSParameterAssert(refName != nil); int gitError = git_revwalk_push_ref(self.walk, refName.UTF8String); @@ -131,7 +131,7 @@ - (BOOL)pushReferenceName:(NSString *)refName error:(NSError **)error { return YES; } -- (BOOL)hideSHA:(NSString *)sha error:(NSError **)error { +- (BOOL)hideSHA:(NSString *)sha error:(NSError * __autoreleasing *)error { NSParameterAssert(sha != nil); GTOID *oid = [[GTOID alloc] initWithSHA:sha error:error]; @@ -146,7 +146,7 @@ - (BOOL)hideSHA:(NSString *)sha error:(NSError **)error { return YES; } -- (BOOL)hideGlob:(NSString *)refGlob error:(NSError **)error { +- (BOOL)hideGlob:(NSString *)refGlob error:(NSError * __autoreleasing *)error { NSParameterAssert(refGlob != nil); int gitError = git_revwalk_hide_glob(self.walk, refGlob.UTF8String); @@ -158,7 +158,7 @@ - (BOOL)hideGlob:(NSString *)refGlob error:(NSError **)error { return YES; } -- (BOOL)hideHEAD:(NSError **)error { +- (BOOL)hideHEAD:(NSError * __autoreleasing *)error { int gitError = git_revwalk_hide_head(self.walk); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to hide HEAD onto rev walker."]; @@ -167,7 +167,7 @@ - (BOOL)hideHEAD:(NSError **)error { return YES; } -- (BOOL)hideReferenceName:(NSString *)refName error:(NSError **)error { +- (BOOL)hideReferenceName:(NSString *)refName error:(NSError * __autoreleasing *)error { NSParameterAssert(refName != nil); int gitError = git_revwalk_hide_ref(self.walk, refName.UTF8String); @@ -189,7 +189,7 @@ - (void)resetWithOptions:(GTEnumeratorOptions)options { #pragma mark Enumerating -- (GTOID *)nextOIDWithSuccess:(BOOL *)success error:(NSError **)error { +- (GTOID *)nextOIDWithSuccess:(BOOL *)success error:(NSError * __autoreleasing *)error { git_oid oid; int gitError = git_revwalk_next(&oid, self.walk); @@ -207,7 +207,7 @@ - (GTOID *)nextOIDWithSuccess:(BOOL *)success error:(NSError **)error { return [GTOID oidWithGitOid:&oid]; } -- (GTCommit *)nextObjectWithSuccess:(BOOL *)success error:(NSError **)error { +- (GTCommit *)nextObjectWithSuccess:(BOOL *)success error:(NSError * __autoreleasing *)error { GTOID *oid = [self nextOIDWithSuccess:success error:error]; if (oid == nil) { // We don't care whether the iteration completed, or an error occurred, @@ -221,7 +221,7 @@ - (GTCommit *)nextObjectWithSuccess:(BOOL *)success error:(NSError **)error { return commit; } -- (NSArray *)allObjectsWithError:(NSError **)error { +- (NSArray *)allObjectsWithError:(NSError * __autoreleasing *)error { NSMutableArray *array = [NSMutableArray array]; GTCommit *object; @@ -238,7 +238,7 @@ - (NSArray *)allObjectsWithError:(NSError **)error { return array; } -- (NSUInteger)countRemainingObjects:(NSError **)error { +- (NSUInteger)countRemainingObjects:(NSError * __autoreleasing *)error { git_oid oid; int gitError; diff --git a/ObjectiveGit/GTFilter.h b/ObjectiveGit/GTFilter.h index 51b2e7196..472fe9c7c 100644 --- a/ObjectiveGit/GTFilter.h +++ b/ObjectiveGit/GTFilter.h @@ -69,14 +69,14 @@ extern const NSInteger GTFilterErrorNameAlreadyRegistered; /// error - The error if one occurred. /// /// Returns whether the registration was successful. -- (BOOL)registerWithPriority:(int)priority error:(NSError **)error; +- (BOOL)registerWithPriority:(int)priority error:(NSError * __autoreleasing *)error; /// Unregisters the filter. /// /// error - The error if one occurred. /// /// Returns whether the unregistration was successful. -- (BOOL)unregister:(NSError **)error; +- (BOOL)unregister:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTFilter.m b/ObjectiveGit/GTFilter.m index 69c185ca7..50a7304e1 100644 --- a/ObjectiveGit/GTFilter.m +++ b/ObjectiveGit/GTFilter.m @@ -140,7 +140,7 @@ - (void)setCleanupBlock:(void (^)(void *))cleanupBlock { #pragma mark Registration -- (BOOL)registerWithPriority:(int)priority error:(NSError **)error { +- (BOOL)registerWithPriority:(int)priority error:(NSError * __autoreleasing *)error { if (GTFiltersNameToRegisteredFilters[self.name] != nil) { if (error != NULL) { NSString *description = [NSString stringWithFormat:NSLocalizedString(@"A filter named \"%@\" has already been registered", @""), self.name]; @@ -170,7 +170,7 @@ - (BOOL)registerWithPriority:(int)priority error:(NSError **)error { return YES; } -- (BOOL)unregister:(NSError **)error { +- (BOOL)unregister:(NSError * __autoreleasing *)error { int result = git_filter_unregister(self.name.UTF8String); if (result != GIT_OK) { if (error != NULL) { diff --git a/ObjectiveGit/GTFilterList.h b/ObjectiveGit/GTFilterList.h index 6ddf3ca98..f8990512c 100644 --- a/ObjectiveGit/GTFilterList.h +++ b/ObjectiveGit/GTFilterList.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the filtered data, or nil if an error occurs. -- (NSData * _Nullable)applyToData:(NSData *)inputData error:(NSError **)error; +- (NSData * _Nullable)applyToData:(NSData *)inputData error:(NSError * __autoreleasing *)error; /// Attempts to apply the filter list to a file in the given repository. /// @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the filtered data, or nil if an error occurs. -- (NSData * _Nullable)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)repository error:(NSError **)error; +- (NSData * _Nullable)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Attempts to apply the filter list to a blob. /// @@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the filtered data, or nil if an error occurs. -- (NSData * _Nullable)applyToBlob:(GTBlob *)blob error:(NSError **)error; +- (NSData * _Nullable)applyToBlob:(GTBlob *)blob error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTFilterList.m b/ObjectiveGit/GTFilterList.m index 1780293a4..e2dee938f 100644 --- a/ObjectiveGit/GTFilterList.m +++ b/ObjectiveGit/GTFilterList.m @@ -50,7 +50,7 @@ - (void)dealloc { #pragma mark Application -- (NSData *)applyToData:(NSData *)inputData error:(NSError **)error { +- (NSData *)applyToData:(NSData *)inputData error:(NSError * __autoreleasing *)error { NSParameterAssert(inputData != nil); git_buf input = inputData.git_buf; @@ -65,7 +65,7 @@ - (NSData *)applyToData:(NSData *)inputData error:(NSError **)error { return [NSData git_dataWithBuffer:&output]; } -- (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)repository error:(NSError **)error { +- (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(relativePath != nil); NSParameterAssert(repository != nil); @@ -84,7 +84,7 @@ - (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)re return [NSData git_dataWithBuffer:&output]; } -- (NSData *)applyToBlob:(GTBlob *)blob error:(NSError **)error { +- (NSData *)applyToBlob:(GTBlob *)blob error:(NSError * __autoreleasing *)error { NSParameterAssert(blob != nil); git_buf output = GIT_BUF_INIT_CONST(0, NULL); diff --git a/ObjectiveGit/GTIndex.h b/ObjectiveGit/GTIndex.h index d0df6e4ec..d6c707638 100644 --- a/ObjectiveGit/GTIndex.h +++ b/ObjectiveGit/GTIndex.h @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the newly created index, or nil if an error occurred. -+ (instancetype _Nullable)inMemoryIndexWithRepository:(GTRepository *)repository error:(NSError **)error; ++ (instancetype _Nullable)inMemoryIndexWithRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Loads the index at the given file URL. /// @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns the loaded index, or nil if an error occurred. -+ (instancetype _Nullable)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError **)error; ++ (instancetype _Nullable)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -90,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether the refresh was successful. -- (BOOL)refresh:(NSError **)error; +- (BOOL)refresh:(NSError * __autoreleasing *)error; /// Clear all the entries from the index. This happens in memory. Changes can be /// written to the datastore by calling -write:. @@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one ocurred. /// /// Returns whether the clear operation was successful. -- (BOOL)clear:(NSError **)error; +- (BOOL)clear:(NSError * __autoreleasing *)error; /// Get the entry at the given index. /// @@ -116,7 +116,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns a new GTIndexEntry, or nil if an error occurred. -- (GTIndexEntry * _Nullable)entryWithPath:(NSString *)path error:(NSError **)error; +- (GTIndexEntry * _Nullable)entryWithPath:(NSString *)path error:(NSError * __autoreleasing *)error; /// Add an entry to the index. /// @@ -126,7 +126,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns YES if successful, NO otherwise. -- (BOOL)addEntry:(GTIndexEntry *)entry error:(NSError **)error; +- (BOOL)addEntry:(GTIndexEntry *)entry error:(NSError * __autoreleasing *)error; /// Add an entry (by relative path) to the index. /// Will fail if the receiver's repository is nil. @@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns YES if successful, NO otherwise. -- (BOOL)addFile:(NSString *)file error:(NSError **)error; +- (BOOL)addFile:(NSString *)file error:(NSError * __autoreleasing *)error; /// Add an entry (with the provided data and name) to the index. /// Will fail if the receiver's repository is nil. @@ -145,7 +145,7 @@ NS_ASSUME_NONNULL_BEGIN /// data - The content of the entry to add. Cannot be nil. /// path - The path of the entry to add. Cannot be nil. /// error - The error if one occurred. -- (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError **)error; +- (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError * __autoreleasing *)error; /// Reads the contents of the given tree into the index. /// @@ -153,14 +153,14 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns whether reading the tree was successful. -- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error; +- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError * __autoreleasing *)error; /// Add all the content of the working directory to the index. Like `git add -A` /// /// error - If not NULL, set to any error that occurs. /// /// Returns whether the operation was successful -- (BOOL)addAll:(NSError **)error; +- (BOOL)addAll:(NSError * __autoreleasing *)error; /// Remove an entry (by relative path) from the index. /// Will fail if the receiver's repository is nil. @@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error, if one occurred. /// /// Returns YES if successful, NO otherwise. -- (BOOL)removeFile:(NSString *)file error:(NSError **)error; +- (BOOL)removeFile:(NSString *)file error:(NSError * __autoreleasing *)error; /// Write the index to the repository. /// Will fail if the receiver's repository is nil. @@ -178,7 +178,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns YES if successful, NO otherwise. -- (BOOL)write:(NSError **)error; +- (BOOL)write:(NSError * __autoreleasing *)error; /// Write the index to the repository as a tree. /// Will fail if the receiver's repository is nil. @@ -186,7 +186,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns a new GTTree, or nil if an error occurred. -- (GTTree * _Nullable)writeTree:(NSError **)error; +- (GTTree * _Nullable)writeTree:(NSError * __autoreleasing *)error; /// Write the index to the given repository as a tree. /// Will fail if the receiver's index has conflicts. @@ -195,7 +195,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns a new GTTree or nil if an error occurred. -- (GTTree * _Nullable)writeTreeToRepository:(GTRepository *)repository error:(NSError **)error; +- (GTTree * _Nullable)writeTreeToRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; /// Enumerate through any conflicts in the index, running the provided block each /// time. @@ -209,7 +209,7 @@ NS_ASSUME_NONNULL_BEGIN /// /// Returns `YES` in the event of successful enumeration or no conflicts in the /// index, `NO` in case of error. -- (BOOL)enumerateConflictedFilesWithError:(NSError **)error usingBlock:(void (^)(GTIndexEntry *ancestor, GTIndexEntry *ours, GTIndexEntry *theirs, BOOL *stop))block; +- (BOOL)enumerateConflictedFilesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTIndexEntry *ancestor, GTIndexEntry *ours, GTIndexEntry *theirs, BOOL *stop))block; /// Update all index entries to match the working directory. /// This method will immediately fail if the index's repo is bare. @@ -227,11 +227,11 @@ NS_ASSUME_NONNULL_BEGIN /// error - When something goes wrong, this parameter is set. Optional. /// /// Returns `YES` in the event that everything has gone smoothly. Otherwise, `NO`. -- (BOOL)updatePathspecs:(NSArray * _Nullable)pathspecs error:(NSError **)error passingTest:(BOOL (^ _Nullable)(NSString *matchedPathspec, NSString *path, BOOL *stop))block; +- (BOOL)updatePathspecs:(NSArray * _Nullable)pathspecs error:(NSError * __autoreleasing *)error passingTest:(BOOL (^ _Nullable)(NSString *matchedPathspec, NSString *path, BOOL *stop))block; #pragma mark Deprecations - (GTIndexEntry * _Nullable)entryWithName:(NSString *)name __deprecated_msg("use entryWithPath: instead."); -- (GTIndexEntry * _Nullable)entryWithName:(NSString *)name error:(NSError **)error __deprecated_msg("use entryWithPath:error: instead."); +- (GTIndexEntry * _Nullable)entryWithName:(NSString *)name error:(NSError * __autoreleasing *)error __deprecated_msg("use entryWithPath:error: instead."); @end diff --git a/ObjectiveGit/GTIndex.m b/ObjectiveGit/GTIndex.m index 8ee64fde6..1bd4f9f7b 100644 --- a/ObjectiveGit/GTIndex.m +++ b/ObjectiveGit/GTIndex.m @@ -75,7 +75,7 @@ - (void)dealloc { if (_git_index != NULL) git_index_free(_git_index); } -+ (instancetype)inMemoryIndexWithRepository:(GTRepository *)repository error:(NSError **)error { ++ (instancetype)inMemoryIndexWithRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { git_index *index = NULL; int status = git_index_new(&index); @@ -92,7 +92,7 @@ - (instancetype)init { return nil; } -+ (instancetype)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError **)error { ++ (instancetype)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(fileURL != nil); NSParameterAssert(fileURL.isFileURL); @@ -125,7 +125,7 @@ - (NSUInteger)entryCount { return git_index_entrycount(self.git_index); } -- (BOOL)refresh:(NSError **)error { +- (BOOL)refresh:(NSError * __autoreleasing *)error { int status = git_index_read(self.git_index, 1); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to refresh index."]; @@ -135,7 +135,7 @@ - (BOOL)refresh:(NSError **)error { return YES; } -- (BOOL)clear:(NSError **)error { +- (BOOL)clear:(NSError * __autoreleasing *)error { int gitError = git_index_clear(self.git_index); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to clear index"]; @@ -155,7 +155,7 @@ - (GTIndexEntry *)entryWithPath:(NSString *)path { return [self entryWithPath:path error:NULL]; } -- (GTIndexEntry *)entryWithPath:(NSString *)path error:(NSError **)error { +- (GTIndexEntry *)entryWithPath:(NSString *)path error:(NSError * __autoreleasing *)error { size_t pos = 0; int gitError = git_index_find(&pos, self.git_index, path.UTF8String); if (gitError != GIT_OK) { @@ -165,7 +165,7 @@ - (GTIndexEntry *)entryWithPath:(NSString *)path error:(NSError **)error { return [self entryAtIndex:pos]; } -- (BOOL)addEntry:(GTIndexEntry *)entry error:(NSError **)error { +- (BOOL)addEntry:(GTIndexEntry *)entry error:(NSError * __autoreleasing *)error { int status = git_index_add(self.git_index, entry.git_index_entry); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to add entry to index."]; @@ -175,7 +175,7 @@ - (BOOL)addEntry:(GTIndexEntry *)entry error:(NSError **)error { return YES; } -- (BOOL)addFile:(NSString *)file error:(NSError **)error { +- (BOOL)addFile:(NSString *)file error:(NSError * __autoreleasing *)error { NSString *unicodeString = [self composedUnicodeStringWithString:file]; int status = git_index_add_bypath(self.git_index, unicodeString.UTF8String); @@ -187,7 +187,7 @@ - (BOOL)addFile:(NSString *)file error:(NSError **)error { return YES; } -- (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError **)error { +- (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError * __autoreleasing *)error { NSParameterAssert(data != nil); NSParameterAssert(path != nil); @@ -206,7 +206,7 @@ - (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError **)error return YES; } -- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error { +- (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError * __autoreleasing *)error { NSParameterAssert(tree != nil); int status = git_index_read_tree(self.git_index, tree.git_tree); @@ -218,7 +218,7 @@ - (BOOL)addContentsOfTree:(GTTree *)tree error:(NSError **)error { return YES; } -- (BOOL)addAll:(NSError **)error { +- (BOOL)addAll:(NSError * __autoreleasing *)error { int status = git_index_add_all(self.git_index, nil, GIT_INDEX_ADD_CHECK_PATHSPEC, nil, nil); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to add all the contents of the working tree to the index"]; @@ -228,7 +228,7 @@ - (BOOL)addAll:(NSError **)error { return YES; } -- (BOOL)removeFile:(NSString *)file error:(NSError **)error { +- (BOOL)removeFile:(NSString *)file error:(NSError * __autoreleasing *)error { NSString *unicodeString = [self composedUnicodeStringWithString:file]; int status = git_index_remove_bypath(self.git_index, unicodeString.UTF8String); @@ -240,7 +240,7 @@ - (BOOL)removeFile:(NSString *)file error:(NSError **)error { return YES; } -- (BOOL)write:(NSError **)error { +- (BOOL)write:(NSError * __autoreleasing *)error { int status = git_index_write(self.git_index); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to write index."]; @@ -250,7 +250,7 @@ - (BOOL)write:(NSError **)error { return YES; } -- (GTTree *)writeTree:(NSError **)error { +- (GTTree *)writeTree:(NSError * __autoreleasing *)error { git_oid oid; int status = git_index_write_tree(&oid, self.git_index); @@ -262,7 +262,7 @@ - (GTTree *)writeTree:(NSError **)error { return [self.repository lookUpObjectByGitOid:&oid objectType:GTObjectTypeTree error:NULL]; } -- (GTTree *)writeTreeToRepository:(GTRepository *)repository error:(NSError **)error { +- (GTTree *)writeTreeToRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); git_oid oid; @@ -292,7 +292,7 @@ - (BOOL)hasConflicts { return (BOOL)git_index_has_conflicts(self.git_index); } -- (BOOL)enumerateConflictedFilesWithError:(NSError **)error usingBlock:(void (^)(GTIndexEntry *ancestor, GTIndexEntry *ours, GTIndexEntry *theirs, BOOL *stop))block { +- (BOOL)enumerateConflictedFilesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTIndexEntry *ancestor, GTIndexEntry *ours, GTIndexEntry *theirs, BOOL *stop))block { NSParameterAssert(block != nil); if (!self.hasConflicts) return YES; @@ -348,7 +348,7 @@ - (BOOL)enumerateConflictedFilesWithError:(NSError **)error usingBlock:(void (^) BOOL shouldAbortImmediately; }; -- (BOOL)updatePathspecs:(NSArray *)pathspecs error:(NSError **)error passingTest:(GTIndexPathspecMatchedBlock)block { +- (BOOL)updatePathspecs:(NSArray *)pathspecs error:(NSError * __autoreleasing *)error passingTest:(GTIndexPathspecMatchedBlock)block { NSAssert(self.repository.isBare == NO, @"This method only works with non-bare repositories."); const git_strarray strarray = pathspecs.git_strarray; @@ -403,7 +403,7 @@ - (GTIndexEntry *)entryWithName:(NSString *)name { return [self entryWithPath:name]; } -- (GTIndexEntry *)entryWithName:(NSString *)name error:(NSError **)error { +- (GTIndexEntry *)entryWithName:(NSString *)name error:(NSError * __autoreleasing *)error { return [self entryWithPath:name error:error]; } @end diff --git a/ObjectiveGit/GTIndexEntry.h b/ObjectiveGit/GTIndexEntry.h index 16b89a588..1a5c4e2c9 100644 --- a/ObjectiveGit/GTIndexEntry.h +++ b/ObjectiveGit/GTIndexEntry.h @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - will be filled if an error occurs /// /// Returns the initialized object. -- (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry index:(GTIndex * _Nullable)index error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry index:(GTIndex * _Nullable)index error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; - (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry; /// The underlying `git_index_entry` object. @@ -80,14 +80,14 @@ NS_ASSUME_NONNULL_BEGIN /// error - will be filled if an error occurs /// /// Returns this entry as a GTObject or nil if an error occurred. -- (nullable GTObject *)GTObject:(NSError **)error; +- (nullable GTObject *)GTObject:(NSError * __autoreleasing *)error; @end @interface GTObject (GTIndexEntry) -+ (instancetype _Nullable)objectWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError **)error; -- (instancetype _Nullable)initWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError **)error; ++ (instancetype _Nullable)objectWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError * __autoreleasing *)error; +- (instancetype _Nullable)initWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTIndexEntry.m b/ObjectiveGit/GTIndexEntry.m index c687d0060..a115cf098 100644 --- a/ObjectiveGit/GTIndexEntry.m +++ b/ObjectiveGit/GTIndexEntry.m @@ -55,7 +55,7 @@ - (instancetype)init { return nil; } -- (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry index:(GTIndex *)index error:(NSError **)error { +- (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry index:(GTIndex *)index error:(NSError * __autoreleasing *)error { NSParameterAssert(entry != NULL); self = [super init]; @@ -113,7 +113,7 @@ - (GTRepository *)repository { return self.index.repository; } -- (GTObject *)GTObject:(NSError **)error { +- (GTObject *)GTObject:(NSError * __autoreleasing *)error { return [GTObject objectWithIndexEntry:self error:error]; } @@ -121,11 +121,11 @@ - (GTObject *)GTObject:(NSError **)error { @implementation GTObject (GTIndexEntry) -+ (instancetype)objectWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError **)error { ++ (instancetype)objectWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError * __autoreleasing *)error { return [[self alloc] initWithIndexEntry:indexEntry error:error]; } -- (instancetype)initWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError **)error { +- (instancetype)initWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError * __autoreleasing *)error { git_object *obj; int gitError = git_object_lookup(&obj, indexEntry.repository.git_repository, indexEntry.OID.git_oid, (git_object_t)GTObjectTypeAny); diff --git a/ObjectiveGit/GTNote.h b/ObjectiveGit/GTNote.h index 008b78a5a..8cdf1b254 100644 --- a/ObjectiveGit/GTNote.h +++ b/ObjectiveGit/GTNote.h @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN /// May be NULL. /// /// Returns initialized GTNote instance or nil on failure (error will be populated, if passed). -- (instancetype _Nullable)initWithTargetOID:(GTOID *)oid repository:(GTRepository *)repository referenceName:(NSString * _Nullable)referenceName error:(NSError **)error; +- (instancetype _Nullable)initWithTargetOID:(GTOID *)oid repository:(GTRepository *)repository referenceName:(NSString * _Nullable)referenceName error:(NSError * __autoreleasing *)error; /// Create a note with target libgit2 oid in the given repository. /// @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN /// referenceName - Name for the notes reference in the repo, or NULL for default ("refs/notes/commits") /// /// Returns initialized GTNote instance or nil on failure. -- (instancetype _Nullable)initWithTargetGitOID:(git_oid *)oid repository:(git_repository *)repository referenceName:(const char * _Nullable)referenceName error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (instancetype _Nullable)initWithTargetGitOID:(git_oid *)oid repository:(git_repository *)repository referenceName:(const char * _Nullable)referenceName error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN /// May be NULL. /// /// Returns default reference name (usually "refs/notes/commits"). -+ (NSString * _Nullable)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error; ++ (NSString * _Nullable)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTNote.m b/ObjectiveGit/GTNote.m index b87039de1..47bb71237 100644 --- a/ObjectiveGit/GTNote.m +++ b/ObjectiveGit/GTNote.m @@ -59,11 +59,11 @@ - (GTOID *)targetOID { return [GTOID oidWithGitOid:git_note_id(self.git_note)]; } -- (instancetype)initWithTargetOID:(GTOID *)oid repository:(GTRepository *)repository referenceName:(NSString *)referenceName error:(NSError **)error { +- (instancetype)initWithTargetOID:(GTOID *)oid repository:(GTRepository *)repository referenceName:(NSString *)referenceName error:(NSError * __autoreleasing *)error { return [self initWithTargetGitOID:(git_oid *)oid.git_oid repository:repository.git_repository referenceName:referenceName.UTF8String error:error]; } -- (instancetype)initWithTargetGitOID:(git_oid *)oid repository:(git_repository *)repository referenceName:(const char *)referenceName error:(NSError **)error { +- (instancetype)initWithTargetGitOID:(git_oid *)oid repository:(git_repository *)repository referenceName:(const char *)referenceName error:(NSError * __autoreleasing *)error { self = [super init]; if (self == nil) return nil; @@ -82,7 +82,7 @@ - (instancetype)init { return nil; } -+ (NSString *)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error { ++ (NSString *)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSString *noteRef = nil; git_buf default_ref_name = { 0 }; diff --git a/ObjectiveGit/GTOID.h b/ObjectiveGit/GTOID.h index bd0502990..cf059c33a 100644 --- a/ObjectiveGit/GTOID.h +++ b/ObjectiveGit/GTOID.h @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be filled with an error object in if the SHA cannot be parsed /// /// Returns the initialized receiver or nil if an error occured. -- (instancetype _Nullable)initWithSHA:(NSString *)SHA error:(NSError **)error; +- (instancetype _Nullable)initWithSHA:(NSString *)SHA error:(NSError * __autoreleasing *)error; /// Initializes the receiver by converting the given SHA C string to an OID. /// @@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - Will be filled with an error object in if the SHA cannot be parsed /// /// Returns the initialized receiver. -- (instancetype _Nullable)initWithSHACString:(const char *)string error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (instancetype _Nullable)initWithSHACString:(const char *)string error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; /// Creates a new instance with the given git_oid using initWithGitOid: + (instancetype)oidWithGitOid:(const git_oid *)git_oid; @@ -85,7 +85,7 @@ NS_ASSUME_NONNULL_BEGIN /// type - The type of the git object. /// /// Returns a new OID, or nil if an error occurred. -+ (instancetype _Nullable)OIDByHashingData:(NSData *)data type:(GTObjectType)type error:(NSError **)error; ++ (instancetype _Nullable)OIDByHashingData:(NSData *)data type:(GTObjectType)type error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTOID.m b/ObjectiveGit/GTOID.m index 8010c2885..725ef9a63 100644 --- a/ObjectiveGit/GTOID.m +++ b/ObjectiveGit/GTOID.m @@ -53,7 +53,7 @@ - (instancetype)initWithGitOid:(const git_oid *)oid { return self; } -- (instancetype)initWithSHA:(NSString *)SHA error:(NSError **)error { +- (instancetype)initWithSHA:(NSString *)SHA error:(NSError * __autoreleasing *)error { NSParameterAssert(SHA != nil); const char *SHACString = SHA.UTF8String; NSAssert(SHACString, @"Unexpected nil SHA"); @@ -64,7 +64,7 @@ - (instancetype)initWithSHA:(NSString *)SHA { return [self initWithSHA:SHA error:NULL]; } -- (instancetype)initWithSHACString:(const char *)string error:(NSError **)error { +- (instancetype)initWithSHACString:(const char *)string error:(NSError * __autoreleasing *)error { NSParameterAssert(string != NULL); self = [super init]; @@ -129,7 +129,7 @@ - (id)copyWithZone:(NSZone *)zone { @implementation GTOID (GTObjectDatabase) -+ (instancetype)OIDByHashingData:(NSData *)data type:(GTObjectType)type error:(NSError **)error { ++ (instancetype)OIDByHashingData:(NSData *)data type:(GTObjectType)type error:(NSError * __autoreleasing *)error { NSParameterAssert(data != nil); git_oid oid; diff --git a/ObjectiveGit/GTObject.h b/ObjectiveGit/GTObject.h index 3167dc139..6cf0f1f07 100644 --- a/ObjectiveGit/GTObject.h +++ b/ObjectiveGit/GTObject.h @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN /// error(out) - will be filled if an error occurs /// /// returns a GTOdbObject or nil if an error occurred. -- (GTOdbObject * _Nullable)odbObjectWithError:(NSError **)error; +- (GTOdbObject * _Nullable)odbObjectWithError:(NSError * __autoreleasing *)error; /// Recursively peel an object until an object of the specified type is met. /// @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN /// May be NULL. /// /// Returns the found object or nil on error. -- (id _Nullable)objectByPeelingToType:(GTObjectType)type error:(NSError **)error; +- (id _Nullable)objectByPeelingToType:(GTObjectType)type error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTObject.m b/ObjectiveGit/GTObject.m index 503585092..23cbfee52 100644 --- a/ObjectiveGit/GTObject.m +++ b/ObjectiveGit/GTObject.m @@ -140,14 +140,14 @@ - (NSString *)shortSHA { return [self.SHA git_shortUniqueShaString]; } -- (GTOdbObject *)odbObjectWithError:(NSError **)error { +- (GTOdbObject *)odbObjectWithError:(NSError * __autoreleasing *)error { GTObjectDatabase *database = [self.repository objectDatabaseWithError:error]; if (database == nil) return nil; return [database objectWithOID:self.OID error:error]; } -- (id)objectByPeelingToType:(GTObjectType)type error:(NSError **)error { +- (id)objectByPeelingToType:(GTObjectType)type error:(NSError * __autoreleasing *)error { git_object *peeled = NULL; int gitError = git_object_peel(&peeled, self.git_object, (git_object_t)type); if (gitError != GIT_OK) { diff --git a/ObjectiveGit/GTObjectDatabase.h b/ObjectiveGit/GTObjectDatabase.h index c111d8b6a..ef47d149a 100644 --- a/ObjectiveGit/GTObjectDatabase.h +++ b/ObjectiveGit/GTObjectDatabase.h @@ -42,13 +42,13 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the initialized object. -- (instancetype _Nullable)initWithRepository:(GTRepository *)repo error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (instancetype _Nullable)initWithRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; /// The underlying `git_odb` object. - (git_odb *)git_odb __attribute__((objc_returns_inner_pointer)); -- (GTOdbObject * _Nullable)objectWithOID:(GTOID *)OID error:(NSError **)error; -- (GTOdbObject * _Nullable)objectWithSHA:(NSString *)SHA error:(NSError **)error; +- (GTOdbObject * _Nullable)objectWithOID:(GTOID *)OID error:(NSError * __autoreleasing *)error; +- (GTOdbObject * _Nullable)objectWithSHA:(NSString *)SHA error:(NSError * __autoreleasing *)error; /// Writes the data into the object database. /// @@ -58,9 +58,9 @@ NS_ASSUME_NONNULL_BEGIN /// /// Returns the OID for the object which was written, or nil if an error /// occurred. -- (GTOID * _Nullable)writeData:(NSData *)data type:(GTObjectType)type error:(NSError **)error; +- (GTOID * _Nullable)writeData:(NSData *)data type:(GTObjectType)type error:(NSError * __autoreleasing *)error; -- (BOOL)containsObjectWithSHA:(NSString *)SHA error:(NSError **)error; +- (BOOL)containsObjectWithSHA:(NSString *)SHA error:(NSError * __autoreleasing *)error; /// Checks if the object database contains an object with a given OID. /// diff --git a/ObjectiveGit/GTObjectDatabase.m b/ObjectiveGit/GTObjectDatabase.m index 99c431a48..6dbe2364e 100644 --- a/ObjectiveGit/GTObjectDatabase.m +++ b/ObjectiveGit/GTObjectDatabase.m @@ -61,7 +61,7 @@ - (instancetype)init { return nil; } -- (instancetype)initWithRepository:(GTRepository *)repo error:(NSError **)error { +- (instancetype)initWithRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error { NSParameterAssert(repo != nil); self = [super init]; @@ -78,7 +78,7 @@ - (instancetype)initWithRepository:(GTRepository *)repo error:(NSError **)error return self; } -- (GTOdbObject *)objectWithOID:(GTOID *)oid error:(NSError **)error { +- (GTOdbObject *)objectWithOID:(GTOID *)oid error:(NSError * __autoreleasing *)error { git_odb_object *obj; int gitError = git_odb_read(&obj, self.git_odb, oid.git_oid); if (gitError != GIT_OK) { @@ -89,7 +89,7 @@ - (GTOdbObject *)objectWithOID:(GTOID *)oid error:(NSError **)error { return [[GTOdbObject alloc] initWithOdbObj:obj repository:self.repository]; } -- (GTOdbObject *)objectWithSHA:(NSString *)sha error:(NSError **)error { +- (GTOdbObject *)objectWithSHA:(NSString *)sha error:(NSError * __autoreleasing *)error { GTOID *oid = [[GTOID alloc] initWithSHA:sha error:error]; if (oid == nil) return nil; @@ -98,7 +98,7 @@ - (GTOdbObject *)objectWithSHA:(NSString *)sha error:(NSError **)error { #pragma mark Writing -- (GTOID *)writeData:(NSData *)data type:(GTObjectType)type error:(NSError **)error { +- (GTOID *)writeData:(NSData *)data type:(GTObjectType)type error:(NSError * __autoreleasing *)error { NSParameterAssert(data != nil); git_odb_stream *stream; @@ -128,7 +128,7 @@ - (GTOID *)writeData:(NSData *)data type:(GTObjectType)type error:(NSError **)er return [GTOID oidWithGitOid:&oid]; } -- (BOOL)containsObjectWithSHA:(NSString *)sha error:(NSError **)error { +- (BOOL)containsObjectWithSHA:(NSString *)sha error:(NSError * __autoreleasing *)error { GTOID *oid = [[GTOID alloc] initWithSHA:sha error:error]; if (oid == nil) return NO; diff --git a/ObjectiveGit/GTReference.h b/ObjectiveGit/GTReference.h index c24a9fc7b..4c2e93b27 100644 --- a/ObjectiveGit/GTReference.h +++ b/ObjectiveGit/GTReference.h @@ -70,8 +70,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, strong) GTReflog * _Nullable reflog; /// Convenience initializers -+ (instancetype _Nullable)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error; -- (instancetype _Nullable)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error; ++ (instancetype _Nullable)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError * __autoreleasing *)error; +- (instancetype _Nullable)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the updated reference, or nil if an error occurred. -- (GTReference * _Nullable)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString * _Nullable)message error:(NSError **)error; +- (GTReference * _Nullable)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString * _Nullable)message error:(NSError * __autoreleasing *)error; /// The name of the reference. @property (nonatomic, readonly, copy) NSString *name; @@ -122,28 +122,28 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the renamed reference, or nil if an error occurred. -- (GTReference * _Nullable)referenceByRenaming:(NSString *)newName error:(NSError **)error; +- (GTReference * _Nullable)referenceByRenaming:(NSString *)newName error:(NSError * __autoreleasing *)error; /// Delete this reference. /// /// error - The error if one occurred. /// /// Returns whether the deletion was successful. -- (BOOL)deleteWithError:(NSError **)error; +- (BOOL)deleteWithError:(NSError * __autoreleasing *)error; /// Resolve this reference as a symbolic ref /// /// error(out) - will be filled if an error occurs /// /// returns the peeled GTReference or nil if an error occurred. -- (GTReference * _Nullable)resolvedReferenceWithError:(NSError **)error; +- (GTReference * _Nullable)resolvedReferenceWithError:(NSError * __autoreleasing *)error; /// Reload the reference from disk. /// /// error - The error if one occurred. /// /// Returns the reloaded reference, or nil if an error occurred. -- (GTReference * _Nullable)reloadedReferenceWithError:(NSError **)error; +- (GTReference * _Nullable)reloadedReferenceWithError:(NSError * __autoreleasing *)error; /// An error indicating that the git_reference is no longer valid. + (NSError *)invalidReferenceError; diff --git a/ObjectiveGit/GTReference.m b/ObjectiveGit/GTReference.m index 080375dd2..51a8ad7a1 100644 --- a/ObjectiveGit/GTReference.m +++ b/ObjectiveGit/GTReference.m @@ -70,7 +70,7 @@ - (BOOL)isRemote { return git_reference_is_remote(self.git_reference) != 0; } -+ (instancetype)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error { ++ (instancetype)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError * __autoreleasing *)error { return [[self alloc] initByResolvingSymbolicReference:symbolicRef error:error]; } @@ -79,7 +79,7 @@ - (instancetype)init { return nil; } -- (instancetype)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error { +- (instancetype)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError * __autoreleasing *)error { NSParameterAssert(symbolicRef != nil); git_reference *ref = NULL; @@ -126,7 +126,7 @@ - (NSString *)name { return refName; } -- (GTReference *)referenceByRenaming:(NSString *)newName error:(NSError **)error { +- (GTReference *)referenceByRenaming:(NSString *)newName error:(NSError * __autoreleasing *)error { NSParameterAssert(newName != nil); git_reference *newRef = NULL; @@ -176,7 +176,7 @@ - (GTOID *)targetOID { return [self.resolvedTarget OID]; } -- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString *)message error:(NSError **)error { +- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString *)message error:(NSError * __autoreleasing *)error { NSParameterAssert(newTarget != nil); int gitError; @@ -198,7 +198,7 @@ - (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSStri return [[self.class alloc] initWithGitReference:newRef repository:self.repository]; } -- (BOOL)deleteWithError:(NSError **)error { +- (BOOL)deleteWithError:(NSError * __autoreleasing *)error { int gitError = git_reference_delete(self.git_reference); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to delete reference %@.", self.name]; @@ -208,7 +208,7 @@ - (BOOL)deleteWithError:(NSError **)error { return YES; } -- (GTReference *)resolvedReferenceWithError:(NSError **)error { +- (GTReference *)resolvedReferenceWithError:(NSError * __autoreleasing *)error { return [GTReference referenceByResolvingSymbolicReference:self error:error]; } @@ -223,7 +223,7 @@ - (GTOID *)OID { return [[GTOID alloc] initWithGitOid:oid]; } -- (GTReference *)reloadedReferenceWithError:(NSError **)error { +- (GTReference *)reloadedReferenceWithError:(NSError * __autoreleasing *)error { return [self.repository lookUpReferenceWithName:self.name error:error]; } diff --git a/ObjectiveGit/GTReflog.h b/ObjectiveGit/GTReflog.h index feeafea51..5fed8b2a7 100644 --- a/ObjectiveGit/GTReflog.h +++ b/ObjectiveGit/GTReflog.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether the entry was successfully written. -- (BOOL)writeEntryWithCommitter:(GTSignature *)committer message:(NSString *)message error:(NSError **)error; +- (BOOL)writeEntryWithCommitter:(GTSignature *)committer message:(NSString *)message error:(NSError * __autoreleasing *)error; /// Get the reflog entry at the given index. /// diff --git a/ObjectiveGit/GTReflog.m b/ObjectiveGit/GTReflog.m index be1ecad6b..7561ff9ec 100644 --- a/ObjectiveGit/GTReflog.m +++ b/ObjectiveGit/GTReflog.m @@ -55,7 +55,7 @@ - (instancetype)initWithReference:(GTReference *)reference { #pragma mark Entries -- (BOOL)writeEntryWithCommitter:(GTSignature *)committer message:(NSString *)message error:(NSError **)error { +- (BOOL)writeEntryWithCommitter:(GTSignature *)committer message:(NSString *)message error:(NSError * __autoreleasing *)error { NSParameterAssert(committer != nil); int status = git_reflog_append(self.git_reflog, self.reference.git_oid, committer.git_signature, message.UTF8String); diff --git a/ObjectiveGit/GTRemote.h b/ObjectiveGit/GTRemote.h index bde9a37f1..a471d5314 100644 --- a/ObjectiveGit/GTRemote.h +++ b/ObjectiveGit/GTRemote.h @@ -75,7 +75,7 @@ typedef enum { /// error - Will be set if an error occurs. /// /// Returns a new remote, or nil if an error occurred -+ (instancetype _Nullable)createRemoteWithName:(NSString *)name URLString:(NSString *)URLString inRepository:(GTRepository *)repo error:(NSError **)error; ++ (instancetype _Nullable)createRemoteWithName:(NSString *)name URLString:(NSString *)URLString inRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error; /// Load a remote from a repository. /// @@ -84,7 +84,7 @@ typedef enum { /// error - Will be set if an error occurs. /// /// Returns the loaded remote, or nil if an error occurred. -+ (instancetype _Nullable)remoteWithName:(NSString *)name inRepository:(GTRepository *)repo error:(NSError **)error; ++ (instancetype _Nullable)remoteWithName:(NSString *)name inRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -107,7 +107,7 @@ typedef enum { /// `GTRemoteRenameProblematicRefSpecs` key. /// /// Return YES if successful, NO otherwise. -- (BOOL)rename:(NSString *)name error:(NSError **)error; +- (BOOL)rename:(NSString *)name error:(NSError * __autoreleasing *)error; /// Updates the URL string for this remote. /// @@ -117,7 +117,7 @@ typedef enum { /// /// Returns YES if the URLString was successfully updated, NO and an error /// if updating or saving the remote failed. -- (BOOL)updateURLString:(NSString *)URLString error:(NSError **)error; +- (BOOL)updateURLString:(NSString *)URLString error:(NSError * __autoreleasing *)error; /// Updates the push URL string for this remote. /// @@ -127,7 +127,7 @@ typedef enum { /// /// Returns YES if the push URLString was successfully updated, NO and an error /// if updating or saving the remote failed. -- (BOOL)updatePushURLString:(NSString *)URLString error:(NSError **)error; +- (BOOL)updatePushURLString:(NSString *)URLString error:(NSError * __autoreleasing *)error; /// Adds a fetch refspec to this remote. /// @@ -138,7 +138,7 @@ typedef enum { /// Returns YES if there is the refspec is successfully added /// or a matching refspec is already present, NO and an error if /// adding the refspec or saving the remote failed. -- (BOOL)addFetchRefspec:(NSString *)fetchRefspec error:(NSError **)error; +- (BOOL)addFetchRefspec:(NSString *)fetchRefspec error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRemote.m b/ObjectiveGit/GTRemote.m index 03f76b7ca..7eb321356 100644 --- a/ObjectiveGit/GTRemote.m +++ b/ObjectiveGit/GTRemote.m @@ -29,7 +29,7 @@ @implementation GTRemote #pragma mark Lifecycle -+ (instancetype)createRemoteWithName:(NSString *)name URLString:(NSString *)URLString inRepository:(GTRepository *)repo error:(NSError **)error { ++ (instancetype)createRemoteWithName:(NSString *)name URLString:(NSString *)URLString inRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); NSParameterAssert(URLString != nil); NSParameterAssert(repo != nil); @@ -45,7 +45,7 @@ + (instancetype)createRemoteWithName:(NSString *)name URLString:(NSString *)URLS return [[self alloc] initWithGitRemote:remote inRepository:repo]; } -+ (instancetype)remoteWithName:(NSString *)name inRepository:(GTRepository *)repo error:(NSError **)error { ++ (instancetype)remoteWithName:(NSString *)name inRepository:(GTRepository *)repo error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); NSParameterAssert(repo != nil); @@ -144,7 +144,7 @@ - (BOOL)isConnected { #pragma mark Renaming -- (BOOL)rename:(NSString *)name error:(NSError **)error { +- (BOOL)rename:(NSString *)name error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); git_strarray problematic_refspecs; @@ -189,7 +189,7 @@ - (NSArray *)pushRefspecs { #pragma mark Update the remote -- (BOOL)updateURLString:(NSString *)URLString error:(NSError **)error { +- (BOOL)updateURLString:(NSString *)URLString error:(NSError * __autoreleasing *)error { NSParameterAssert(URLString != nil); if ([self.URLString isEqualToString:URLString]) return YES; @@ -204,7 +204,7 @@ - (BOOL)updateURLString:(NSString *)URLString error:(NSError **)error { return YES; } -- (BOOL)updatePushURLString:(NSString *)URLString error:(NSError **)error { +- (BOOL)updatePushURLString:(NSString *)URLString error:(NSError * __autoreleasing *)error { NSParameterAssert(URLString != nil); if ([self.pushURLString isEqualToString:URLString]) return YES; @@ -219,7 +219,7 @@ - (BOOL)updatePushURLString:(NSString *)URLString error:(NSError **)error { return YES; } -- (BOOL)addFetchRefspec:(NSString *)fetchRefspec error:(NSError **)error { +- (BOOL)addFetchRefspec:(NSString *)fetchRefspec error:(NSError * __autoreleasing *)error { NSParameterAssert(fetchRefspec != nil); if ([self.fetchRefspecs containsObject:fetchRefspec]) return YES; diff --git a/ObjectiveGit/GTRepository+Blame.h b/ObjectiveGit/GTRepository+Blame.h index 603274f25..cf2a86990 100644 --- a/ObjectiveGit/GTRepository+Blame.h +++ b/ObjectiveGit/GTRepository+Blame.h @@ -46,6 +46,6 @@ extern NSString * const GTBlameOptionsLastLine; /// error - Populated with an `NSError` object on error. /// /// Returns a new `GTBlame` object or nil if an error occurred. -- (GTBlame *)blameWithFile:(NSString *)path options:(NSDictionary *)options error:(NSError **)error; +- (GTBlame *)blameWithFile:(NSString *)path options:(NSDictionary *)options error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Blame.m b/ObjectiveGit/GTRepository+Blame.m index 1138eae3b..ac8de941f 100644 --- a/ObjectiveGit/GTRepository+Blame.m +++ b/ObjectiveGit/GTRepository+Blame.m @@ -20,7 +20,7 @@ @implementation GTRepository (Blame) -- (GTBlame *)blameWithFile:(NSString *)path options:(NSDictionary *)options error:(NSError **)error { +- (GTBlame *)blameWithFile:(NSString *)path options:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(path != nil); git_blame *blame = NULL; diff --git a/ObjectiveGit/GTRepository+Committing.h b/ObjectiveGit/GTRepository+Committing.h index 4e5518664..858eda30e 100644 --- a/ObjectiveGit/GTRepository+Committing.h +++ b/ObjectiveGit/GTRepository+Committing.h @@ -25,11 +25,11 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the newly created commit, or nil if an error occurred. -- (GTCommit * _Nullable)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(NSArray * _Nullable)parents updatingReferenceNamed:(NSString * _Nullable)refName error:(NSError **)error; +- (GTCommit * _Nullable)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(NSArray * _Nullable)parents updatingReferenceNamed:(NSString * _Nullable)refName error:(NSError * __autoreleasing *)error; /// Creates a new commit using +createCommitWithTree:message:author:committer:parents:updatingReferenceNamed:error: /// with -userSignatureForNow as both the author and committer. -- (GTCommit * _Nullable)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(NSArray * _Nullable)parents updatingReferenceNamed:(NSString * _Nullable)refName error:(NSError **)error; +- (GTCommit * _Nullable)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(NSArray * _Nullable)parents updatingReferenceNamed:(NSString * _Nullable)refName error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Committing.m b/ObjectiveGit/GTRepository+Committing.m index 93e4e7480..ea09c2024 100644 --- a/ObjectiveGit/GTRepository+Committing.m +++ b/ObjectiveGit/GTRepository+Committing.m @@ -18,7 +18,7 @@ @implementation GTRepository (Committing) -- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError **)error { +- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError * __autoreleasing *)error { NSParameterAssert(tree != nil); NSParameterAssert(message != nil); @@ -26,7 +26,7 @@ - (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message pa return [self createCommitWithTree:tree message:message author:signature committer:signature parents:parents updatingReferenceNamed:refName error:error]; } -- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError **)error { +- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError * __autoreleasing *)error { NSParameterAssert(tree != nil); NSParameterAssert(message != nil); NSParameterAssert(author != nil); diff --git a/ObjectiveGit/GTRepository+Merging.h b/ObjectiveGit/GTRepository+Merging.h index 53649a095..322965720 100644 --- a/ObjectiveGit/GTRepository+Merging.h +++ b/ObjectiveGit/GTRepository+Merging.h @@ -35,14 +35,14 @@ typedef NS_OPTIONS(NSInteger, GTMergeAnalysis) { /// enumeration to stop after the block returns. Must not be nil. /// /// Returns YES if the operation succedded, NO otherwise. -- (BOOL)enumerateMergeHeadEntriesWithError:(NSError **)error usingBlock:(void (^)(GTOID *mergeHeadEntry, BOOL *stop))block; +- (BOOL)enumerateMergeHeadEntriesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTOID *mergeHeadEntry, BOOL *stop))block; /// Convenience method for -enumerateMergeHeadEntriesWithError:usingBlock: that retuns an NSArray with all the fetch head entries. /// /// error - The error if one ocurred. Can be NULL. /// /// Retruns a (possibly empty) array with GTOID objects. Will not be nil. -- (NSArray *)mergeHeadEntriesWithError:(NSError **)error; +- (NSArray *)mergeHeadEntriesWithError:(NSError * __autoreleasing *)error; /// Merge Branch into current branch /// @@ -51,7 +51,7 @@ typedef NS_OPTIONS(NSInteger, GTMergeAnalysis) { /// /// Returns YES if the merge was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)fromBranch withError:(NSError **)error; +- (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)fromBranch withError:(NSError * __autoreleasing *)error; /// Gets the file content with conflict markers for the given file /// @@ -63,7 +63,7 @@ typedef NS_OPTIONS(NSInteger, GTMergeAnalysis) { /// error - The error if one occurred. Can be NULL. /// /// Returns The file content annotated with conflict markers or null on error -- (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourSide:(GTIndexEntry *)ourSide theirSide:(GTIndexEntry *)theirSide error:(NSError **)error; +- (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourSide:(GTIndexEntry *)ourSide theirSide:(GTIndexEntry *)theirSide error:(NSError * __autoreleasing *)error; /// Analyze which merge to perform. /// @@ -73,7 +73,7 @@ typedef NS_OPTIONS(NSInteger, GTMergeAnalysis) { /// /// Returns YES if the analysis was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)analyzeMerge:(GTMergeAnalysis *)analysis fromBranch:(GTBranch *)fromBranch error:(NSError **)error; +- (BOOL)analyzeMerge:(GTMergeAnalysis *)analysis fromBranch:(GTBranch *)fromBranch error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Merging.m b/ObjectiveGit/GTRepository+Merging.m index f7b9837df..6c4e00479 100644 --- a/ObjectiveGit/GTRepository+Merging.m +++ b/ObjectiveGit/GTRepository+Merging.m @@ -44,7 +44,7 @@ int GTMergeHeadEntriesCallback(const git_oid *oid, void *payload) { return (stop == YES ? GIT_EUSER : 0); } -- (BOOL)enumerateMergeHeadEntriesWithError:(NSError **)error usingBlock:(void (^)(GTOID *mergeHeadEntry, BOOL *stop))block { +- (BOOL)enumerateMergeHeadEntriesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTOID *mergeHeadEntry, BOOL *stop))block { NSParameterAssert(block != nil); GTEnumerateMergeHeadEntriesPayload payload = { @@ -61,7 +61,7 @@ - (BOOL)enumerateMergeHeadEntriesWithError:(NSError **)error usingBlock:(void (^ return YES; } -- (NSArray *)mergeHeadEntriesWithError:(NSError **)error { +- (NSArray *)mergeHeadEntriesWithError:(NSError * __autoreleasing *)error { NSMutableArray *entries = [NSMutableArray array]; [self enumerateMergeHeadEntriesWithError:error usingBlock:^(GTOID *mergeHeadEntry, BOOL *stop) { @@ -73,7 +73,7 @@ - (NSArray *)mergeHeadEntriesWithError:(NSError **)error { return entries; } -- (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)error { +- (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError * __autoreleasing *)error { // Check if merge is necessary GTBranch *localBranch = [self currentBranchWithError:error]; if (!localBranch) { @@ -172,7 +172,7 @@ - (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)er return NO; } -- (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourSide:(GTIndexEntry *)ourSide theirSide:(GTIndexEntry *)theirSide error:(NSError **)error { +- (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourSide:(GTIndexEntry *)ourSide theirSide:(GTIndexEntry *)theirSide error:(NSError * __autoreleasing *)error { GTObjectDatabase *database = [self objectDatabaseWithError:error]; if (database == nil) { @@ -247,7 +247,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS return mergedContent; } -- (BOOL)annotatedCommit:(git_annotated_commit **)annotatedCommit fromCommit:(GTCommit *)fromCommit error:(NSError **)error { +- (BOOL)annotatedCommit:(git_annotated_commit **)annotatedCommit fromCommit:(GTCommit *)fromCommit error:(NSError * __autoreleasing *)error { int gitError = git_annotated_commit_lookup(annotatedCommit, self.git_repository, fromCommit.OID.git_oid); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to lookup annotated commit for %@", fromCommit]; @@ -257,7 +257,7 @@ - (BOOL)annotatedCommit:(git_annotated_commit **)annotatedCommit fromCommit:(GTC return YES; } -- (BOOL)analyzeMerge:(GTMergeAnalysis *)analysis fromBranch:(GTBranch *)fromBranch error:(NSError **)error { +- (BOOL)analyzeMerge:(GTMergeAnalysis *)analysis fromBranch:(GTBranch *)fromBranch error:(NSError * __autoreleasing *)error { NSParameterAssert(analysis != NULL); NSParameterAssert(fromBranch != nil); diff --git a/ObjectiveGit/GTRepository+Private.h b/ObjectiveGit/GTRepository+Private.h index f3341730c..8b086d088 100644 --- a/ObjectiveGit/GTRepository+Private.h +++ b/ObjectiveGit/GTRepository+Private.h @@ -12,8 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @interface GTRepository () -- (id _Nullable)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError **)error; -- (id _Nullable)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError **)error; +- (id _Nullable)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error; +- (id _Nullable)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Pull.h b/ObjectiveGit/GTRepository+Pull.h index cbc1f74fd..63c1abc36 100644 --- a/ObjectiveGit/GTRepository+Pull.h +++ b/ObjectiveGit/GTRepository+Pull.h @@ -30,7 +30,7 @@ typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress * /// /// Returns YES if the pull was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(GTRemoteFetchTransferProgressBlock _Nullable)progressBlock; +- (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(GTRemoteFetchTransferProgressBlock _Nullable)progressBlock; @end diff --git a/ObjectiveGit/GTRepository+Pull.m b/ObjectiveGit/GTRepository+Pull.m index b99bf37ce..8b3466db6 100644 --- a/ObjectiveGit/GTRepository+Pull.m +++ b/ObjectiveGit/GTRepository+Pull.m @@ -20,7 +20,7 @@ @implementation GTRepository (Pull) #pragma mark - Pull -- (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemoteFetchTransferProgressBlock)progressBlock { +- (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemoteFetchTransferProgressBlock)progressBlock { NSParameterAssert(branch != nil); NSParameterAssert(remote != nil); diff --git a/ObjectiveGit/GTRepository+References.h b/ObjectiveGit/GTRepository+References.h index cfddac2fc..a28fb2cfa 100644 --- a/ObjectiveGit/GTRepository+References.h +++ b/ObjectiveGit/GTRepository+References.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurs. May be NULL. /// /// Returns the reference or nil if look up failed. -- (GTReference * _Nullable)lookUpReferenceWithName:(NSString *)name error:(NSError **)error; +- (GTReference * _Nullable)lookUpReferenceWithName:(NSString *)name error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+References.m b/ObjectiveGit/GTRepository+References.m index 1494d7539..90ce49369 100644 --- a/ObjectiveGit/GTRepository+References.m +++ b/ObjectiveGit/GTRepository+References.m @@ -14,7 +14,7 @@ @implementation GTRepository (References) -- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError **)error { +- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); git_reference *ref = NULL; diff --git a/ObjectiveGit/GTRepository+RemoteOperations.h b/ObjectiveGit/GTRepository+RemoteOperations.h index d93ebaad7..e4152749c 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.h +++ b/ObjectiveGit/GTRepository+RemoteOperations.h @@ -51,7 +51,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the fetch was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(const git_transfer_progress *stats, BOOL *stop))progressBlock; +- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(const git_transfer_progress *stats, BOOL *stop))progressBlock; /// Enumerate all available fetch head entries. /// @@ -61,14 +61,14 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// enumeration to stop after the block returns. Must not be nil. /// /// Returns YES if the operation succedded, NO otherwise. -- (BOOL)enumerateFetchHeadEntriesWithError:(NSError **)error usingBlock:(void (^)(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop))block; +- (BOOL)enumerateFetchHeadEntriesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop))block; /// Convenience method for -enumerateFetchHeadEntriesWithError:usingBlock: that retuns an NSArray with all the fetch head entries. /// /// error - The error if one ocurred. Can be NULL. /// /// Retruns a (possibly empty) array with GTFetchHeadEntry objects. Will not be nil. -- (NSArray *)fetchHeadEntriesWithError:(NSError **)error; +- (NSArray *)fetchHeadEntriesWithError:(NSError * __autoreleasing *)error; #pragma mark - Push @@ -85,7 +85,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the push was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; +- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; /// Push an array of branches to a remote. /// @@ -100,7 +100,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the push was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; +- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; /// Push a given Git notes reference name to a remote. /// @@ -114,7 +114,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the push was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)pushNotes:(NSString * _Nullable)noteReferenceName toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; +- (BOOL)pushNotes:(NSString * _Nullable)noteReferenceName toRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock; /// Delete a remote branch /// @@ -127,7 +127,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the push was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error; +- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; @end NS_ASSUME_NONNULL_END diff --git a/ObjectiveGit/GTRepository+RemoteOperations.m b/ObjectiveGit/GTRepository+RemoteOperations.m index 822171ab9..de57b60b9 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.m +++ b/ObjectiveGit/GTRepository+RemoteOperations.m @@ -69,7 +69,7 @@ int GTRemotePushTransferProgressCallback(unsigned int current, unsigned int tota #pragma mark - Fetch -- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemoteFetchTransferProgressBlock)progressBlock { +- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemoteFetchTransferProgressBlock)progressBlock { GTCredentialProvider *credProvider = options[GTRepositoryRemoteOptionsCredentialProvider]; GTRemoteConnectionInfo connectionInfo = { @@ -143,7 +143,7 @@ int GTFetchHeadEntriesCallback(const char *ref_name, const char *remote_url, con return (stop == YES ? GIT_EUSER : 0); } -- (BOOL)enumerateFetchHeadEntriesWithError:(NSError **)error usingBlock:(void (^)(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop))block { +- (BOOL)enumerateFetchHeadEntriesWithError:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop))block { NSParameterAssert(block != nil); GTEnumerateHeadEntriesPayload payload = { @@ -160,7 +160,7 @@ - (BOOL)enumerateFetchHeadEntriesWithError:(NSError **)error usingBlock:(void (^ return YES; } -- (NSArray *)fetchHeadEntriesWithError:(NSError **)error { +- (NSArray *)fetchHeadEntriesWithError:(NSError * __autoreleasing *)error { NSMutableArray *entries = [NSMutableArray array]; [self enumerateFetchHeadEntriesWithError:error usingBlock:^(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop) { @@ -174,14 +174,14 @@ - (NSArray *)fetchHeadEntriesWithError:(NSError **)error { #pragma mark - Push (Public) -- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock { +- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemotePushTransferProgressBlock)progressBlock { NSParameterAssert(branch != nil); NSParameterAssert(remote != nil); return [self pushBranches:@[ branch ] toRemote:remote withOptions:options error:error progress:progressBlock]; } -- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock { +- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemotePushTransferProgressBlock)progressBlock { NSParameterAssert(branches != nil); NSParameterAssert(branches.count != 0); NSParameterAssert(remote != nil); @@ -232,7 +232,7 @@ - (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions return [self pushRefspecs:refspecs toRemote:remote withOptions:options error:error progress:progressBlock]; } -- (BOOL)pushNotes:(NSString *)noteRef toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock { +- (BOOL)pushNotes:(NSString *)noteRef toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemotePushTransferProgressBlock)progressBlock { NSParameterAssert(remote != nil); if (noteRef == nil) { @@ -249,7 +249,7 @@ - (BOOL)pushNotes:(NSString *)noteRef toRemote:(GTRemote *)remote withOptions:(N } #pragma mark - Deletion (Public) -- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error { +- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error { NSParameterAssert(branch != nil); NSParameterAssert(remote != nil); @@ -260,7 +260,7 @@ - (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOption #pragma mark - Push (Private) -- (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock { +- (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error progress:(GTRemotePushTransferProgressBlock)progressBlock { int gitError; GTCredentialProvider *credProvider = options[GTRepositoryRemoteOptionsCredentialProvider]; diff --git a/ObjectiveGit/GTRepository+Reset.h b/ObjectiveGit/GTRepository+Reset.h index cbb06158a..fd986e177 100644 --- a/ObjectiveGit/GTRepository+Reset.h +++ b/ObjectiveGit/GTRepository+Reset.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether the reset was succcessful. -- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError **)error; +- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError * __autoreleasing *)error; /// Resets the given pathspecs in the index to the tree entries from the commit. /// @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether the reset was successful. -- (BOOL)resetPathspecs:(NSArray *)pathspecs toCommit:(GTCommit *)commit error:(NSError **)error; +- (BOOL)resetPathspecs:(NSArray *)pathspecs toCommit:(GTCommit *)commit error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Reset.m b/ObjectiveGit/GTRepository+Reset.m index 71d24b1f0..acb8db17c 100644 --- a/ObjectiveGit/GTRepository+Reset.m +++ b/ObjectiveGit/GTRepository+Reset.m @@ -16,7 +16,7 @@ @implementation GTRepository (Reset) -- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError **)error { +- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError * __autoreleasing *)error { NSParameterAssert(commit != nil); git_checkout_options options = GIT_CHECKOUT_OPTIONS_INIT; @@ -32,7 +32,7 @@ - (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetT return YES; } -- (BOOL)resetPathspecs:(NSArray *)paths toCommit:(GTCommit *)commit error:(NSError **)error { +- (BOOL)resetPathspecs:(NSArray *)paths toCommit:(GTCommit *)commit error:(NSError * __autoreleasing *)error { NSParameterAssert(paths != nil); NSParameterAssert(commit != nil); diff --git a/ObjectiveGit/GTRepository+Stashing.h b/ObjectiveGit/GTRepository+Stashing.h index a7dc57b34..8086abc58 100644 --- a/ObjectiveGit/GTRepository+Stashing.h +++ b/ObjectiveGit/GTRepository+Stashing.h @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN /// /// Returns a commit representing the stashed changes if successful, or nil /// otherwise. -- (GTCommit * _Nullable)stashChangesWithMessage:(NSString * _Nullable)message flags:(GTRepositoryStashFlag)flags error:(NSError **)error; +- (GTCommit * _Nullable)stashChangesWithMessage:(NSString * _Nullable)message flags:(GTRepositoryStashFlag)flags error:(NSError * __autoreleasing *)error; /// Enumerate over all the stashes in the repository, from most recent to oldest. /// @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN /// progressBlock - A block that will be executed on each step of the stash application. /// /// Returns YES if the requested stash was successfully applied, NO otherwise. -- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions * _Nullable)options error:(NSError **)error progressBlock:(void (^ _Nullable)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock; +- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error progressBlock:(void (^ _Nullable)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock; /// Pop stashed changes. /// @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN /// progressBlock - A block that will be executed on each step of the stash application. /// /// Returns YES if the requested stash was successfully applied, NO otherwise. -- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions * _Nullable)options error:(NSError **)error progressBlock:(void (^ _Nullable)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock; +- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error progressBlock:(void (^ _Nullable)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock; /// Drop a stash from the repository's list of stashes. /// @@ -90,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns YES if the stash was successfully dropped, NO otherwise -- (BOOL)dropStashAtIndex:(NSUInteger)index error:(NSError **)error; +- (BOOL)dropStashAtIndex:(NSUInteger)index error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Stashing.m b/ObjectiveGit/GTRepository+Stashing.m index e5903a87f..fd5d55409 100644 --- a/ObjectiveGit/GTRepository+Stashing.m +++ b/ObjectiveGit/GTRepository+Stashing.m @@ -18,7 +18,7 @@ @implementation GTRepository (Stashing) -- (GTCommit *)stashChangesWithMessage:(NSString *)message flags:(GTRepositoryStashFlag)flags error:(NSError **)error { +- (GTCommit *)stashChangesWithMessage:(NSString *)message flags:(GTRepositoryStashFlag)flags error:(NSError * __autoreleasing *)error { git_oid git_oid; int gitError = git_stash_save(&git_oid, self.git_repository, [self userSignatureForNow].git_signature, message.UTF8String, flags); @@ -59,7 +59,7 @@ static int stashApplyProgressCallback(git_stash_apply_progress_t progress, void return (stop ? GIT_EUSER : 0); } -- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError **)error progressBlock:(void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock { +- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError * __autoreleasing *)error progressBlock:(void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock { git_stash_apply_options stash_options = GIT_STASH_APPLY_OPTIONS_INIT; stash_options.flags = (git_stash_apply_flags)flags; @@ -81,7 +81,7 @@ - (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)fl return YES; } -- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError **)error progressBlock:(void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock { +- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError * __autoreleasing *)error progressBlock:(void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock { git_stash_apply_options stash_options = GIT_STASH_APPLY_OPTIONS_INIT; stash_options.flags = (git_stash_apply_flags)flags; @@ -103,7 +103,7 @@ - (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flag return YES; } -- (BOOL)dropStashAtIndex:(NSUInteger)index error:(NSError **)error { +- (BOOL)dropStashAtIndex:(NSUInteger)index error:(NSError * __autoreleasing *)error { int gitError = git_stash_drop(self.git_repository, index); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Stash drop failed" failureReason:@"The stash at index %ld couldn't be dropped", (unsigned long)index]; diff --git a/ObjectiveGit/GTRepository+Status.h b/ObjectiveGit/GTRepository+Status.h index 86d4121ca..1d0d193ab 100644 --- a/ObjectiveGit/GTRepository+Status.h +++ b/ObjectiveGit/GTRepository+Status.h @@ -113,7 +113,7 @@ extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey; /// /// Returns `NO` in case of a failure or `YES` if the enumeration completed /// successfully. -- (BOOL)enumerateFileStatusWithOptions:(NSDictionary * _Nullable)options error:(NSError **)error usingBlock:(void (^ _Nullable)(GTStatusDelta * _Nullable headToIndex, GTStatusDelta * _Nullable indexToWorkingDirectory, BOOL *stop))block; +- (BOOL)enumerateFileStatusWithOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error usingBlock:(void (^ _Nullable)(GTStatusDelta * _Nullable headToIndex, GTStatusDelta * _Nullable indexToWorkingDirectory, BOOL *stop))block; /// Query the status of one file /// @@ -122,7 +122,7 @@ extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey; /// error - If not nil, set to any error that occurs. /// /// Returns the combined GTFileStatusFlags for the file. -- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL * _Nullable)success error:(NSError **)error; +- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// Tests the ignore rules to see if the file should be considered as ignored. /// @@ -131,7 +131,7 @@ extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey; /// error - If not nil, set to any error that occurs. /// /// Returns YES if the file should be ignored; NO otherwise. -- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL * _Nullable)success error:(NSError **)error; +- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// An enum for use with shouldIgnoreFileURL:error: below typedef NS_ENUM(NSInteger, GTFileIgnoreState) { @@ -141,7 +141,7 @@ typedef NS_ENUM(NSInteger, GTFileIgnoreState) { }; /// Convenience wrapper for shouldFileBeIgnored:success:error: -- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error; +- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTRepository+Status.m b/ObjectiveGit/GTRepository+Status.m index 7f2559134..8c145902e 100644 --- a/ObjectiveGit/GTRepository+Status.m +++ b/ObjectiveGit/GTRepository+Status.m @@ -22,7 +22,7 @@ @implementation GTRepository (Status) -- (BOOL)enumerateFileStatusWithOptions:(NSDictionary *)options error:(NSError **)error usingBlock:(void (^)(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop))block { +- (BOOL)enumerateFileStatusWithOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop))block { NSParameterAssert(block != NULL); __block git_status_options gitOptions = GIT_STATUS_OPTIONS_INIT; @@ -93,7 +93,7 @@ - (BOOL)isWorkingDirectoryClean { return clean; } -- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL *)success error:(NSError **)error { +- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL *)success error:(NSError * __autoreleasing *)error { NSParameterAssert(filePath != nil); git_status_t status; @@ -109,7 +109,7 @@ - (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL *)success return (GTFileStatusFlags)status; } -- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSError **)error { +- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSError * __autoreleasing *)error { NSParameterAssert(fileURL != nil); int ignoreState = 0; @@ -125,7 +125,7 @@ - (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSEr return (ignoreState == 1 ? YES : NO); } -- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error { +- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error { BOOL success = NO; BOOL ignore = [self shouldFileBeIgnored:fileURL success:&success error:error]; if (success) { diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index b57430b50..7d8d4a4e4 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -178,7 +178,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurs. /// /// Returns the initialized repository, or nil if an error occurred. -+ (instancetype _Nullable)initializeEmptyRepositoryAtFileURL:(NSURL *)fileURL options:(NSDictionary * _Nullable)options error:(NSError **)error; ++ (instancetype _Nullable)initializeEmptyRepositoryAtFileURL:(NSURL *)fileURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error; /// Convenience class initializer which uses the default options. /// @@ -186,7 +186,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurs. /// /// Returns the initialized repository, or nil if an error occurred. -+ (instancetype _Nullable)repositoryWithURL:(NSURL *)localFileURL error:(NSError **)error; ++ (instancetype _Nullable)repositoryWithURL:(NSURL *)localFileURL error:(NSError * __autoreleasing *)error; /// Convenience initializer which uses the default options. /// @@ -194,7 +194,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurs. /// /// Returns the initialized repository, or nil if an error occurred. -- (instancetype _Nullable)initWithURL:(NSURL *)localFileURL error:(NSError **)error; +- (instancetype _Nullable)initWithURL:(NSURL *)localFileURL error:(NSError * __autoreleasing *)error; /// Convenience initializer to find and open a repository with extended controls. /// @@ -205,7 +205,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurs. /// /// Returns the initialized repository, or nil if an error occurred. -- (instancetype _Nullable)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(NSArray * _Nullable)ceilingDirURLs error:(NSError **)error; +- (instancetype _Nullable)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(NSArray * _Nullable)ceilingDirURLs error:(NSError * __autoreleasing *)error; - (instancetype)init NS_UNAVAILABLE; @@ -239,16 +239,16 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful. -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock; ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock; /// Lookup objects in the repo by oid or sha1 -- (id _Nullable)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError **)error; -- (id _Nullable)lookUpObjectByOID:(GTOID *)oid error:(NSError **)error; -- (id _Nullable)lookUpObjectBySHA:(NSString *)sha objectType:(GTObjectType)type error:(NSError **)error; -- (id _Nullable)lookUpObjectBySHA:(NSString *)sha error:(NSError **)error; +- (id _Nullable)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error; +- (id _Nullable)lookUpObjectByOID:(GTOID *)oid error:(NSError * __autoreleasing *)error; +- (id _Nullable)lookUpObjectBySHA:(NSString *)sha objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error; +- (id _Nullable)lookUpObjectBySHA:(NSString *)sha error:(NSError * __autoreleasing *)error; /// Lookup an object in the repo using a revparse spec -- (id _Nullable)lookUpObjectByRevParse:(NSString *)spec error:(NSError **)error; +- (id _Nullable)lookUpObjectByRevParse:(NSString *)spec error:(NSError * __autoreleasing *)error; /// Finds the branch with the given name and type. /// @@ -262,7 +262,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// /// Returns the matching branch, or nil if no match was found or an error occurs. /// The latter two cases can be distinguished by checking `success`. -- (GTBranch * _Nullable)lookUpBranchWithName:(NSString *)branchName type:(GTBranchType)branchType success:(BOOL * _Nullable)success error:(NSError **)error; +- (GTBranch * _Nullable)lookUpBranchWithName:(NSString *)branchName type:(GTBranchType)branchType success:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// List all references in the repository /// @@ -271,14 +271,14 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// /// returns an array of NSStrings holding the names of the references /// returns nil if an error occurred and fills the error parameter -- (NSArray * _Nullable)referenceNamesWithError:(NSError **)error; +- (NSArray * _Nullable)referenceNamesWithError:(NSError * __autoreleasing *)error; /// Get the HEAD reference. /// /// error - If not NULL, set to any error that occurs. /// /// Returns a GTReference or nil if an error occurs. -- (GTReference * _Nullable)headReferenceWithError:(NSError **)error; +- (GTReference * _Nullable)headReferenceWithError:(NSError * __autoreleasing *)error; /// Move HEAD reference safely, since deleting and recreating HEAD is always wrong. /// @@ -286,7 +286,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns NO if an error occurs. -- (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError **)error; +- (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError * __autoreleasing *)error; /// Move HEAD reference safely, since deleting and recreating HEAD is always wrong. /// @@ -294,21 +294,21 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns NO if an error occurs. -- (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError **)error; +- (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError * __autoreleasing *)error; /// Get the local branches. /// /// error - If not NULL, set to any error that occurs. /// /// Returns an array of GTBranches or nil if an error occurs. -- (NSArray * _Nullable)localBranchesWithError:(NSError **)error; +- (NSArray * _Nullable)localBranchesWithError:(NSError * __autoreleasing *)error; /// Get the remote branches. /// /// error - If not NULL, set to any error that occurs. /// /// Returns an array of GTBranches or nil if an error occurs. -- (NSArray * _Nullable)remoteBranchesWithError:(NSError **)error; +- (NSArray * _Nullable)remoteBranchesWithError:(NSError * __autoreleasing *)error; /// Get branches with names sharing a given prefix. /// @@ -316,7 +316,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns an array of GTBranches or nil if an error occurs. -- (NSArray * _Nullable)branchesWithPrefix:(NSString *)prefix error:(NSError **)error; +- (NSArray * _Nullable)branchesWithPrefix:(NSString *)prefix error:(NSError * __autoreleasing *)error; /// Get the local and remote branches and merge them together by combining local /// branches with their remote branch, if they have one. @@ -324,35 +324,35 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns an array of GTBranches or nil if an error occurs. -- (NSArray * _Nullable)branches:(NSError **)error; +- (NSArray * _Nullable)branches:(NSError * __autoreleasing *)error; /// List all remotes in the repository /// /// error - will be filled if an error occurs /// /// returns an array of NSStrings holding the names of the remotes, or nil if an error occurred -- (NSArray * _Nullable)remoteNamesWithError:(NSError **)error; +- (NSArray * _Nullable)remoteNamesWithError:(NSError * __autoreleasing *)error; /// Delete the given remote by name /// /// error - If not NULL, set to any error that occurs. /// /// returns YES if the deletion succeeded, otherwise NO. -- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError **)error; +- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError * __autoreleasing *)error; /// Get all tags in the repository. /// /// error - If not NULL, set to any error that occurs. /// /// Returns an array of GTTag or nil if an error occurs. -- (NSArray * _Nullable)allTagsWithError:(NSError **)error; +- (NSArray * _Nullable)allTagsWithError:(NSError * __autoreleasing *)error; /// Count all commits in the current branch (HEAD) /// /// error(out) - will be filled if an error occurs /// /// returns number of commits in the current branch or NSNotFound if an error occurred -- (NSUInteger)numberOfCommitsInCurrentBranch:(NSError **)error; +- (NSUInteger)numberOfCommitsInCurrentBranch:(NSError * __autoreleasing *)error; /// Creates a direct reference to the given OID. /// @@ -363,7 +363,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns the created ref, or nil if an error occurred. -- (GTReference * _Nullable)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString * _Nullable)message error:(NSError **)error; +- (GTReference * _Nullable)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString * _Nullable)message error:(NSError * __autoreleasing *)error; /// Creates a symbolic reference to another ref. /// @@ -374,7 +374,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns the created ref, or nil if an error occurred. -- (GTReference * _Nullable)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString * _Nullable)message error:(NSError **)error; +- (GTReference * _Nullable)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString * _Nullable)message error:(NSError * __autoreleasing *)error; /// Create a new local branch pointing to the given OID. /// @@ -386,14 +386,14 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns the new branch, or nil if an error occurred. -- (GTBranch * _Nullable)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString * _Nullable)message error:(NSError **)error; +- (GTBranch * _Nullable)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString * _Nullable)message error:(NSError * __autoreleasing *)error; /// Get the current branch. /// /// error(out) - will be filled if an error occurs /// /// returns the current branch or nil if an error occurred. -- (GTBranch * _Nullable)currentBranchWithError:(NSError **)error; +- (GTBranch * _Nullable)currentBranchWithError:(NSError * __autoreleasing *)error; /// Find the commits that are on our local branch but not on the remote branch. /// @@ -401,7 +401,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error(out) - will be filled if an error occurs /// /// returns the local commits, an empty array if there is no remote branch, or nil if an error occurred -- (NSArray * _Nullable)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError **)error; +- (NSArray * _Nullable)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError * __autoreleasing *)error; /// Retrieves git's "prepared message" for the next commit, like the default /// message pre-filled when committing after a conflicting merge. @@ -410,7 +410,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// /// Returns the message from disk, or nil if no prepared message exists or an /// error occurred. -- (NSString * _Nullable)preparedMessageWithError:(NSError **)error; +- (NSString * _Nullable)preparedMessageWithError:(NSError * __autoreleasing *)error; /// The signature for the user at the current time, based on the repository and /// system configs. If the user's name or email have not been set, reasonable @@ -437,7 +437,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// /// Returns the first submodule that matches the given name, or nil if an error /// occurred locating or instantiating the GTSubmodule. -- (GTSubmodule * _Nullable)submoduleWithName:(NSString *)name error:(NSError **)error; +- (GTSubmodule * _Nullable)submoduleWithName:(NSString *)name error:(NSError * __autoreleasing *)error; /// Finds the merge base between the commits pointed at by the given OIDs. /// @@ -446,28 +446,28 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns the merge base, or nil if none is found or an error occurred. -- (GTCommit * _Nullable)mergeBaseBetweenFirstOID:(GTOID *)firstOID secondOID:(GTOID *)secondOID error:(NSError **)error; +- (GTCommit * _Nullable)mergeBaseBetweenFirstOID:(GTOID *)firstOID secondOID:(GTOID *)secondOID error:(NSError * __autoreleasing *)error; /// The object database backing the repository. /// /// error - The error if one occurred. /// /// Returns the object database, or nil if an error occurred. -- (GTObjectDatabase * _Nullable)objectDatabaseWithError:(NSError **)error; +- (GTObjectDatabase * _Nullable)objectDatabaseWithError:(NSError * __autoreleasing *)error; /// The configuration for the repository. /// /// error - The error if one occurred. /// /// Returns the configuration, or nil if an error occurred. -- (GTConfiguration * _Nullable)configurationWithError:(NSError **)error; +- (GTConfiguration * _Nullable)configurationWithError:(NSError * __autoreleasing *)error; /// The index for the repository. /// /// error - The error if one occurred. /// /// Returns the index, or nil if an error occurred. -- (GTIndex * _Nullable)indexWithError:(NSError **)error; +- (GTIndex * _Nullable)indexWithError:(NSError * __autoreleasing *)error; /// Creates a new lightweight tag in this repository. /// @@ -480,7 +480,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// Returns YES on success or NO otherwise. -- (BOOL)createLightweightTagNamed:(NSString *)tagName target:(GTObject *)target error:(NSError **)error; +- (BOOL)createLightweightTagNamed:(NSString *)tagName target:(GTObject *)target error:(NSError * __autoreleasing *)error; /// Creates an annotated tag in this repo. Existing tags are not overwritten. /// @@ -496,7 +496,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// Returns the object ID of the newly created tag or nil on error. -- (GTOID * _Nullable)OIDByCreatingTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error; +- (GTOID * _Nullable)OIDByCreatingTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError * __autoreleasing *)error; /// Creates an annotated tag in this repo. Existing tags are not overwritten. /// @@ -512,7 +512,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// Returns the newly created tag or nil on error. -- (GTTag * _Nullable)createTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error; +- (GTTag * _Nullable)createTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError * __autoreleasing *)error; /// Checkout a commit /// @@ -521,7 +521,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurred. Can be NULL. /// /// Returns YES if operation was successful, NO otherwise -- (BOOL)checkoutCommit:(GTCommit *)targetCommit options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error; +- (BOOL)checkoutCommit:(GTCommit *)targetCommit options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error; /// Checkout a reference /// @@ -530,7 +530,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurred. Can be NULL. /// /// Returns YES if operation was successful, NO otherwise -- (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error; +- (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error; /// Checkout an index /// @@ -539,7 +539,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurred. Can be NULL. /// /// Returns YES if operation was successful, NO otherwise -- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error; +- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error; /// Checkout a tree /// @@ -549,7 +549,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// /// Returns YES if operation was successful, NO otherwise /// Note: this operation will NOT update HEAD to newly checked out tree. -- (BOOL)checkoutTree:(GTTree *)targetTree options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error; +- (BOOL)checkoutTree:(GTTree *)targetTree options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error; /// Flush the gitattributes cache. - (void)flushAttributesCache; @@ -572,7 +572,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// Returns the loaded filter list, or nil if an error occurs or there are no /// filters to apply to the given path. The latter two cases can be /// distinguished using the value of `success`. -- (GTFilterList * _Nullable)filterListWithPath:(NSString *)path blob:(GTBlob * _Nullable)blob mode:(GTFilterSourceMode)mode options:(GTFilterListOptions)options success:(BOOL * _Nullable)success error:(NSError **)error; +- (GTFilterList * _Nullable)filterListWithPath:(NSString *)path blob:(GTBlob * _Nullable)blob mode:(GTFilterSourceMode)mode options:(GTFilterListOptions)options success:(BOOL * _Nullable)success error:(NSError * __autoreleasing *)error; /// Calculates how far ahead/behind the commit represented by `headOID` is, /// relative to the commit represented by `baseOID`. @@ -584,7 +584,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - If not NULL, set to any error that occurs. /// /// Returns whether `ahead` and `behind` were successfully calculated. -- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind ofOID:(GTOID *)headOID relativeToOID:(GTOID *)baseOID error:(NSError **)error; +- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind ofOID:(GTOID *)headOID relativeToOID:(GTOID *)baseOID error:(NSError * __autoreleasing *)error; /// Creates an enumerator for walking the unique commits, as determined by a /// pushing a starting OID and hiding the relative OID. @@ -594,7 +594,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurred. /// /// Returns the enumerator or nil if an error occurred. -- (GTEnumerator * _Nullable)enumeratorForUniqueCommitsFromOID:(GTOID *)fromOID relativeToOID:(GTOID *)relativeOID error:(NSError **)error; +- (GTEnumerator * _Nullable)enumeratorForUniqueCommitsFromOID:(GTOID *)fromOID relativeToOID:(GTOID *)relativeOID error:(NSError * __autoreleasing *)error; /// Determines the status of a git repository--i.e., whether an operation /// (merge, cherry-pick, etc) is in progress. @@ -603,7 +603,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// error - The error if one occurred. /// /// Returns YES if operation was successful, NO otherwise -- (BOOL)calculateState:(GTRepositoryStateType *)state withError:(NSError **)error; +- (BOOL)calculateState:(GTRepositoryStateType *)state withError:(NSError * __autoreleasing *)error; /// Remove all the metadata associated with an ongoing command like merge, /// revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc. @@ -627,7 +627,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// Returns the newly created note or nil on error. -- (GTNote * _Nullable)createNote:(NSString *)note target:(GTObject *)theTarget referenceName:(NSString * _Nullable)referenceName author:(GTSignature *)author committer:(GTSignature *)committer overwriteIfExists:(BOOL)overwrite error:(NSError **)error; +- (GTNote * _Nullable)createNote:(NSString *)note target:(GTObject *)theTarget referenceName:(NSString * _Nullable)referenceName author:(GTSignature *)author committer:(GTSignature *)committer overwriteIfExists:(BOOL)overwrite error:(NSError * __autoreleasing *)error; /// Removes a note attached to object in this repo /// @@ -641,7 +641,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// Returns the YES on success and NO on error. -- (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(NSString * _Nullable)referenceName author:(GTSignature *)author committer:(GTSignature *)committer error:(NSError **)error; +- (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(NSString * _Nullable)referenceName author:(GTSignature *)author committer:(GTSignature *)committer error:(NSError * __autoreleasing *)error; /// Enumerates through all stored notes in this repo /// @@ -653,7 +653,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// If the block sets `stop` to YES, the iterator is finished. /// /// Returns YES on overall success or NO on error of any kind. -- (BOOL)enumerateNotesWithReferenceName:(NSString * _Nullable)referenceName error:(NSError **)error usingBlock:(void (^)(GTNote * _Nullable note, GTObject * _Nullable object, NSError * _Nullable error, BOOL *stop))block; +- (BOOL)enumerateNotesWithReferenceName:(NSString * _Nullable)referenceName error:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTNote * _Nullable note, GTObject * _Nullable object, NSError * _Nullable error, BOOL *stop))block; @end diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index 133216cd4..348602b09 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -116,7 +116,7 @@ - (void)dealloc { #pragma mark API -+ (instancetype)initializeEmptyRepositoryAtFileURL:(NSURL *)localFileURL options:(NSDictionary *)optionsDict error:(NSError **)error { ++ (instancetype)initializeEmptyRepositoryAtFileURL:(NSURL *)localFileURL options:(NSDictionary *)optionsDict error:(NSError * __autoreleasing *)error { if (!localFileURL.isFileURL || localFileURL.path == nil) { if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to initialize repository.", @"") }]; return nil; @@ -146,7 +146,7 @@ + (instancetype)initializeEmptyRepositoryAtFileURL:(NSURL *)localFileURL options return [[self alloc] initWithGitRepository:repository]; } -+ (instancetype)repositoryWithURL:(NSURL *)localFileURL error:(NSError **)error { ++ (instancetype)repositoryWithURL:(NSURL *)localFileURL error:(NSError * __autoreleasing *)error { return [[self alloc] initWithURL:localFileURL error:error]; } @@ -166,7 +166,7 @@ - (instancetype)initWithGitRepository:(git_repository *)repository { return self; } -- (instancetype)initWithURL:(NSURL *)localFileURL error:(NSError **)error { +- (instancetype)initWithURL:(NSURL *)localFileURL error:(NSError * __autoreleasing *)error { if (![localFileURL isFileURL] || localFileURL.path == nil) { if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to open.", @"") }]; return nil; @@ -182,7 +182,7 @@ - (instancetype)initWithURL:(NSURL *)localFileURL error:(NSError **)error { return [self initWithGitRepository:r]; } -- (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(NSArray *)ceilingDirURLs error:(NSError **)error { +- (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(NSArray *)ceilingDirURLs error:(NSError * __autoreleasing *)error { if (!localFileURL.isFileURL || localFileURL.path == nil) { if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to open.", @"") }]; return nil; @@ -244,7 +244,7 @@ static int remoteCreate(git_remote **remote, git_repository *repo, const char *n git_remote_callbacks remoteCallbacks; }; -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock { ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock { git_clone_options cloneOptions = GIT_CLONE_OPTIONS_INIT; @@ -314,7 +314,7 @@ + (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NS return [[self alloc] initWithGitRepository:repository]; } -- (id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError **)error { +- (id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error { git_object *obj; int gitError = git_object_lookup(&obj, self.git_repository, oid, (git_object_t)type); @@ -330,30 +330,30 @@ - (id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type er return [GTObject objectWithObj:obj inRepository:self]; } -- (id)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError **)error { +- (id)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError * __autoreleasing *)error { return [self lookUpObjectByGitOid:oid objectType:GTObjectTypeAny error:error]; } -- (id)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError **)error { +- (id)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error { return [self lookUpObjectByGitOid:oid.git_oid objectType:type error:error]; } -- (id)lookUpObjectByOID:(GTOID *)oid error:(NSError **)error { +- (id)lookUpObjectByOID:(GTOID *)oid error:(NSError * __autoreleasing *)error { return [self lookUpObjectByOID:oid objectType:GTObjectTypeAny error:error]; } -- (id)lookUpObjectBySHA:(NSString *)sha objectType:(GTObjectType)type error:(NSError **)error { +- (id)lookUpObjectBySHA:(NSString *)sha objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error { GTOID *oid = [[GTOID alloc] initWithSHA:sha error:error]; if (!oid) return nil; return [self lookUpObjectByOID:oid objectType:type error:error]; } -- (id)lookUpObjectBySHA:(NSString *)sha error:(NSError **)error { +- (id)lookUpObjectBySHA:(NSString *)sha error:(NSError * __autoreleasing *)error { return [self lookUpObjectBySHA:sha objectType:GTObjectTypeAny error:error]; } -- (id)lookUpObjectByRevParse:(NSString *)spec error:(NSError **)error { +- (id)lookUpObjectByRevParse:(NSString *)spec error:(NSError * __autoreleasing *)error { git_object *obj; int gitError = git_revparse_single(&obj, self.git_repository, spec.UTF8String); if (gitError < GIT_OK) { @@ -363,7 +363,7 @@ - (id)lookUpObjectByRevParse:(NSString *)spec error:(NSError **)error { return [GTObject objectWithObj:obj inRepository:self]; } -- (GTBranch *)lookUpBranchWithName:(NSString *)branchName type:(GTBranchType)branchType success:(BOOL *)success error:(NSError **)error { +- (GTBranch *)lookUpBranchWithName:(NSString *)branchName type:(GTBranchType)branchType success:(BOOL *)success error:(NSError * __autoreleasing *)error { NSParameterAssert(branchName != nil); git_reference *ref = NULL; @@ -382,7 +382,7 @@ - (GTBranch *)lookUpBranchWithName:(NSString *)branchName type:(GTBranchType)bra return [[GTBranch alloc] initWithReference:gtRef]; } -- (GTReference *)headReferenceWithError:(NSError **)error { +- (GTReference *)headReferenceWithError:(NSError * __autoreleasing *)error { git_reference *headRef; int gitError = git_repository_head(&headRef, self.git_repository); if (gitError != GIT_OK) { @@ -399,7 +399,7 @@ - (GTReference *)headReferenceWithError:(NSError **)error { typedef void (^GTRepositoryBranchEnumerationBlock)(GTBranch *branch, BOOL *stop); -- (BOOL)enumerateBranchesWithType:(GTBranchType)type error:(NSError **)error usingBlock:(GTRepositoryBranchEnumerationBlock)block { +- (BOOL)enumerateBranchesWithType:(GTBranchType)type error:(NSError * __autoreleasing *)error usingBlock:(GTRepositoryBranchEnumerationBlock)block { git_branch_iterator *iter = NULL; git_reference *gitRef = NULL; int gitError = git_branch_iterator_new(&iter, self.git_repository, (git_branch_t)type); @@ -429,7 +429,7 @@ - (BOOL)enumerateBranchesWithType:(GTBranchType)type error:(NSError **)error usi return YES; } -- (NSArray *)localBranchesWithError:(NSError **)error { +- (NSArray *)localBranchesWithError:(NSError * __autoreleasing *)error { NSMutableArray *localBranches = [NSMutableArray array]; BOOL success = [self enumerateBranchesWithType:GTBranchTypeLocal error:error usingBlock:^(GTBranch *branch, BOOL *stop) { [localBranches addObject:branch]; @@ -440,7 +440,7 @@ - (NSArray *)localBranchesWithError:(NSError **)error { return [localBranches copy]; } -- (NSArray *)remoteBranchesWithError:(NSError **)error { +- (NSArray *)remoteBranchesWithError:(NSError * __autoreleasing *)error { NSMutableArray *remoteBranches = [NSMutableArray array]; BOOL success = [self enumerateBranchesWithType:GTBranchTypeRemote error:error usingBlock:^(GTBranch *branch, BOOL *stop) { if (![branch.shortName isEqualToString:@"HEAD"]) @@ -452,7 +452,7 @@ - (NSArray *)remoteBranchesWithError:(NSError **)error { return [remoteBranches copy]; } -- (NSArray *)branchesWithPrefix:(NSString *)prefix error:(NSError **)error { +- (NSArray *)branchesWithPrefix:(NSString *)prefix error:(NSError * __autoreleasing *)error { NSArray *references = [self referenceNamesWithError:error]; if (references == nil) return nil; @@ -472,7 +472,7 @@ - (NSArray *)branchesWithPrefix:(NSString *)prefix error:(NSError **)error { return branches; } -- (NSArray *)branches:(NSError **)error { +- (NSArray *)branches:(NSError * __autoreleasing *)error { NSArray *localBranches = [self localBranchesWithError:error]; if (localBranches == nil) return nil; @@ -491,7 +491,7 @@ - (NSArray *)branches:(NSError **)error { return branches; } -- (NSArray *)remoteNamesWithError:(NSError **)error { +- (NSArray *)remoteNamesWithError:(NSError * __autoreleasing *)error { git_strarray array; int gitError = git_remote_list(&array, self.git_repository); if (gitError < GIT_OK) { @@ -506,7 +506,7 @@ - (NSArray *)remoteNamesWithError:(NSError **)error { return remoteNames; } -- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError **)error { +- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError * __autoreleasing *)error { int gitError = git_remote_delete(self.git_repository, [remoteName cStringUsingEncoding:NSUTF8StringEncoding]); if (gitError < GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to delete remote."]; @@ -533,7 +533,7 @@ static int GTRepositoryForeachTagCallback(const char *name, git_oid *oid, void * return stop ? GIT_EUSER : 0; } -- (BOOL)enumerateTags:(NSError **)error block:(GTRepositoryTagEnumerationBlock)block { +- (BOOL)enumerateTags:(NSError * __autoreleasing *)error block:(GTRepositoryTagEnumerationBlock)block { NSParameterAssert(block != nil); struct GTRepositoryTagEnumerationInfo payload = { @@ -549,7 +549,7 @@ - (BOOL)enumerateTags:(NSError **)error block:(GTRepositoryTagEnumerationBlock)b return YES; } -- (NSArray *)allTagsWithError:(NSError **)error { +- (NSArray *)allTagsWithError:(NSError * __autoreleasing *)error { NSMutableArray *tagArray = [NSMutableArray array]; BOOL success = [self enumerateTags:error block:^(GTTag *tag, BOOL *stop) { [tagArray addObject:tag]; @@ -557,14 +557,14 @@ - (NSArray *)allTagsWithError:(NSError **)error { return success == YES ? tagArray : nil; } -- (NSUInteger)numberOfCommitsInCurrentBranch:(NSError **)error { +- (NSUInteger)numberOfCommitsInCurrentBranch:(NSError * __autoreleasing *)error { GTBranch *currentBranch = [self currentBranchWithError:error]; if (currentBranch == nil) return NSNotFound; return [currentBranch numberOfCommitsWithError:error]; } -- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error { +- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); NSParameterAssert(targetOID != nil); @@ -578,7 +578,7 @@ - (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOI return [[GTReference alloc] initWithGitReference:ref repository:self]; } -- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString *)message error:(NSError **)error { +- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString *)message error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); NSParameterAssert(targetRef != nil); NSParameterAssert(targetRef.name != nil); @@ -593,7 +593,7 @@ - (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReferenc return [[GTReference alloc] initWithGitReference:ref repository:self]; } -- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error { +- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); NSParameterAssert(targetOID != nil); @@ -607,21 +607,21 @@ - (BOOL)isEmpty { return (BOOL) git_repository_is_empty(self.git_repository); } -- (GTBranch *)currentBranchWithError:(NSError **)error { +- (GTBranch *)currentBranchWithError:(NSError * __autoreleasing *)error { GTReference *head = [self headReferenceWithError:error]; if (head == nil) return nil; return [GTBranch branchWithReference:head]; } -- (NSArray *)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError **)error { +- (NSArray *)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError * __autoreleasing *)error { GTBranch *localBranch = [self currentBranchWithError:error]; if (localBranch == nil) return nil; return [localBranch uniqueCommitsRelativeToBranch:remoteBranch error:error]; } -- (NSArray *)referenceNamesWithError:(NSError **)error { +- (NSArray *)referenceNamesWithError:(NSError * __autoreleasing *)error { git_strarray array; int gitError = git_reference_list(&array, self.git_repository); if (gitError < GIT_OK) { @@ -694,7 +694,7 @@ - (NSString *)preparedMessageWithError:(NSError * __autoreleasing *)error { return message; } -- (GTCommit *)mergeBaseBetweenFirstOID:(GTOID *)firstOID secondOID:(GTOID *)secondOID error:(NSError **)error { +- (GTCommit *)mergeBaseBetweenFirstOID:(GTOID *)firstOID secondOID:(GTOID *)secondOID error:(NSError * __autoreleasing *)error { NSParameterAssert(firstOID != nil); NSParameterAssert(secondOID != nil); @@ -708,11 +708,11 @@ - (GTCommit *)mergeBaseBetweenFirstOID:(GTOID *)firstOID secondOID:(GTOID *)seco return [self lookUpObjectByGitOid:&mergeBase objectType:GTObjectTypeCommit error:error]; } -- (GTObjectDatabase *)objectDatabaseWithError:(NSError **)error { +- (GTObjectDatabase *)objectDatabaseWithError:(NSError * __autoreleasing *)error { return [[GTObjectDatabase alloc] initWithRepository:self error:error]; } -- (GTConfiguration *)configurationWithError:(NSError **)error { +- (GTConfiguration *)configurationWithError:(NSError * __autoreleasing *)error { git_config *config = NULL; int gitError = git_repository_config(&config, self.git_repository); if (gitError != GIT_OK) { @@ -723,7 +723,7 @@ - (GTConfiguration *)configurationWithError:(NSError **)error { return [[GTConfiguration alloc] initWithGitConfig:config repository:self]; } -- (GTIndex *)indexWithError:(NSError **)error { +- (GTIndex *)indexWithError:(NSError * __autoreleasing *)error { git_index *index = NULL; int gitError = git_repository_index(&index, self.git_repository); if (gitError != GIT_OK) { @@ -770,7 +770,7 @@ - (void)enumerateSubmodulesRecursively:(BOOL)recursive usingBlock:(void (^)(GTSu git_submodule_foreach(self.git_repository, &submoduleEnumerationCallback, &info); } -- (GTSubmodule *)submoduleWithName:(NSString *)name error:(NSError **)error { +- (GTSubmodule *)submoduleWithName:(NSString *)name error:(NSError * __autoreleasing *)error { NSParameterAssert(name != nil); git_submodule *submodule; @@ -816,7 +816,7 @@ - (GTSignature *)userSignatureForNow { #pragma mark Tagging -- (BOOL)createLightweightTagNamed:(NSString *)tagName target:(GTObject *)target error:(NSError **)error { +- (BOOL)createLightweightTagNamed:(NSString *)tagName target:(GTObject *)target error:(NSError * __autoreleasing *)error { NSParameterAssert(tagName != nil); NSParameterAssert(target != nil); @@ -830,7 +830,7 @@ - (BOOL)createLightweightTagNamed:(NSString *)tagName target:(GTObject *)target return YES; } -- (GTOID *)OIDByCreatingTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error { +- (GTOID *)OIDByCreatingTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError * __autoreleasing *)error { git_oid oid; int gitError = git_tag_create(&oid, self.git_repository, [tagName UTF8String], theTarget.git_object, theTagger.git_signature, [theMessage UTF8String], 0); if (gitError != GIT_OK) { @@ -841,14 +841,14 @@ - (GTOID *)OIDByCreatingTagNamed:(NSString *)tagName target:(GTObject *)theTarge return [GTOID oidWithGitOid:&oid]; } -- (GTTag *)createTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error { +- (GTTag *)createTagNamed:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError * __autoreleasing *)error { GTOID *oid = [self OIDByCreatingTagNamed:tagName target:theTarget tagger:theTagger message:theMessage error:error]; return oid ? [self lookUpObjectByOID:oid objectType:GTObjectTypeTag error:error] : nil; } #pragma mark Checkout -- (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError **)error { +- (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError * __autoreleasing *)error { NSParameterAssert(reference != nil); int gitError = git_repository_set_head(self.git_repository, reference.name.UTF8String); @@ -859,7 +859,7 @@ - (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError **)error { return gitError == GIT_OK; } -- (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError **)error { +- (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError * __autoreleasing *)error { NSParameterAssert(commit != nil); int gitError = git_repository_set_head_detached(self.git_repository, commit.OID.git_oid); @@ -870,7 +870,7 @@ - (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError **)error { return gitError == GIT_OK; } -- (BOOL)performCheckout:(GTObject *)target options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error { +- (BOOL)performCheckout:(GTObject *)target options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error { int gitError = git_checkout_tree(self.git_repository, target.git_object, options.git_checkoutOptions); if (gitError < GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to checkout tree."]; @@ -878,13 +878,13 @@ - (BOOL)performCheckout:(GTObject *)target options:(GTCheckoutOptions * _Nullabl return gitError == GIT_OK; } -- (BOOL)checkoutCommit:(GTCommit *)targetCommit options:(GTCheckoutOptions *)options error:(NSError **)error { +- (BOOL)checkoutCommit:(GTCommit *)targetCommit options:(GTCheckoutOptions *)options error:(NSError * __autoreleasing *)error { BOOL success = [self performCheckout:targetCommit options:options error:error]; if (success == NO) return NO; return [self moveHEADToCommit:targetCommit error:error]; } -- (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOptions *)options error:(NSError **)error { +- (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOptions *)options error:(NSError * __autoreleasing *)error { GTOID *targetOID = [targetReference targetOID]; GTObject *target = [self lookUpObjectByOID:targetOID error:error]; if (target == nil) return NO; @@ -893,11 +893,11 @@ - (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOpti return [self moveHEADToReference:targetReference error:error]; } -- (BOOL)checkoutTree:(GTTree *)targetTree options:(GTCheckoutOptions * _Nullable)options error:(NSError **)error { +- (BOOL)checkoutTree:(GTTree *)targetTree options:(GTCheckoutOptions * _Nullable)options error:(NSError * __autoreleasing *)error { return [self performCheckout:targetTree options:options error:error]; } -- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions *)options error:(NSError **)error { +- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions *)options error:(NSError * __autoreleasing *)error { int gitError = git_checkout_index(self.git_repository, index.git_index, options.git_checkoutOptions); if (gitError < GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to checkout index."]; @@ -910,7 +910,7 @@ - (void)flushAttributesCache { git_attr_cache_flush(self.git_repository); } -- (GTFilterList *)filterListWithPath:(NSString *)path blob:(GTBlob *)blob mode:(GTFilterSourceMode)mode options:(GTFilterListOptions)options success:(BOOL *)success error:(NSError **)error { +- (GTFilterList *)filterListWithPath:(NSString *)path blob:(GTBlob *)blob mode:(GTFilterSourceMode)mode options:(GTFilterListOptions)options success:(BOOL *)success error:(NSError * __autoreleasing *)error { NSParameterAssert(path != nil); git_filter_list *list = NULL; @@ -930,7 +930,7 @@ - (GTFilterList *)filterListWithPath:(NSString *)path blob:(GTBlob *)blob mode:( } } -- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind ofOID:(GTOID *)headOID relativeToOID:(GTOID *)baseOID error:(NSError **)error { +- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind ofOID:(GTOID *)headOID relativeToOID:(GTOID *)baseOID error:(NSError * __autoreleasing *)error { NSParameterAssert(headOID != nil); NSParameterAssert(baseOID != nil); @@ -944,7 +944,7 @@ - (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind ofOID:(GTOID *)he return YES; } -- (GTEnumerator *)enumeratorForUniqueCommitsFromOID:(GTOID *)fromOID relativeToOID:(GTOID *)relativeOID error:(NSError **)error { +- (GTEnumerator *)enumeratorForUniqueCommitsFromOID:(GTOID *)fromOID relativeToOID:(GTOID *)relativeOID error:(NSError * __autoreleasing *)error { NSParameterAssert(fromOID != nil); NSParameterAssert(relativeOID != nil); @@ -960,7 +960,7 @@ - (GTEnumerator *)enumeratorForUniqueCommitsFromOID:(GTOID *)fromOID relativeToO return enumerator; } -- (BOOL)calculateState:(GTRepositoryStateType *)state withError:(NSError **)error { +- (BOOL)calculateState:(GTRepositoryStateType *)state withError:(NSError * __autoreleasing *)error { NSParameterAssert(state != NULL); int result = git_repository_state(self.git_repository); @@ -973,7 +973,7 @@ - (BOOL)calculateState:(GTRepositoryStateType *)state withError:(NSError **)erro return YES; } -- (BOOL)cleanupStateWithError:(NSError **)error { +- (BOOL)cleanupStateWithError:(NSError * __autoreleasing *)error { int errorCode = git_repository_state_cleanup(self.git_repository); if (errorCode != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:errorCode description:@"Failed to clean up repository state"]; @@ -983,7 +983,7 @@ - (BOOL)cleanupStateWithError:(NSError **)error { #pragma mark Notes -- (GTNote *)createNote:(NSString *)note target:(GTObject *)theTarget referenceName:(NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer overwriteIfExists:(BOOL)overwrite error:(NSError **)error { +- (GTNote *)createNote:(NSString *)note target:(GTObject *)theTarget referenceName:(NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer overwriteIfExists:(BOOL)overwrite error:(NSError * __autoreleasing *)error { git_oid oid; int gitError = git_note_create(&oid, self.git_repository, referenceName.UTF8String, author.git_signature, committer.git_signature, theTarget.OID.git_oid, [note UTF8String], overwrite ? 1 : 0); @@ -996,7 +996,7 @@ - (GTNote *)createNote:(NSString *)note target:(GTObject *)theTarget referenceNa return [[GTNote alloc] initWithTargetOID:theTarget.OID repository:self referenceName:referenceName error:error]; } -- (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer error:(NSError **)error { +- (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer error:(NSError * __autoreleasing *)error { int gitError = git_note_remove(self.git_repository, referenceName.UTF8String, author.git_signature, committer.git_signature, parentObject.OID.git_oid); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to delete note from %@", parentObject]; @@ -1006,7 +1006,7 @@ - (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(NSString *) return YES; } -- (BOOL)enumerateNotesWithReferenceName:(NSString *)referenceName error:(NSError **)error usingBlock:(void (^)(GTNote *note, GTObject *object, NSError *error, BOOL *stop))block { +- (BOOL)enumerateNotesWithReferenceName:(NSString *)referenceName error:(NSError * __autoreleasing *)error usingBlock:(void (^)(GTNote *note, GTObject *object, NSError *error, BOOL *stop))block { git_note_iterator *iter = NULL; int gitError = git_note_iterator_new(&iter, self.git_repository, referenceName.UTF8String); diff --git a/ObjectiveGit/GTSubmodule.h b/ObjectiveGit/GTSubmodule.h index 1e55fe16f..fa683825a 100644 --- a/ObjectiveGit/GTSubmodule.h +++ b/ObjectiveGit/GTSubmodule.h @@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN /// This will mutate properties on the receiver. /// /// Returns whether reloading succeeded. -- (BOOL)reload:(NSError **)error; +- (BOOL)reload:(NSError * __autoreleasing *)error; /// Write a new ignore rule to disk and get the resulting submodule. The /// receiver will not have the new ignore rule. To update the receiver, call @@ -119,23 +119,23 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the updated submodule or nil if an error occurred. -- (GTSubmodule * _Nullable)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error; +- (GTSubmodule * _Nullable)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError * __autoreleasing *)error; /// Synchronizes the submodule repository's configuration files with the settings /// from the parent repository. /// /// Returns whether the synchronization succeeded. -- (BOOL)sync:(NSError **)error; +- (BOOL)sync:(NSError * __autoreleasing *)error; /// Opens the submodule repository. /// /// If the submodule is not currently checked out, this will fail. /// /// Returns the opened repository, or nil if an error occurs. -- (GTRepository * _Nullable)submoduleRepository:(NSError **)error; +- (GTRepository * _Nullable)submoduleRepository:(NSError * __autoreleasing *)error; /// Calls `-statusWithIgnoreRule:error:` with the submodule's ignore rule. -- (GTSubmoduleStatus)status:(NSError **)error; +- (GTSubmoduleStatus)status:(NSError * __autoreleasing *)error; /// Determine the status for the submodule using the given ignore rule. /// @@ -143,7 +143,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the status or `GTSubmoduleStatusUnknown` if an error occurred. -- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error; +- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError * __autoreleasing *)error; /// Initializes the submodule by copying its information into the parent /// repository's `.git/config` file. This is equivalent to `git submodule init` @@ -154,7 +154,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - If not NULL, set to any error that occurs. /// /// Returns whether the initialization succeeded. -- (BOOL)writeToParentConfigurationDestructively:(BOOL)overwrite error:(NSError **)error; +- (BOOL)writeToParentConfigurationDestructively:(BOOL)overwrite error:(NSError * __autoreleasing *)error; /// Add the current HEAD to the parent repository's index. /// @@ -163,7 +163,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns whether the add was successful. -- (BOOL)addToIndex:(NSError **)error; +- (BOOL)addToIndex:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTSubmodule.m b/ObjectiveGit/GTSubmodule.m index 5d61b20c2..65a60a67c 100644 --- a/ObjectiveGit/GTSubmodule.m +++ b/ObjectiveGit/GTSubmodule.m @@ -25,7 +25,7 @@ - (GTSubmoduleIgnoreRule)ignoreRule { return (GTSubmoduleIgnoreRule)git_submodule_ignore(self.git_submodule); } -- (GTSubmodule *)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error { +- (GTSubmodule *)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError * __autoreleasing *)error { int result = git_submodule_set_ignore(self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule); if (result != GIT_OK) { if (error != NULL) { @@ -116,7 +116,7 @@ - (instancetype)initWithGitSubmodule:(git_submodule *)submodule parentRepository #pragma mark Inspection -- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error { +- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError * __autoreleasing *)error { unsigned status; int gitError = git_submodule_status(&status, self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule); if (gitError != GIT_OK) { @@ -127,13 +127,13 @@ - (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule erro return status; } -- (GTSubmoduleStatus)status:(NSError **)error { +- (GTSubmoduleStatus)status:(NSError * __autoreleasing *)error { return [self statusWithIgnoreRule:self.ignoreRule error:error]; } #pragma mark Manipulation -- (BOOL)reload:(NSError **)error { +- (BOOL)reload:(NSError * __autoreleasing *)error { int gitError = git_submodule_reload(self.git_submodule, 0); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to reload submodule %@.", self.name]; @@ -143,7 +143,7 @@ - (BOOL)reload:(NSError **)error { return YES; } -- (BOOL)sync:(NSError **)error { +- (BOOL)sync:(NSError * __autoreleasing *)error { int gitError = git_submodule_sync(self.git_submodule); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to synchronize submodule %@.", self.name]; @@ -153,7 +153,7 @@ - (BOOL)sync:(NSError **)error { return YES; } -- (GTRepository *)submoduleRepository:(NSError **)error { +- (GTRepository *)submoduleRepository:(NSError * __autoreleasing *)error { git_repository *repo; int gitError = git_submodule_open(&repo, self.git_submodule); if (gitError != GIT_OK) { @@ -164,7 +164,7 @@ - (GTRepository *)submoduleRepository:(NSError **)error { return [[GTRepository alloc] initWithGitRepository:repo]; } -- (BOOL)writeToParentConfigurationDestructively:(BOOL)overwrite error:(NSError **)error { +- (BOOL)writeToParentConfigurationDestructively:(BOOL)overwrite error:(NSError * __autoreleasing *)error { int gitError = git_submodule_init(self.git_submodule, (overwrite ? 1 : 0)); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to initialize submodule %@.", self.name]; @@ -174,7 +174,7 @@ - (BOOL)writeToParentConfigurationDestructively:(BOOL)overwrite error:(NSError * return YES; } -- (BOOL)addToIndex:(NSError **)error { +- (BOOL)addToIndex:(NSError * __autoreleasing *)error { int gitError = git_submodule_add_to_index(self.git_submodule, 0); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to add submodule %@ to its parent's index.", self.name]; diff --git a/ObjectiveGit/GTTag.h b/ObjectiveGit/GTTag.h index bd7318e64..3d06e4ccb 100644 --- a/ObjectiveGit/GTTag.h +++ b/ObjectiveGit/GTTag.h @@ -57,10 +57,10 @@ NS_ASSUME_NONNULL_BEGIN /// May be NULL. /// /// Returns the found object or nil on error. -- (id _Nullable)objectByPeelingTagError:(NSError **)error; +- (id _Nullable)objectByPeelingTagError:(NSError * __autoreleasing *)error; /// Delete the receiver. -- (BOOL)delete:(NSError **)error; +- (BOOL)delete:(NSError * __autoreleasing *)error; /// The underlying `git_object` as a `git_tag` object. - (git_tag *)git_tag __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTTag.m b/ObjectiveGit/GTTag.m index e2cd31a94..690f15d1c 100644 --- a/ObjectiveGit/GTTag.m +++ b/ObjectiveGit/GTTag.m @@ -77,7 +77,7 @@ - (git_tag *)git_tag { return (git_tag *) self.git_object; } -- (id)objectByPeelingTagError:(NSError **)error { +- (id)objectByPeelingTagError:(NSError * __autoreleasing *)error { git_object *target = nil; int gitError = git_tag_peel(&target, self.git_tag); if (gitError != GIT_OK) { @@ -88,7 +88,7 @@ - (id)objectByPeelingTagError:(NSError **)error { return [[GTObject alloc] initWithObj:target inRepository:self.repository]; } -- (BOOL)delete:(NSError **)error { +- (BOOL)delete:(NSError * __autoreleasing *)error { int gitError = git_tag_delete(self.repository.git_repository, self.name.UTF8String); if (gitError != GIT_OK) { if (error) *error = [NSError git_errorFor:gitError description:@"Tag deletion failed"]; diff --git a/ObjectiveGit/GTTree.h b/ObjectiveGit/GTTree.h index 80ceb507f..7c348212a 100644 --- a/ObjectiveGit/GTTree.h +++ b/ObjectiveGit/GTTree.h @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN /// path - the path of the entry relative to the repository root /// /// returns a GTTreeEntry or nil if there is nothing with the specified path -- (GTTreeEntry * _Nullable)entryWithPath:(NSString *)path error:(NSError **)error; +- (GTTreeEntry * _Nullable)entryWithPath:(NSString *)path error:(NSError * __autoreleasing *)error; /// Enumerates the contents of the tree /// @@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN /// Returning `YES` or `NO` only matters when in pre-order mode. /// /// Returns `YES` if the enumeration completed successfully, `NO` otherwise. -- (BOOL)enumerateEntriesWithOptions:(GTTreeEnumerationOptions)options error:(NSError **)error block:(BOOL (^)(GTTreeEntry *entry, NSString *root, BOOL *stop))block; +- (BOOL)enumerateEntriesWithOptions:(GTTreeEnumerationOptions)options error:(NSError * __autoreleasing *)error block:(BOOL (^)(GTTreeEntry *entry, NSString *root, BOOL *stop))block; /// Merges the given tree into the receiver in memory and produces the result as /// an index. @@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN /// /// Returns an index which represents the result of the merge, or nil if an error /// occurred. -- (GTIndex * _Nullable)merge:(GTTree *)otherTree ancestor:(GTTree * _Nullable)ancestorTree error:(NSError **)error; +- (GTIndex * _Nullable)merge:(GTTree *)otherTree ancestor:(GTTree * _Nullable)ancestorTree error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTTree.m b/ObjectiveGit/GTTree.m index 97b7aa6c3..f1a5e7916 100644 --- a/ObjectiveGit/GTTree.m +++ b/ObjectiveGit/GTTree.m @@ -56,7 +56,7 @@ - (NSUInteger)entryCount { return (NSUInteger)git_tree_entrycount(self.git_tree); } -- (GTTreeEntry *)createEntryWithEntry:(const git_tree_entry *)entry error:(NSError **)error { +- (GTTreeEntry *)createEntryWithEntry:(const git_tree_entry *)entry error:(NSError * __autoreleasing *)error { return (entry != NULL ? [GTTreeEntry entryWithEntry:entry parentTree:self error:nil] : nil); } @@ -68,7 +68,7 @@ - (GTTreeEntry *)entryWithName:(NSString *)name { return [self createEntryWithEntry:git_tree_entry_byname(self.git_tree, name.UTF8String) error:nil]; } -- (GTTreeEntry *)entryWithPath:(NSString *)path error:(NSError **)error { +- (GTTreeEntry *)entryWithPath:(NSString *)path error:(NSError * __autoreleasing *)error { git_tree_entry *internalEntry = NULL; int gitError = git_tree_entry_bypath(&internalEntry, self.git_tree, path.UTF8String); if (gitError != GIT_OK) { @@ -111,7 +111,7 @@ static int treewalk_cb(const char *root, const git_tree_entry *git_entry, void * } } -- (BOOL)enumerateEntriesWithOptions:(GTTreeEnumerationOptions)option error:(NSError **)error block:(GTTreeEnumerationBlock)block { +- (BOOL)enumerateEntriesWithOptions:(GTTreeEnumerationOptions)option error:(NSError * __autoreleasing *)error block:(GTTreeEnumerationBlock)block { NSParameterAssert(block != nil); NSMutableDictionary *structure = [[NSMutableDictionary alloc] initWithCapacity:self.entryCount]; @@ -145,7 +145,7 @@ - (NSArray *)entries { #pragma mark Merging -- (GTIndex *)merge:(GTTree *)otherTree ancestor:(GTTree *)ancestorTree error:(NSError **)error { +- (GTIndex *)merge:(GTTree *)otherTree ancestor:(GTTree *)ancestorTree error:(NSError * __autoreleasing *)error { NSParameterAssert(otherTree != nil); git_index *index; diff --git a/ObjectiveGit/GTTreeBuilder.h b/ObjectiveGit/GTTreeBuilder.h index cfa5f8842..ca1f02a47 100644 --- a/ObjectiveGit/GTTreeBuilder.h +++ b/ObjectiveGit/GTTreeBuilder.h @@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the initialized object, or nil if an error occurred. -- (instancetype _Nullable)initWithTree:(GTTree * _Nullable)treeOrNil repository:(GTRepository *)repository error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (instancetype _Nullable)initWithTree:(GTTree * _Nullable)treeOrNil repository:(GTRepository *)repository error:(NSError * __autoreleasing *)error NS_DESIGNATED_INITIALIZER; /// The underlying `git_treebuilder` object. - (git_treebuilder *)git_treebuilder __attribute__((objc_returns_inner_pointer)); @@ -94,7 +94,7 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns the added entry, or nil if an error occurred -- (GTTreeEntry * _Nullable)addEntryWithData:(NSData *)data fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError **)error; +- (GTTreeEntry * _Nullable)addEntryWithData:(NSData *)data fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError * __autoreleasing *)error; /// Add or update an entry to the builder. /// @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN /// the type of the pointed at object. /// /// Returns the added entry, or nil if an error occurred. -- (GTTreeEntry * _Nullable)addEntryWithOID:(GTOID *)oid fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError **)error; +- (GTTreeEntry * _Nullable)addEntryWithOID:(GTOID *)oid fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError * __autoreleasing *)error; /// Remove an entry from the builder by its file name. /// @@ -119,14 +119,14 @@ NS_ASSUME_NONNULL_BEGIN /// error - The error if one occurred. /// /// Returns YES if the entry was removed, or NO if an error occurred. -- (BOOL)removeEntryWithFileName:(NSString *)fileName error:(NSError **)error; +- (BOOL)removeEntryWithFileName:(NSString *)fileName error:(NSError * __autoreleasing *)error; /// Write the contents of the tree builder as a tree object. /// /// error - The error if one occurred. /// /// Returns the written tree, or nil if an error occurred. -- (GTTree * _Nullable)writeTree:(NSError **)error; +- (GTTree * _Nullable)writeTree:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTTreeBuilder.m b/ObjectiveGit/GTTreeBuilder.m index d53118e9d..3e8530ab9 100644 --- a/ObjectiveGit/GTTreeBuilder.m +++ b/ObjectiveGit/GTTreeBuilder.m @@ -60,7 +60,7 @@ - (instancetype)init { return nil; } -- (instancetype)initWithTree:(GTTree *)treeOrNil repository:(GTRepository *)repository error:(NSError **)error { +- (instancetype)initWithTree:(GTTree *)treeOrNil repository:(GTRepository *)repository error:(NSError * __autoreleasing *)error { NSParameterAssert(repository != nil); self = [super init]; @@ -109,7 +109,7 @@ - (GTTreeEntry *)entryWithFileName:(NSString *)fileName { return [GTTreeEntry entryWithEntry:entry parentTree:nil error:nil]; } -- (GTTreeEntry *)addEntryWithData:(NSData *)data fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError **)error { +- (GTTreeEntry *)addEntryWithData:(NSData *)data fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError * __autoreleasing *)error { NSParameterAssert(data != nil); NSParameterAssert(fileName != nil); @@ -122,7 +122,7 @@ - (GTTreeEntry *)addEntryWithData:(NSData *)data fileName:(NSString *)fileName f return [self addEntryWithOID:OID fileName:fileName fileMode:fileMode error:error]; } -- (GTTreeEntry *)addEntryWithOID:(GTOID *)oid fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError **)error { +- (GTTreeEntry *)addEntryWithOID:(GTOID *)oid fileName:(NSString *)fileName fileMode:(GTFileMode)fileMode error:(NSError * __autoreleasing *)error { NSParameterAssert(oid != nil); NSParameterAssert(fileName != nil); @@ -137,7 +137,7 @@ - (GTTreeEntry *)addEntryWithOID:(GTOID *)oid fileName:(NSString *)fileName file return [GTTreeEntry entryWithEntry:entry parentTree:nil error:error]; } -- (BOOL)removeEntryWithFileName:(NSString *)fileName error:(NSError **)error { +- (BOOL)removeEntryWithFileName:(NSString *)fileName error:(NSError * __autoreleasing *)error { int status = git_treebuilder_remove(self.git_treebuilder, fileName.UTF8String); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to remove entry with name %@ from tree builder.", fileName]; @@ -146,7 +146,7 @@ - (BOOL)removeEntryWithFileName:(NSString *)fileName error:(NSError **)error { return status == GIT_OK; } -- (GTTree *)writeTree:(NSError **)error { +- (GTTree *)writeTree:(NSError * __autoreleasing *)error { git_oid treeOid; int status = git_treebuilder_write(&treeOid, self.git_treebuilder); if (status != GIT_OK) { diff --git a/ObjectiveGit/GTTreeEntry.h b/ObjectiveGit/GTTreeEntry.h index f90bc135a..6b9324667 100644 --- a/ObjectiveGit/GTTreeEntry.h +++ b/ObjectiveGit/GTTreeEntry.h @@ -36,10 +36,10 @@ NS_ASSUME_NONNULL_BEGIN @interface GTTreeEntry : NSObject /// Initializes the receiver. -- (instancetype _Nullable)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree * _Nullable)parent error:(NSError **)error; +- (instancetype _Nullable)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree * _Nullable)parent error:(NSError * __autoreleasing *)error; /// Convience class initializer. -+ (instancetype _Nullable)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree * _Nullable)parent error:(NSError **)error; ++ (instancetype _Nullable)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree * _Nullable)parent error:(NSError * __autoreleasing *)error; /// The underlying `git_tree_entry`. - (git_tree_entry *)git_tree_entry __attribute__((objc_returns_inner_pointer)); @@ -67,15 +67,15 @@ NS_ASSUME_NONNULL_BEGIN /// error - will be filled if an error occurs /// /// Returns this entry as a GTObject or nil if an error occurred. -- (GTObject * _Nullable)GTObject:(NSError **)error; +- (GTObject * _Nullable)GTObject:(NSError * __autoreleasing *)error; @end @interface GTObject (GTTreeEntry) -+ (instancetype _Nullable)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error; -- (instancetype _Nullable)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error; ++ (instancetype _Nullable)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError * __autoreleasing *)error; +- (instancetype _Nullable)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError * __autoreleasing *)error; @end diff --git a/ObjectiveGit/GTTreeEntry.m b/ObjectiveGit/GTTreeEntry.m index 946b1f06f..aa3f17fa0 100644 --- a/ObjectiveGit/GTTreeEntry.m +++ b/ObjectiveGit/GTTreeEntry.m @@ -70,7 +70,7 @@ - (void)dealloc { #pragma mark API -- (instancetype)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent error:(NSError **)error { +- (instancetype)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent error:(NSError * __autoreleasing *)error { NSParameterAssert(theEntry != NULL); self = [super init]; @@ -89,7 +89,7 @@ - (instancetype)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTre return self; } -+ (instancetype)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent error:(NSError **)error { ++ (instancetype)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent error:(NSError * __autoreleasing *)error { return [[self alloc] initWithEntry:theEntry parentTree:parent error:error]; } @@ -123,7 +123,7 @@ - (GTRepository *)repository { return self.tree.repository; } -- (GTObject *)GTObject:(NSError **)error { +- (GTObject *)GTObject:(NSError * __autoreleasing *)error { return [GTObject objectWithTreeEntry:self error:error]; } @@ -132,11 +132,11 @@ - (GTObject *)GTObject:(NSError **)error { @implementation GTObject (GTTreeEntry) -+ (instancetype)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error { ++ (instancetype)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError * __autoreleasing *)error { return [[self alloc] initWithTreeEntry:treeEntry error:error]; } -- (instancetype)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error { +- (instancetype)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError * __autoreleasing *)error { git_object *obj; int gitError = git_tree_entry_to_object(&obj, treeEntry.repository.git_repository, treeEntry.git_tree_entry); if (gitError < GIT_OK) { From 39baf9389a66aecd8e7ee4ee4351431176bfe266 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 7 May 2021 23:18:58 +0200 Subject: [PATCH 03/12] Fix some flags-to-unsigned-int conversions --- ObjectiveGit/GTCheckoutOptions.m | 4 ++-- ObjectiveGit/GTRepository+Stashing.m | 2 +- ObjectiveGit/GTRepository.m | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ObjectiveGit/GTCheckoutOptions.m b/ObjectiveGit/GTCheckoutOptions.m index 354e330c6..1f48ab4d7 100644 --- a/ObjectiveGit/GTCheckoutOptions.m +++ b/ObjectiveGit/GTCheckoutOptions.m @@ -79,7 +79,7 @@ static int GTCheckoutNotifyCallback(git_checkout_notify_t why, const char *path, } - (git_checkout_options *)git_checkoutOptions { - _git_checkoutOptions.checkout_strategy = self.strategy; + _git_checkoutOptions.checkout_strategy = (unsigned int)self.strategy; if (self.progressBlock != nil) { _git_checkoutOptions.progress_cb = GTCheckoutProgressCallback; @@ -88,7 +88,7 @@ - (git_checkout_options *)git_checkoutOptions { if (self.notifyBlock != nil) { _git_checkoutOptions.notify_cb = GTCheckoutNotifyCallback; - _git_checkoutOptions.notify_flags = self.notifyFlags; + _git_checkoutOptions.notify_flags = (unsigned int)self.notifyFlags; _git_checkoutOptions.notify_payload = (__bridge void *)self.notifyBlock; } diff --git a/ObjectiveGit/GTRepository+Stashing.m b/ObjectiveGit/GTRepository+Stashing.m index fd5d55409..ef79458e4 100644 --- a/ObjectiveGit/GTRepository+Stashing.m +++ b/ObjectiveGit/GTRepository+Stashing.m @@ -21,7 +21,7 @@ @implementation GTRepository (Stashing) - (GTCommit *)stashChangesWithMessage:(NSString *)message flags:(GTRepositoryStashFlag)flags error:(NSError * __autoreleasing *)error { git_oid git_oid; - int gitError = git_stash_save(&git_oid, self.git_repository, [self userSignatureForNow].git_signature, message.UTF8String, flags); + int gitError = git_stash_save(&git_oid, self.git_repository, [self userSignatureForNow].git_signature, message.UTF8String, (unsigned int)flags); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to stash."]; return nil; diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index 348602b09..729f5d960 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -914,7 +914,7 @@ - (GTFilterList *)filterListWithPath:(NSString *)path blob:(GTBlob *)blob mode:( NSParameterAssert(path != nil); git_filter_list *list = NULL; - int gitError = git_filter_list_load(&list, self.git_repository, blob.git_blob, path.UTF8String, (git_filter_mode_t)mode, options); + int gitError = git_filter_list_load(&list, self.git_repository, blob.git_blob, path.UTF8String, (git_filter_mode_t)mode, (unsigned int)options); if (gitError != GIT_OK) { if (success != NULL) *success = NO; if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to load filter list for %@", path]; From 8c685e80688e587e6a57de7ec18b86584b700bfb Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 7 May 2021 23:21:41 +0200 Subject: [PATCH 04/12] Sure, Xcode --- ObjectiveGitFramework.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ObjectiveGitFramework.xcodeproj/project.pbxproj b/ObjectiveGitFramework.xcodeproj/project.pbxproj index 26da37c95..134499a75 100644 --- a/ObjectiveGitFramework.xcodeproj/project.pbxproj +++ b/ObjectiveGitFramework.xcodeproj/project.pbxproj @@ -102,8 +102,8 @@ 4DC55AE61AD859AD0032563C /* GTCheckoutOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC55AE31AD859AD0032563C /* GTCheckoutOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4DC55AE71AD859AD0032563C /* GTCheckoutOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DC55AE41AD859AD0032563C /* GTCheckoutOptions.m */; }; 4DC55AE81AD859AD0032563C /* GTCheckoutOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DC55AE41AD859AD0032563C /* GTCheckoutOptions.m */; }; - 4DD769A92645D214007599B8 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB971022645C8F300D14944 /* Nimble.framework */; }; 4DD7422C25D3F8CB009D9A17 /* libgit2-mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DD7422B25D3F8CB009D9A17 /* libgit2-mac.a */; }; + 4DD769A92645D214007599B8 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB971022645C8F300D14944 /* Nimble.framework */; }; 4DFFB15B183AA8D600D1565E /* GTRepository+RemoteOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DFFB159183AA8D600D1565E /* GTRepository+RemoteOperations.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4DFFB15C183AA8D600D1565E /* GTRepository+RemoteOperations.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DFFB15A183AA8D600D1565E /* GTRepository+RemoteOperations.m */; }; 55C8055013861FE7004DCB0F /* GTObjectDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C8054D13861F34004DCB0F /* GTObjectDatabase.m */; }; From 3b4a85cdbeb7cd2ba55d3957b846470532e836f3 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 7 May 2021 23:22:06 +0200 Subject: [PATCH 05/12] Disable double-quoted-header-in-framework warning --- ObjectiveGitFramework.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ObjectiveGitFramework.xcodeproj/project.pbxproj b/ObjectiveGitFramework.xcodeproj/project.pbxproj index 134499a75..f554b421f 100644 --- a/ObjectiveGitFramework.xcodeproj/project.pbxproj +++ b/ObjectiveGitFramework.xcodeproj/project.pbxproj @@ -2218,6 +2218,7 @@ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -2258,6 +2259,7 @@ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -2389,6 +2391,7 @@ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -2608,6 +2611,7 @@ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; From 77220f451b4aa0116201a45ccc7dad95bac269fb Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Tue, 7 Jul 2020 19:20:04 +0200 Subject: [PATCH 06/12] Update libgit2 to 1.1.0 --- External/libgit2 | 2 +- ObjectiveGit.modulemap | 1 - ObjectiveGit/GTBlob.m | 8 ++++--- ObjectiveGit/GTConfiguration.m | 2 +- ObjectiveGit/GTCredential+Private.h | 2 +- ObjectiveGit/GTCredential.h | 12 +++++----- ObjectiveGit/GTCredential.m | 24 ++++++++++---------- ObjectiveGit/GTDiff.m | 2 +- ObjectiveGit/GTIndex.m | 2 +- ObjectiveGit/GTOID.m | 2 +- ObjectiveGit/GTRemote.m | 6 ++--- ObjectiveGit/GTRepository+Merging.m | 8 +++---- ObjectiveGit/GTRepository+Pull.h | 2 +- ObjectiveGit/GTRepository+RemoteOperations.h | 2 +- ObjectiveGit/GTRepository+RemoteOperations.m | 9 ++++---- ObjectiveGit/GTRepository+Status.m | 2 +- ObjectiveGit/GTRepository.h | 2 +- ObjectiveGit/GTRepository.m | 6 ++--- 18 files changed, 47 insertions(+), 47 deletions(-) diff --git a/External/libgit2 b/External/libgit2 index 1a107fac0..20c9fc916 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit 1a107fac0fc88a4d74b64ffc9ae2fd178ba631c0 +Subproject commit 20c9fc9168ce14aca86e8bdfd2a55d337a030248 diff --git a/ObjectiveGit.modulemap b/ObjectiveGit.modulemap index 3ef32bc58..21ad5c5c4 100644 --- a/ObjectiveGit.modulemap +++ b/ObjectiveGit.modulemap @@ -64,7 +64,6 @@ framework module ObjectiveGit { header "git2/sys/refs.h" header "git2/sys/repository.h" header "git2/sys/transport.h" - header "git2/sys/time.h" header "git2/cred_helpers.h" header "git2/sys/openssl.h" header "git2/sys/stream.h" diff --git a/ObjectiveGit/GTBlob.m b/ObjectiveGit/GTBlob.m index 6f2d1e8cb..f7f48a7be 100644 --- a/ObjectiveGit/GTBlob.m +++ b/ObjectiveGit/GTBlob.m @@ -84,7 +84,7 @@ - (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)reposit NSParameterAssert(repository != nil); git_oid oid; - int gitError = git_blob_create_frombuffer(&oid, repository.git_repository, [data bytes], data.length); + int gitError = git_blob_create_from_buffer(&oid, repository.git_repository, [data bytes], data.length); if(gitError < GIT_OK) { if(error != NULL) { *error = [NSError git_errorFor:gitError description:@"Failed to create blob from NSData"]; @@ -100,7 +100,7 @@ - (instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)reposito NSParameterAssert(repository != nil); git_oid oid; - int gitError = git_blob_create_fromdisk(&oid, repository.git_repository, [[file path] fileSystemRepresentation]); + int gitError = git_blob_create_from_disk(&oid, repository.git_repository, [[file path] fileSystemRepresentation]); if(gitError < GIT_OK) { if(error != NULL) { *error = [NSError git_errorFor:gitError description:@"Failed to create blob from NSURL"]; @@ -137,7 +137,9 @@ - (NSData *)applyFiltersForPath:(NSString *)path error:(NSError * __autoreleasin NSCParameterAssert(path != nil); git_buf buffer = GIT_BUF_INIT_CONST(0, NULL); - int gitError = git_blob_filtered_content(&buffer, self.git_blob, path.UTF8String, 1); + + git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT; + int gitError = git_blob_filter(&buffer, self.git_blob, path.UTF8String, &opts); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to apply filters for path %@ to blob", path]; return nil; diff --git a/ObjectiveGit/GTConfiguration.m b/ObjectiveGit/GTConfiguration.m index 917f3552c..4c4a3c08a 100644 --- a/ObjectiveGit/GTConfiguration.m +++ b/ObjectiveGit/GTConfiguration.m @@ -146,7 +146,7 @@ - (NSArray *)remotes { } } - git_strarray_free(&names); + git_strarray_dispose(&names); return remotes; } diff --git a/ObjectiveGit/GTCredential+Private.h b/ObjectiveGit/GTCredential+Private.h index 866b389a7..33a546359 100644 --- a/ObjectiveGit/GTCredential+Private.h +++ b/ObjectiveGit/GTCredential+Private.h @@ -27,4 +27,4 @@ typedef struct { __unsafe_unretained GTCredentialProvider *credProvider; } GTCredentialAcquireCallbackInfo; -int GTCredentialAcquireCallback(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); +int GTCredentialAcquireCallback(git_credential **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); diff --git a/ObjectiveGit/GTCredential.h b/ObjectiveGit/GTCredential.h index 5501bf04a..9f0b42ee8 100644 --- a/ObjectiveGit/GTCredential.h +++ b/ObjectiveGit/GTCredential.h @@ -12,9 +12,9 @@ /// An enum describing the data needed for authentication. /// See `git_credtype_t`. typedef NS_ENUM(NSInteger, GTCredentialType) { - GTCredentialTypeUserPassPlaintext = GIT_CREDTYPE_USERPASS_PLAINTEXT, - GTCredentialTypeSSHKey = GIT_CREDTYPE_SSH_KEY, - GTCredentialTypeSSHCustom = GIT_CREDTYPE_SSH_CUSTOM, + GTCredentialTypeUserPassPlaintext = GIT_CREDENTIAL_USERPASS_PLAINTEXT, + GTCredentialTypeSSHKey = GIT_CREDENTIAL_SSH_KEY, + GTCredentialTypeSSHCustom = GIT_CREDENTIAL_SSH_CUSTOM, }; NS_ASSUME_NONNULL_BEGIN @@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// The GTCredential class is used to provide authentication data. -/// It acts as a wrapper around `git_cred` objects. +/// It acts as a wrapper around `git_credential` objects. @interface GTCredential : NSObject /// Create a credential object from a username/password pair. @@ -86,8 +86,8 @@ NS_ASSUME_NONNULL_BEGIN /// Return a new GTCredential instance, or nil if an error occurred + (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError * __autoreleasing *)error; -/// The underlying `git_cred` object. -- (git_cred *)git_cred __attribute__((objc_returns_inner_pointer)); +/// The underlying `git_credential` object. +- (git_credential *)git_credential __attribute__((objc_returns_inner_pointer)); @end diff --git a/ObjectiveGit/GTCredential.m b/ObjectiveGit/GTCredential.m index fe435387e..3ba731649 100644 --- a/ObjectiveGit/GTCredential.m +++ b/ObjectiveGit/GTCredential.m @@ -39,14 +39,14 @@ - (GTCredential *)credentialForType:(GTCredentialType)type URL:(NSString *)URL u @end @interface GTCredential () -@property (nonatomic, assign, readonly) git_cred *git_cred; +@property (nonatomic, assign, readonly) git_credential *git_credential; @end @implementation GTCredential + (instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError * __autoreleasing *)error { - git_cred *cred; - int gitError = git_cred_userpass_plaintext_new(&cred, userName.UTF8String, password.UTF8String); + git_credential *cred; + int gitError = git_credential_userpass_plaintext_new(&cred, userName.UTF8String, password.UTF8String); if (gitError != GIT_OK) { if (error) *error = [NSError git_errorFor:gitError description:@"Failed to create credentials object" failureReason:@"There was an error creating a credential object for username %@.", userName]; return nil; @@ -61,8 +61,8 @@ + (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL NSString *privateKeyPath = privateKeyURL.filePathURL.path; NSAssert(privateKeyPath != nil, @"Invalid file URL passed: %@", privateKeyURL); - git_cred *cred; - int gitError = git_cred_ssh_key_new(&cred, userName.UTF8String, publicKeyPath.fileSystemRepresentation, privateKeyPath.fileSystemRepresentation, passphrase.UTF8String); + git_credential *cred; + int gitError = git_credential_ssh_key_new(&cred, userName.UTF8String, publicKeyPath.fileSystemRepresentation, privateKeyPath.fileSystemRepresentation, passphrase.UTF8String); if (gitError != GIT_OK) { if (error) *error = [NSError git_errorFor:gitError description:@"Failed to create credentials object" failureReason:@"There was an error creating a credential object for username %@ with the provided public/private key pair.\nPublic key: %@\nPrivate key: %@", userName, publicKeyURL, privateKeyURL]; return nil; @@ -74,8 +74,8 @@ + (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL + (instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(NSString *)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString *)passphrase error:(NSError * __autoreleasing *)error { NSParameterAssert(privateKeyString != nil); - git_cred *cred; - int gitError = git_cred_ssh_key_memory_new(&cred, userName.UTF8String, publicKeyString.UTF8String, privateKeyString.UTF8String, passphrase.UTF8String); + git_credential *cred; + int gitError = git_credential_ssh_key_memory_new(&cred, userName.UTF8String, publicKeyString.UTF8String, privateKeyString.UTF8String, passphrase.UTF8String); if (gitError != GIT_OK) { if (error) *error = [NSError git_errorFor:gitError description:@"Failed to create credentials object" failureReason:@"There was an error creating a credential object for username %@ with the provided public/private key pair.\nPublic key: %@", userName, publicKeyString]; return nil; @@ -84,21 +84,21 @@ + (instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(NSS return [[self alloc] initWithGitCred:cred]; } -- (instancetype)initWithGitCred:(git_cred *)cred { +- (instancetype)initWithGitCred:(git_credential *)cred { NSParameterAssert(cred != nil); self = [self init]; if (self == nil) return nil; - _git_cred = cred; + _git_credential = cred; return self; } @end -int GTCredentialAcquireCallback(git_cred **git_cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) { - NSCParameterAssert(git_cred != NULL); +int GTCredentialAcquireCallback(git_credential **git_credential, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) { + NSCParameterAssert(git_credential != NULL); NSCParameterAssert(payload != NULL); GTCredentialAcquireCallbackInfo *info = payload; @@ -118,6 +118,6 @@ int GTCredentialAcquireCallback(git_cred **git_cred, const char *url, const char return GIT_ERROR; } - *git_cred = cred.git_cred; + *git_credential = cred.git_credential; return GIT_OK; } diff --git a/ObjectiveGit/GTDiff.m b/ObjectiveGit/GTDiff.m index 5c160be6a..bb1a35ff8 100644 --- a/ObjectiveGit/GTDiff.m +++ b/ObjectiveGit/GTDiff.m @@ -71,7 +71,7 @@ + (int)handleParsedOptionsDictionary:(NSDictionary *)dictionary usingBlock:(int git_strarray strArray = pathSpec.git_strarray; if (pathSpec != nil) newOptions.pathspec = strArray; @onExit { - git_strarray_free((git_strarray *)&strArray); + git_strarray_dispose((git_strarray *)&strArray); }; git_diff_options *optionsPtr = &newOptions; diff --git a/ObjectiveGit/GTIndex.m b/ObjectiveGit/GTIndex.m index 1bd4f9f7b..5f6890fc1 100644 --- a/ObjectiveGit/GTIndex.m +++ b/ObjectiveGit/GTIndex.m @@ -196,7 +196,7 @@ - (BOOL)addData:(NSData *)data withPath:(NSString *)path error:(NSError * __auto entry.path = [path cStringUsingEncoding:NSUTF8StringEncoding]; entry.mode = GIT_FILEMODE_BLOB; - int status = git_index_add_frombuffer(self.git_index, &entry, [data bytes], [data length]); + int status = git_index_add_from_buffer(self.git_index, &entry, [data bytes], [data length]); if (status != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to add data with name %@ into index.", path]; diff --git a/ObjectiveGit/GTOID.m b/ObjectiveGit/GTOID.m index 725ef9a63..323a308ef 100644 --- a/ObjectiveGit/GTOID.m +++ b/ObjectiveGit/GTOID.m @@ -98,7 +98,7 @@ + (instancetype)oidWithSHACString:(const char *)SHA { } - (BOOL)isZero { - return git_oid_iszero(self.git_oid) != 0; + return git_oid_is_zero(self.git_oid) != 0; } #pragma mark NSObject diff --git a/ObjectiveGit/GTRemote.m b/ObjectiveGit/GTRemote.m index 7eb321356..c3869fe57 100644 --- a/ObjectiveGit/GTRemote.m +++ b/ObjectiveGit/GTRemote.m @@ -157,7 +157,7 @@ - (BOOL)rename:(NSString *)name error:(NSError * __autoreleasing *)error { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to rename remote" userInfo:userInfo failureReason:@"Couldn't rename remote %@ to %@", self.name, name]; } - git_strarray_free(&problematic_refspecs); + git_strarray_dispose(&problematic_refspecs); return gitError == GIT_OK; } @@ -168,7 +168,7 @@ - (NSArray *)fetchRefspecs { if (gitError != GIT_OK) return nil; @onExit { - git_strarray_free(&refspecs); + git_strarray_dispose(&refspecs); }; return [NSArray git_arrayWithStrarray:refspecs]; @@ -181,7 +181,7 @@ - (NSArray *)pushRefspecs { if (gitError != GIT_OK) return nil; @onExit { - git_strarray_free(&refspecs); + git_strarray_dispose(&refspecs); }; return [NSArray git_arrayWithStrarray:refspecs]; diff --git a/ObjectiveGit/GTRepository+Merging.m b/ObjectiveGit/GTRepository+Merging.m index 6c4e00479..621a36605 100644 --- a/ObjectiveGit/GTRepository+Merging.m +++ b/ObjectiveGit/GTRepository+Merging.m @@ -20,7 +20,7 @@ #import "GTOdbObject.h" #import "GTObjectDatabase.h" -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *stats, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *stats, BOOL *stop); @implementation GTRepository (Merging) @@ -181,7 +181,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize the ancestor's merge file input git_merge_file_input ancestorInput; - int gitError = git_merge_file_init_input(&ancestorInput, GIT_MERGE_FILE_INPUT_VERSION); + int gitError = git_merge_file_input_init(&ancestorInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input for ancestor"]; return nil; @@ -199,7 +199,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize our merge file input git_merge_file_input ourInput; - gitError = git_merge_file_init_input(&ourInput, GIT_MERGE_FILE_INPUT_VERSION); + gitError = git_merge_file_input_init(&ourInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input for our side"]; return nil; @@ -217,7 +217,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize their merge file input git_merge_file_input theirInput; - gitError = git_merge_file_init_input(&theirInput, GIT_MERGE_FILE_INPUT_VERSION); + gitError = git_merge_file_input_init(&theirInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input other side"]; return nil; diff --git a/ObjectiveGit/GTRepository+Pull.h b/ObjectiveGit/GTRepository+Pull.h index 63c1abc36..2c14d051c 100644 --- a/ObjectiveGit/GTRepository+Pull.h +++ b/ObjectiveGit/GTRepository+Pull.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *progress, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *progress, BOOL *stop); @interface GTRepository (Pull) diff --git a/ObjectiveGit/GTRepository+RemoteOperations.h b/ObjectiveGit/GTRepository+RemoteOperations.h index e4152749c..2c9008390 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.h +++ b/ObjectiveGit/GTRepository+RemoteOperations.h @@ -51,7 +51,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the fetch was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(const git_transfer_progress *stats, BOOL *stop))progressBlock; +- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error progress:(void (^ _Nullable)(const git_indexer_progress *stats, BOOL *stop))progressBlock; /// Enumerate all available fetch head entries. /// diff --git a/ObjectiveGit/GTRepository+RemoteOperations.m b/ObjectiveGit/GTRepository+RemoteOperations.m index de57b60b9..67fc2bdb5 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.m +++ b/ObjectiveGit/GTRepository+RemoteOperations.m @@ -30,7 +30,7 @@ NSString *const GTRepositoryRemoteOptionsDownloadTags = @"GTRepositoryRemoteOptionsDownloadTags"; NSString *const GTRepositoryRemoteOptionsPushNotes = @"GTRepositoryRemoteOptionsPushNotes"; -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *stats, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *stats, BOOL *stop); typedef void (^GTRemotePushTransferProgressBlock)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop); @implementation GTRepository (RemoteOperations) @@ -45,7 +45,7 @@ @implementation GTRepository (RemoteOperations) git_direction direction; } GTRemoteConnectionInfo; -int GTRemoteFetchTransferProgressCallback(const git_transfer_progress *stats, void *payload) { +int GTRemoteFetchTransferProgressCallback(const git_indexer_progress *stats, void *payload) { GTRemoteConnectionInfo *info = payload; BOOL stop = NO; @@ -97,7 +97,7 @@ - (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error } @onExit { - git_strarray_free(&refspecs); + git_strarray_dispose(&refspecs); }; NSString *reflog_message = [NSString stringWithFormat:@"fetching remote %@", remote.name]; @@ -286,8 +286,7 @@ - (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions }; git_push_options push_options = GIT_PUSH_OPTIONS_INIT; - - gitError = git_push_init_options(&push_options, GIT_PUSH_OPTIONS_VERSION); + gitError = git_push_options_init(&push_options, GIT_PUSH_OPTIONS_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to init push options"]; return NO; diff --git a/ObjectiveGit/GTRepository+Status.m b/ObjectiveGit/GTRepository+Status.m index 8c145902e..85a4b8a58 100644 --- a/ObjectiveGit/GTRepository+Status.m +++ b/ObjectiveGit/GTRepository+Status.m @@ -41,7 +41,7 @@ - (BOOL)enumerateFileStatusWithOptions:(NSDictionary *)options error:(NSError * int err = git_status_list_new(&statusList, self.git_repository, &gitOptions); @onExit { git_status_list_free(statusList); - if (gitOptions.pathspec.count > 0) git_strarray_free(&gitOptions.pathspec); + if (gitOptions.pathspec.count > 0) git_strarray_dispose(&gitOptions.pathspec); }; if (err != GIT_OK) { diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index 7d8d4a4e4..96043de43 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -239,7 +239,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful. -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock; ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_indexer_progress *, BOOL *stop))transferProgressBlock; /// Lookup objects in the repo by oid or sha1 - (id _Nullable)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError * __autoreleasing *)error; diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index 729f5d960..75525cbbc 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -214,9 +214,9 @@ - (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceiling } -typedef void(^GTTransferProgressBlock)(const git_transfer_progress *progress, BOOL *stop); +typedef void(^GTTransferProgressBlock)(const git_indexer_progress *progress, BOOL *stop); -static int transferProgressCallback(const git_transfer_progress *progress, void *payload) { +static int transferProgressCallback(const git_indexer_progress *progress, void *payload) { if (payload == NULL) return 0; struct GTClonePayload *pld = payload; if (pld->transferProgressBlock == NULL) return 0; @@ -244,7 +244,7 @@ static int remoteCreate(git_remote **remote, git_repository *repo, const char *n git_remote_callbacks remoteCallbacks; }; -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock { ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError * __autoreleasing *)error transferProgressBlock:(void (^ _Nullable)(const git_indexer_progress *, BOOL *stop))transferProgressBlock { git_clone_options cloneOptions = GIT_CLONE_OPTIONS_INIT; From 44aa3dacce31e090ca09763f536bd862348fd6a4 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Tue, 7 Jul 2020 19:22:45 +0200 Subject: [PATCH 07/12] Update OpenSSL to 1.1.1i --- External/openssl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/External/openssl b/External/openssl index e71ebf275..90cebd1b2 160000 --- a/External/openssl +++ b/External/openssl @@ -1 +1 @@ -Subproject commit e71ebf275da66dfd601c92e0e80a35114c32f6f8 +Subproject commit 90cebd1b216e0a160fcfd8e0eddca47dad47c183 From e202895ccb474d9773927da960156f40308e8f46 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Tue, 7 Jul 2020 19:23:28 +0200 Subject: [PATCH 08/12] Update libssh2 to 1.9.0 --- External/libssh2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/External/libssh2 b/External/libssh2 index f15b1e297..42d37aa63 160000 --- a/External/libssh2 +++ b/External/libssh2 @@ -1 +1 @@ -Subproject commit f15b1e297f72882214988101ccdc5e6ad30d7e6e +Subproject commit 42d37aa63129a1b2644bf6495198923534322d64 From c58d073b7266c7ec032a8ec918a18bcc74a282f3 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Sun, 9 May 2021 20:30:01 +0200 Subject: [PATCH 09/12] Reorder build phases compile + link happens last Otherwise, a clean build would error because the `git2` headers haven't been copied yet. --- ObjectiveGitFramework.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ObjectiveGitFramework.xcodeproj/project.pbxproj b/ObjectiveGitFramework.xcodeproj/project.pbxproj index f554b421f..8554c63ca 100644 --- a/ObjectiveGitFramework.xcodeproj/project.pbxproj +++ b/ObjectiveGitFramework.xcodeproj/project.pbxproj @@ -1478,12 +1478,12 @@ isa = PBXNativeTarget; buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "ObjectiveGit-Mac" */; buildPhases = ( - 8DC2EF540486A6940098B216 /* Sources */, 8DC2EF520486A6940098B216 /* Resources */, - 8DC2EF560486A6940098B216 /* Frameworks */, 79262F0F13C697BE00A4B1EA /* Copy git2 Headers */, BEF7E4DF1A3A47450035BB8E /* Copy git2 Headers again */, 8DC2EF500486A6940098B216 /* Headers */, + 8DC2EF540486A6940098B216 /* Sources */, + 8DC2EF560486A6940098B216 /* Frameworks */, 4D751E9D215D765D003CD3CE /* Package external libraries */, ); buildRules = ( @@ -1501,9 +1501,9 @@ isa = PBXNativeTarget; buildConfigurationList = D01B6EE619F82E2000D411BC /* Build configuration list for PBXNativeTarget "ObjectiveGit-iOS" */; buildPhases = ( + D01B6ED019F82E2000D411BC /* Headers */, D01B6ECE19F82E2000D411BC /* Sources */, D01B6ECF19F82E2000D411BC /* Frameworks */, - D01B6ED019F82E2000D411BC /* Headers */, ); buildRules = ( ); From fd83f4c791312fa9fc7ec76be030be401dd33d10 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Sun, 9 May 2021 20:30:38 +0200 Subject: [PATCH 10/12] Report the repository initialization error when testing --- ObjectiveGitTests/QuickSpec+GTFixtures.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ObjectiveGitTests/QuickSpec+GTFixtures.m b/ObjectiveGitTests/QuickSpec+GTFixtures.m index a54270a39..1be651cb5 100644 --- a/ObjectiveGitTests/QuickSpec+GTFixtures.m +++ b/ObjectiveGitTests/QuickSpec+GTFixtures.m @@ -121,8 +121,9 @@ - (BOOL)unzipFromArchiveAtPath:(NSString *)zipPath intoDirectory:(NSString *)des - (GTRepository *)fixtureRepositoryNamed:(NSString *)name { NSURL *url = [NSURL fileURLWithPath:[self pathForFixtureRepositoryNamed:name]]; - GTRepository *repository = [[GTRepository alloc] initWithURL:url error:NULL]; - XCTAssertNotNil(repository, @"Couldn't create a repository for %@", name); + NSError *error = nil; + GTRepository *repository = [[GTRepository alloc] initWithURL:url error:&error]; + XCTAssertNotNil(repository, @"Couldn't create a repository for %@: %@", name, error); return repository; } From 23fdc9ba48448c0c5908681fdbc61cea188eaadf Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Sun, 9 May 2021 21:34:00 +0200 Subject: [PATCH 11/12] Fix submodule test failure --- ObjectiveGitTests/GTSubmoduleSpec.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ObjectiveGitTests/GTSubmoduleSpec.m b/ObjectiveGitTests/GTSubmoduleSpec.m index 0a25f5e35..0a2819c57 100644 --- a/ObjectiveGitTests/GTSubmoduleSpec.m +++ b/ObjectiveGitTests/GTSubmoduleSpec.m @@ -246,7 +246,8 @@ __block NSError *error = nil; expect(@([submodule sync:&error])).to(beTruthy()); - expect([config stringForKey:configKey]).to(equal(@"../Test_App")); + NSString *submoduleURL = [[[repo.fileURL URLByAppendingPathComponent:@"../Test_App"] URLByResolvingSymlinksInPath] path]; + expect([config stringForKey:configKey]).to(equal(submoduleURL)); }); }); From f21e086947771e8fcb12080b8c8cd46d01565d87 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 10 May 2021 00:09:12 +0200 Subject: [PATCH 12/12] Build system update --- script/ios_build_functions.sh | 13 +++------- script/update_libgit2_ios | 2 +- script/update_libssh2_ios | 9 ++++++- script/update_libssl_ios | 47 +++++++++++++++++++++-------------- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/script/ios_build_functions.sh b/script/ios_build_functions.sh index 515ca81b1..1a916969b 100755 --- a/script/ios_build_functions.sh +++ b/script/ios_build_functions.sh @@ -39,7 +39,7 @@ function setup_build_environment () CAN_BUILD_64BIT="1" fi - ARCHS="i386 armv7 armv7s" + ARCHS="armv7 armv7s" if [ "${CAN_BUILD_64BIT}" -eq "1" ] then # For some stupid reason cmake needs simulator @@ -72,20 +72,13 @@ function build_all_archs () do if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] then - PLATFORM="iphonesimulator" + PLATFORM="iPhoneSimulator" else - PLATFORM="iphoneos" + PLATFORM="iPhoneOS" fi SDKVERSION=$(ios_sdk_version) - if [ "${ARCH}" == "arm64" ] - then - HOST="aarch64-apple-darwin" - else - HOST="${ARCH}-apple-darwin" - fi - SDKNAME="${PLATFORM}${SDKVERSION}" SDKROOT="$(ios_sdk_path ${SDKNAME})" diff --git a/script/update_libgit2_ios b/script/update_libgit2_ios index 2586f128b..5257856b8 100755 --- a/script/update_libgit2_ios +++ b/script/update_libgit2_ios @@ -46,7 +46,7 @@ function build_libgit2 () -DCMAKE_INSTALL_PREFIX:PATH="${ARCH_INSTALL_PATH}/" \ -DBUILD_CLAR:BOOL=OFF \ -DTHREADSAFE:BOOL=ON \ - -DCURL:BOOL=OFF \ + -DREGEX_BACKEND=builtin \ -DCMAKE_C_FLAGS:STRING="-fembed-bitcode" \ "${SYS_ROOT}" \ -DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \ diff --git a/script/update_libssh2_ios b/script/update_libssh2_ios index b015047c5..d329ed4c9 100755 --- a/script/update_libssh2_ios +++ b/script/update_libssh2_ios @@ -21,11 +21,18 @@ function build_ssh2 () cp -R "${ROOT_PATH}/External/libssh2" "${ARCH_INSTALL_PATH}/libssh2" pushd "${ARCH_INSTALL_PATH}/libssh2" > /dev/null + if [ "${ARCH}" == "arm64" ] + then + HOST="aarch64-apple-darwin" + else + HOST="${ARCH}-apple-darwin" + fi + export CFLAGS="-arch ${ARCH} -fembed-bitcode -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" export CPPFLAGS="-arch ${ARCH} -fembed-bitcode -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" ./buildconf >> "${LOG}" 2>&1 - ./configure --host=${HOST} --prefix="${ARCH_INSTALL_PATH}" --with-openssl --with-libssl-prefix="${INSTALL_PATH}" --disable-shared --enable-static >> "${LOG}" 2>&1 + ./configure --host=${HOST} --prefix="${ARCH_INSTALL_PATH}" --with-libssl-prefix="${INSTALL_PATH}" --disable-shared --enable-static >> "${LOG}" 2>&1 make >> "${LOG}" 2>&1 make install >> "${LOG}" 2>&1 popd > /dev/null diff --git a/script/update_libssl_ios b/script/update_libssl_ios index 2b4593683..6de9c21be 100755 --- a/script/update_libssl_ios +++ b/script/update_libssl_ios @@ -21,28 +21,39 @@ function setup () function build_ssl () { - cp -r "${ROOT_PATH}/External/openssl" "${ARCH_INSTALL_PATH}/openssl" - pushd "${ARCH_INSTALL_PATH}/openssl" > /dev/null + if [ -f "${ARCH_INSTALL_PATH}/lib/libssl.a" -a \ + -f "${ARCH_INSTALL_PATH}/lib/libcrypto.a" ]; then + echo "No building needed." 2>&1 + else - if [ "${ARCH}" == "arm64" ] || [ "${ARCH}" == "x86_64" ] - then - HOST="BSD-generic64" - CONFIG="no-gost no-asm enable-ec_nistp_64_gcc_128" - else - HOST="BSD-generic32" - CONFIG="no-gost no-asm" - perl -i -pe 's|static volatile sig_atomic_t intr_signal|static volatile int intr_signal|' crypto/ui/ui_openssl.c - fi + cp -r "${ROOT_PATH}/External/openssl" "${ARCH_INSTALL_PATH}/openssl" + pushd "${ARCH_INSTALL_PATH}/openssl" > /dev/null - ./Configure ${HOST} ${CONFIG} --openssldir="${ARCH_INSTALL_PATH}" >> "${LOG}" 2>&1 - perl -i -pe "s|^CC= gcc|CC= ${CLANG} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -arch ${ARCH} -fembed-bitcode |g" Makefile >> "${LOG}" 2>&1 - perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${SDKROOT} \$1|g" Makefile >> "${LOG}" 2>&1 - make >> "${LOG}" 2>&1 + if [ "${ARCH}" == "x86_64" ]; then + HOST="iossimulator-xcrun" + CONFIG="" + elif [ "${ARCH}" == "arm64" ]; then + HOST="ios64-cross" + CONFIG="" + elif [ "${ARCH}" == "armv7" ] || [ "${ARCH}" == "armv7s" ]; then + HOST="ios-cross" + CONFIG="" + else + echo "Unhandled ARCH: ${ARCH}" + exit -1 + fi - make install_sw >> "${LOG}" 2>&1 - popd > /dev/null + echo "./Configure ${HOST} ${CONFIG} --prefix=\"${ARCH_INSTALL_PATH}\" --openssldir=\"${ARCH_INSTALL_PATH}\" >> \"${LOG}\" 2>&1" + ./Configure ${HOST} ${CONFIG} --prefix=${ARCH_INSTALL_PATH} --openssldir="${ARCH_INSTALL_PATH}" >> "${LOG}" 2>&1 + perl -i -pe "s|^CFLAGS=(.*)|CFLAGS= -arch ${ARCH} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -isysroot ${SDKROOT} -fembed-bitcode \$1|g" Makefile >> "${LOG}" 2>&1 + perl -i -pe "s|-arch (\w+)|-arch ${ARCH}|g" Makefile >> "${LOG}" 2>&1 + make >> "${LOG}" 2>&1 - rm -rf "${ARCH_INSTALL_PATH}/openssl" + make install_sw >> "${LOG}" 2>&1 + popd > /dev/null + + rm -rf "${ARCH_INSTALL_PATH}/openssl" + fi BUILT_CRYPTO_PATHS+=("${ARCH_INSTALL_PATH}/lib/libcrypto.a") BUILT_SSL_PATHS+=("${ARCH_INSTALL_PATH}/lib/libssl.a")