Skip to content

Commit

Permalink
Merge pull request #582 from alehed/new_nullable_annotation
Browse files Browse the repository at this point in the history
New nullable annotation
  • Loading branch information
pietbrauer authored Mar 10, 2017
2 parents ba47643 + 1279d2f commit ff3bd77
Show file tree
Hide file tree
Showing 57 changed files with 285 additions and 285 deletions.
6 changes: 3 additions & 3 deletions ObjectiveGit/GTBlame.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
/// blame - A git_blame to wrap. May not be NULL.
///
/// Returns a blame, or nil if initialization failed.
- (nullable instancetype)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;

/// Get all the hunks in the blame. A convenience wrapper around `enumerateHunksUsingBlock:`
@property (nonatomic, strong, readonly) NSArray<GTBlameHunk *> *hunks;
Expand All @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
/// index - The index to retrieve the hunk from.
///
/// Returns a `GTBlameHunk` or nil if an error occurred.
- (nullable GTBlameHunk *)hunkAtIndex:(NSUInteger)index;
- (GTBlameHunk * _Nullable)hunkAtIndex:(NSUInteger)index;

/// Enumerate the hunks in the blame.
///
Expand All @@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
/// lineNumber - The (1 based) line number to find a hunk for.
///
/// Returns a `GTBlameHunk` or nil if an error occurred.
- (nullable GTBlameHunk *)hunkAtLineNumber:(NSUInteger)lineNumber;
- (GTBlameHunk * _Nullable)hunkAtLineNumber:(NSUInteger)lineNumber;

