Skip to content

Commit

Permalink
Fix warning about missing ownership on NSError.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiennou committed May 11, 2019
1 parent 8f0f72d commit c588dbc
Show file tree
Hide file tree
Showing 76 changed files with 413 additions and 413 deletions.
2 changes: 1 addition & 1 deletion ObjectiveGit/Categories/NSData+Git.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/Categories/NSData+Git.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions ObjectiveGit/GTBlob.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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));
Expand All @@ -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

Expand Down
16 changes: 8 additions & 8 deletions ObjectiveGit/GTBlob.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions ObjectiveGit/GTBranch.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,33 @@ 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
///
/// otherBranch -
/// error - If not NULL, set to any error that occurs.
///
/// Returns a (possibly empty) array of GTCommits, or nil if an error occurs.
- (NSArray<GTCommit *> * _Nullable)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
- (NSArray<GTCommit *> * _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.
///
Expand All @@ -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.
Expand All @@ -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.
///
Expand All @@ -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

Expand Down
18 changes: 9 additions & 9 deletions ObjectiveGit/GTBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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];
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTCommit.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGit/GTCredential.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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
///
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGit/GTCredential.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit c588dbc

Please sign in to comment.