/// The underlying `git_blame` object.
- (git_blame *)git_blame __attribute__((objc_returns_inner_pointer));
Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGit/GTBlameHunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ NS_ASSUME_NONNULL_BEGIN
/// hunk - A git_blame_hunk to wrap. May not be NULL.
///
/// Returns a blame hunk, or nil if initialization failed.
- (nullable instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;

/// A NSRange where `location` is the (1 based) starting line number,
/// and `length` is the number of lines in the hunk.
@property (nonatomic, readonly) NSRange lines;

/// The OID of the commit where this hunk was last changed.
@property (nonatomic, readonly, copy, nullable) GTOID *finalCommitOID;
@property (nonatomic, readonly, copy) GTOID * _Nullable finalCommitOID;

/// The signature of the commit where this hunk was last changed.
@property (nonatomic, readonly, nullable) GTSignature *finalSignature;
@property (nonatomic, readonly) GTSignature * _Nullable finalSignature;

/// The path of the file in the original commit.
@property (nonatomic, readonly, copy) NSString *originalPath;
Expand Down
16 changes: 8 additions & 8 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.
+ (nullable instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
+ (instancetype _Nullable)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)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.
+ (nullable instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
+ (instancetype _Nullable)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)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.
+ (nullable instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
+ (instancetype _Nullable)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)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.
- (nullable instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
- (instancetype _Nullable)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)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.
- (nullable instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
- (instancetype _Nullable)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;

/// Creates a new blob from the specified file.
///
Expand All @@ -98,22 +98,22 @@ 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.
- (nullable instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
- (instancetype _Nullable)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;

/// The underlying `git_object` as a `git_blob` object.
- (git_blob *)git_blob __attribute__((objc_returns_inner_pointer));

- (git_off_t)size;
- (NSString *)content;
- (nullable NSData *)data;
- (NSData * _Nullable)data;

/// Attempts to apply the filter list for `path` to the blob.
///
/// path - The path to use filters from. Must not be nil.
/// error - If not NULL, set to any error that occurs.
///
/// Returns the filtered data, or nil if an error occurs.
- (nullable NSData *)applyFiltersForPath:(NSString *)path error:(NSError **)error;
- (NSData * _Nullable)applyFiltersForPath:(NSString *)path error:(NSError **)error;

@end

Expand Down
22 changes: 11 additions & 11 deletions ObjectiveGit/GTBranch.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ NS_ASSUME_NONNULL_BEGIN
/// equal.
@interface GTBranch : NSObject

@property (nonatomic, readonly, nullable) NSString *name;
@property (nonatomic, readonly, nullable) NSString *shortName;
@property (nonatomic, copy, readonly, nullable) GTOID *OID;
@property (nonatomic, readonly, nullable) NSString *remoteName;
@property (nonatomic, readonly) NSString * _Nullable name;
@property (nonatomic, readonly) NSString * _Nullable shortName;
@property (nonatomic, copy, readonly) GTOID * _Nullable OID;
@property (nonatomic, readonly) NSString * _Nullable remoteName;
@property (nonatomic, readonly) GTBranchType branchType;
@property (nonatomic, readonly, strong) GTRepository *repository;
@property (nonatomic, readonly, strong) GTReference *reference;
Expand All @@ -62,22 +62,22 @@ NS_ASSUME_NONNULL_BEGIN
/// repo - The repository containing the branch. Must not be nil.
///
/// Returns the initialized receiver.
- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;

/// Convenience class initializer.
///
/// ref - The branch reference to wrap. Must not be nil.
/// repo - The repository containing the branch. Must not be nil.
///
/// Returns an initialized instance.
+ (nullable instancetype)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo;
+ (instancetype _Nullable)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo;

/// Get the target commit for this branch
///
/// error(out) - will be filled if an error occurs
///
/// returns a GTCommit object or nil if an error occurred
- (nullable GTCommit *)targetCommitWithError:(NSError **)error;
- (GTCommit * _Nullable)targetCommitWithError:(NSError **)error;

/// Count all commits in this branch
///
Expand All @@ -92,15 +92,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.
- (nullable NSArray<GTCommit *> *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
- (NSArray<GTCommit *> * _Nullable)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;

/// Deletes the local branch and nils out the reference.
- (BOOL)deleteWithError:(NSError **)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.
- (nullable GTBranch *)trackingBranchWithError:(NSError **)error success:(nullable BOOL *)success;
- (GTBranch * _Nullable)trackingBranchWithError:(NSError **)error success:(BOOL * _Nullable)success;

/// Update the tracking branch.
///
Expand All @@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
/// error - The error if one occurred.
///
/// Returns whether it was successful.
- (BOOL)updateTrackingBranch:(nullable GTBranch *)trackingBranch error:(NSError **)error;
- (BOOL)updateTrackingBranch:(GTBranch * _Nullable)trackingBranch error:(NSError **)error;

/// Reloads the branch's reference and creates a new branch based off that newly
/// loaded reference.
Expand All @@ -119,7 +119,7 @@ NS_ASSUME_NONNULL_BEGIN
/// error - The error if one occurred.
///
/// Returns the reloaded branch, or nil if an error occurred.
- (nullable GTBranch *)reloadedBranchWithError:(NSError **)error;
- (GTBranch * _Nullable)reloadedBranchWithError:(NSError **)error;

/// Calculate the ahead/behind count from this branch to the given branch.
///
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveGit/GTBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ + (NSString *)remoteNamePrefix {
return @"refs/remotes/";
}

+ (nullable instancetype)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo {
+ (instancetype)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo {
return [[self alloc] initWithReference:ref repository:repo];
}

Expand All @@ -74,7 +74,7 @@ - (instancetype)init {
return nil;
}

- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
- (instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
NSParameterAssert(ref != nil);
NSParameterAssert(repo != nil);

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTCheckoutOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef NS_OPTIONS(NSInteger, GTCheckoutNotifyFlags) {
/// @param notifyBlock A block that will be called for each event, @see `notifyFlags`.
///
/// @return A newly-initialized GTCheckoutOptions object.
+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock notifyBlock:(nullable int (^)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir))notifyBlock;
+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(void (^ _Nullable)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock notifyBlock:(int (^ _Nullable)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir))notifyBlock;

/// Create a checkout options object.
/// @see +checkoutOptionsWithStrategy:notifyFlags:progressBlock:notifyBlock:
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveGit/GTCheckoutOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
typedef void (^GTCheckoutProgressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);

// The type of block set in notifyBlock for notification reporting
typedef int (^GTCheckoutNotifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile * __nullable baseline, GTDiffFile * __nullable target, GTDiffFile * __nullable workdir);
typedef int (^GTCheckoutNotifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile * _Nullable baseline, GTDiffFile * _Nullable target, GTDiffFile * _Nullable workdir);


@interface GTCheckoutOptions () {
Expand All @@ -26,7 +26,7 @@ @interface GTCheckoutOptions () {

@implementation GTCheckoutOptions

+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(nullable GTCheckoutProgressBlock)progressBlock notifyBlock:(nullable GTCheckoutNotifyBlock)notifyBlock {
+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(GTCheckoutProgressBlock _Nullable)progressBlock notifyBlock:( GTCheckoutNotifyBlock _Nullable)notifyBlock {
GTCheckoutOptions *options = [self checkoutOptionsWithStrategy:strategy];
options.notifyFlags = notifyFlags;
options.notifyBlock = notifyBlock;
Expand Down
10 changes: 5 additions & 5 deletions ObjectiveGit/GTCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ NS_ASSUME_NONNULL_BEGIN

@interface GTCommit : GTObject {}

@property (nonatomic, readonly, strong, nullable) GTSignature *author;
@property (nonatomic, readonly, strong, nullable) GTSignature *committer;
@property (nonatomic, readonly, strong) GTSignature * _Nullable author;
@property (nonatomic, readonly, strong) GTSignature * _Nullable committer;
@property (nonatomic, readonly, copy) NSArray<GTCommit *> *parents;
@property (nonatomic, readonly, nullable) NSString *message;
@property (nonatomic, readonly) NSString * _Nullable message;
@property (nonatomic, readonly) NSString *messageDetails;
@property (nonatomic, readonly) NSString *messageSummary;
@property (nonatomic, readonly) NSDate *commitDate;
@property (nonatomic, readonly) NSTimeZone *commitTimeZone;
@property (nonatomic, readonly, nullable) GTTree *tree;
@property (nonatomic, readonly) GTTree * _Nullable tree;

/// Is this a merge commit?
@property (nonatomic, readonly, assign, getter = isMerge) BOOL merge;
Expand All @@ -64,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
///
/// Returns an index which represents the result of the merge, or nil if an error
/// occurred.
- (nullable GTIndex *)merge:(GTCommit *)otherCommit error:(NSError **)error;
- (GTIndex * _Nullable)merge:(GTCommit *)otherCommit error:(NSError **)error;

@end

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTConfiguration+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
/// repository - The repository in which the config resides. May be nil.
///
/// Returns the initialized object.
- (nullable instancetype)initWithGitConfig:(nonnull git_config *)config repository:(nullable GTRepository *)repository NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable)initWithGitConfig:(git_config * _Nonnull)config repository:(GTRepository * _Nullable)repository NS_DESIGNATED_INITIALIZER;

@end
8 changes: 4 additions & 4 deletions ObjectiveGit/GTConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ NS_ASSUME_NONNULL_BEGIN

@interface GTConfiguration : NSObject

@property (nonatomic, readonly, strong, nullable) GTRepository *repository;
@property (nonatomic, readonly, strong) GTRepository * _Nullable repository;
@property (nonatomic, readonly, copy) NSArray<NSString *> *configurationKeys;

/// The GTRemotes in the config. If the configuration isn't associated with any
/// repository, this will always be nil.
@property (nonatomic, readonly, copy, nullable) NSArray<GTRemote *> *remotes;
@property (nonatomic, readonly, copy) NSArray<GTRemote *> * _Nullable remotes;

- (instancetype)init NS_UNAVAILABLE;

/// Creates and returns a configuration which includes the global, XDG, and
/// system configurations.
+ (nullable instancetype)defaultConfiguration;
+ (instancetype _Nullable)defaultConfiguration;

/// The underlying `git_config` object.
- (git_config *)git_config __attribute__((objc_returns_inner_pointer));

- (void)setString:(NSString *)s forKey:(NSString *)key;
- (nullable NSString *)stringForKey:(NSString *)key;
- (NSString * _Nullable)stringForKey:(NSString *)key;

- (void)setBool:(BOOL)b forKey:(NSString *)key;
- (BOOL)boolForKey:(NSString *)key;
Expand Down
8 changes: 4 additions & 4 deletions ObjectiveGit/GTCredential.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
/// type - the credential types allowed by the operation.
/// URL - the URL the operation is authenticating against.
/// userName - the user name provided by the operation. Can be nil, and might be ignored.
- (GTCredential * _Nullable)credentialForType:(GTCredentialType)type URL:(nullable NSString *)URL userName:(nullable NSString *)userName;
- (GTCredential * _Nullable)credentialForType:(GTCredentialType)type URL:(NSString * _Nullable)URL userName:(NSString * _Nullable)userName;
@end

/// The GTCredential class is used to provide authentication data.
Expand All @@ -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
+ (nullable instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error;
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)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
+ (nullable instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(nullable NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(nullable NSString *)passphrase error:(NSError **)error;
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL * _Nullable)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString * _Nullable)passphrase error:(NSError **)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
+ (nullable instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(nullable NSString *)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(nullable NSString *)passphrase error:(NSError **)error;
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError **)error;

/// The underlying `git_cred` object.
- (git_cred *)git_cred __attribute__((objc_returns_inner_pointer));
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTDiff+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
/// provides a pointer to that structure to the given `block`.
///
/// Returns the result of invoking `block`.
+ (int)handleParsedOptionsDictionary:(nullable NSDictionary *)dictionary usingBlock:(nonnull int (^)(git_diff_options * __null_unspecified optionsStruct))block;
+ (int)handleParsedOptionsDictionary:(NSDictionary * _Nullable)dictionary usingBlock:(int (^ _Nonnull)(git_diff_options * _Null_unspecified optionsStruct))block;

@end
Loading

0 comments on commit ff3bd77

Please sign in to comment.