Skip to content

Commit ff3bd77

Browse files
authored
Merge pull request #582 from alehed/new_nullable_annotation
New nullable annotation
2 parents ba47643 + 1279d2f commit ff3bd77

Some content is hidden

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

57 files changed

+285
-285
lines changed

ObjectiveGit/GTBlame.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
2424
/// blame - A git_blame to wrap. May not be NULL.
2525
///
2626
/// Returns a blame, or nil if initialization failed.
27-
- (nullable instancetype)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;
27+
- (instancetype _Nullable)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;
2828

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

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

5757
/// The underlying `git_blame` object.
5858
- (git_blame *)git_blame __attribute__((objc_returns_inner_pointer));

ObjectiveGit/GTBlameHunk.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ NS_ASSUME_NONNULL_BEGIN
2424
/// hunk - A git_blame_hunk to wrap. May not be NULL.
2525
///
2626
/// Returns a blame hunk, or nil if initialization failed.
27-
- (nullable instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;
27+
- (instancetype _Nullable)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;
2828

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

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

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

3939
/// The path of the file in the original commit.
4040
@property (nonatomic, readonly, copy) NSString *originalPath;

ObjectiveGit/GTBlob.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
4343
/// error - Will be set if an error occurs. This may be nil.
4444
///
4545
/// Return a newly created blob object, or nil if an error occurs.
46-
+ (nullable instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
46+
+ (instancetype _Nullable)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
4747

4848
/// Creates a new blob from the given data.
4949
///
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
5454
/// error - Will be set if an error occurs. This may be nil.
5555
///
5656
/// Return a newly created blob object, or nil if an error occurs.
57-
+ (nullable instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
57+
+ (instancetype _Nullable)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
5858

5959
/// Creates a new blob given an NSURL to a file.
6060
///
@@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
6565
/// error - Will be set if an error occurs. This may be nil.
6666
///
6767
/// Return a newly created blob object, or nil if an error occurs.
68-
+ (nullable instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
68+
+ (instancetype _Nullable)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
6969

7070
/// Creates a new blob from the given string.
7171
///
@@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
7676
/// error - Will be set if an error occurs. This may be nil.
7777
///
7878
/// Return a newly created blob object, or nil if an error occurs.
79-
- (nullable instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
79+
- (instancetype _Nullable)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
8080

8181
/// Creates a new blob from the passed data.
8282
///
@@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN
8787
/// error - Will be set if an error occurs. This may be nil.
8888
///
8989
/// Returns a newly created blob object, or nil if an error occurs.
90-
- (nullable instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
90+
- (instancetype _Nullable)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
9191

9292
/// Creates a new blob from the specified file.
9393
///
@@ -98,22 +98,22 @@ NS_ASSUME_NONNULL_BEGIN
9898
/// error - Will be set if an error occurs. This may be nil.
9999
///
100100
/// Returns a newly created blob object, or nil if an error occurs.
101-
- (nullable instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
101+
- (instancetype _Nullable)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
102102

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

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

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

118118
@end
119119

ObjectiveGit/GTBranch.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ NS_ASSUME_NONNULL_BEGIN
4343
/// equal.
4444
@interface GTBranch : NSObject
4545

46-
@property (nonatomic, readonly, nullable) NSString *name;
47-
@property (nonatomic, readonly, nullable) NSString *shortName;
48-
@property (nonatomic, copy, readonly, nullable) GTOID *OID;
49-
@property (nonatomic, readonly, nullable) NSString *remoteName;
46+
@property (nonatomic, readonly) NSString * _Nullable name;
47+
@property (nonatomic, readonly) NSString * _Nullable shortName;
48+
@property (nonatomic, copy, readonly) GTOID * _Nullable OID;
49+
@property (nonatomic, readonly) NSString * _Nullable remoteName;
5050
@property (nonatomic, readonly) GTBranchType branchType;
5151
@property (nonatomic, readonly, strong) GTRepository *repository;
5252
@property (nonatomic, readonly, strong) GTReference *reference;
@@ -62,22 +62,22 @@ NS_ASSUME_NONNULL_BEGIN
6262
/// repo - The repository containing the branch. Must not be nil.
6363
///
6464
/// Returns the initialized receiver.
65-
- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
65+
- (instancetype _Nullable)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
6666

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

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

8282
/// Count all commits in this branch
8383
///
@@ -92,15 +92,15 @@ NS_ASSUME_NONNULL_BEGIN
9292
/// error - If not NULL, set to any error that occurs.
9393
///
9494
/// Returns a (possibly empty) array of GTCommits, or nil if an error occurs.
95-
- (nullable NSArray<GTCommit *> *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
95+
- (NSArray<GTCommit *> * _Nullable)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
9696

9797
/// Deletes the local branch and nils out the reference.
9898
- (BOOL)deleteWithError:(NSError **)error;
9999

100100
/// If the receiver is a local branch, looks up and returns its tracking branch.
101101
/// If the receiver is a remote branch, returns self. If no tracking branch was
102102
/// found, returns nil and sets `success` to YES.
103-
- (nullable GTBranch *)trackingBranchWithError:(NSError **)error success:(nullable BOOL *)success;
103+
- (GTBranch * _Nullable)trackingBranchWithError:(NSError **)error success:(BOOL * _Nullable)success;
104104

105105
/// Update the tracking branch.
106106
///
@@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
109109
/// error - The error if one occurred.
110110
///
111111
/// Returns whether it was successful.
112-
- (BOOL)updateTrackingBranch:(nullable GTBranch *)trackingBranch error:(NSError **)error;
112+
- (BOOL)updateTrackingBranch:(GTBranch * _Nullable)trackingBranch error:(NSError **)error;
113113

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

124124
/// Calculate the ahead/behind count from this branch to the given branch.
125125
///

ObjectiveGit/GTBranch.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ + (NSString *)remoteNamePrefix {
6565
return @"refs/remotes/";
6666
}
6767

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

@@ -74,7 +74,7 @@ - (instancetype)init {
7474
return nil;
7575
}
7676

77-
- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
77+
- (instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
7878
NSParameterAssert(ref != nil);
7979
NSParameterAssert(repo != nil);
8080

ObjectiveGit/GTCheckoutOptions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef NS_OPTIONS(NSInteger, GTCheckoutNotifyFlags) {
6464
/// @param notifyBlock A block that will be called for each event, @see `notifyFlags`.
6565
///
6666
/// @return A newly-initialized GTCheckoutOptions object.
67-
+ (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;
67+
+ (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;
6868

6969
/// Create a checkout options object.
7070
/// @see +checkoutOptionsWithStrategy:notifyFlags:progressBlock:notifyBlock:

ObjectiveGit/GTCheckoutOptions.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
typedef void (^GTCheckoutProgressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);
1717

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

2121

2222
@interface GTCheckoutOptions () {
@@ -26,7 +26,7 @@ @interface GTCheckoutOptions () {
2626

2727
@implementation GTCheckoutOptions
2828

29-
+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(nullable GTCheckoutProgressBlock)progressBlock notifyBlock:(nullable GTCheckoutNotifyBlock)notifyBlock {
29+
+ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(GTCheckoutProgressBlock _Nullable)progressBlock notifyBlock:( GTCheckoutNotifyBlock _Nullable)notifyBlock {
3030
GTCheckoutOptions *options = [self checkoutOptionsWithStrategy:strategy];
3131
options.notifyFlags = notifyFlags;
3232
options.notifyBlock = notifyBlock;

ObjectiveGit/GTCommit.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ NS_ASSUME_NONNULL_BEGIN
3939

4040
@interface GTCommit : GTObject {}
4141

42-
@property (nonatomic, readonly, strong, nullable) GTSignature *author;
43-
@property (nonatomic, readonly, strong, nullable) GTSignature *committer;
42+
@property (nonatomic, readonly, strong) GTSignature * _Nullable author;
43+
@property (nonatomic, readonly, strong) GTSignature * _Nullable committer;
4444
@property (nonatomic, readonly, copy) NSArray<GTCommit *> *parents;
45-
@property (nonatomic, readonly, nullable) NSString *message;
45+
@property (nonatomic, readonly) NSString * _Nullable message;
4646
@property (nonatomic, readonly) NSString *messageDetails;
4747
@property (nonatomic, readonly) NSString *messageSummary;
4848
@property (nonatomic, readonly) NSDate *commitDate;
4949
@property (nonatomic, readonly) NSTimeZone *commitTimeZone;
50-
@property (nonatomic, readonly, nullable) GTTree *tree;
50+
@property (nonatomic, readonly) GTTree * _Nullable tree;
5151

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

6969
@end
7070

ObjectiveGit/GTConfiguration+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/// repository - The repository in which the config resides. May be nil.
1919
///
2020
/// Returns the initialized object.
21-
- (nullable instancetype)initWithGitConfig:(nonnull git_config *)config repository:(nullable GTRepository *)repository NS_DESIGNATED_INITIALIZER;
21+
- (instancetype _Nullable)initWithGitConfig:(git_config * _Nonnull)config repository:(GTRepository * _Nullable)repository NS_DESIGNATED_INITIALIZER;
2222

2323
@end

ObjectiveGit/GTConfiguration.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ NS_ASSUME_NONNULL_BEGIN
1717

1818
@interface GTConfiguration : NSObject
1919

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

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

2727
- (instancetype)init NS_UNAVAILABLE;
2828

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

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

3636
- (void)setString:(NSString *)s forKey:(NSString *)key;
37-
- (nullable NSString *)stringForKey:(NSString *)key;
37+
- (NSString * _Nullable)stringForKey:(NSString *)key;
3838

3939
- (void)setBool:(BOOL)b forKey:(NSString *)key;
4040
- (BOOL)boolForKey:(NSString *)key;

ObjectiveGit/GTCredential.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
4646
/// type - the credential types allowed by the operation.
4747
/// URL - the URL the operation is authenticating against.
4848
/// userName - the user name provided by the operation. Can be nil, and might be ignored.
49-
- (GTCredential * _Nullable)credentialForType:(GTCredentialType)type URL:(nullable NSString *)URL userName:(nullable NSString *)userName;
49+
- (GTCredential * _Nullable)credentialForType:(GTCredentialType)type URL:(NSString * _Nullable)URL userName:(NSString * _Nullable)userName;
5050
@end
5151

5252
/// The GTCredential class is used to provide authentication data.
@@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
6060
/// error - If not NULL, set to any errors that occur.
6161
///
6262
/// Return a new GTCredential instance, or nil if an error occurred
63-
+ (nullable instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error;
63+
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error;
6464

6565
/// Create a credential object from a SSH keyfile
6666
///
@@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
7272
/// error - If not NULL, set to any errors that occur.
7373
///
7474
/// Return a new GTCredential instance, or nil if an error occurred
75-
+ (nullable instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(nullable NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(nullable NSString *)passphrase error:(NSError **)error;
75+
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL * _Nullable)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString * _Nullable)passphrase error:(NSError **)error;
7676

7777
/// Create a credential object from a SSH keyfile data string
7878
///
@@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
8484
/// error - If not NULL, set to any errors that occur.
8585
///
8686
/// Return a new GTCredential instance, or nil if an error occurred
87-
+ (nullable instancetype)credentialWithUserName:(NSString *)userName publicKeyString:(nullable NSString *)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(nullable NSString *)passphrase error:(NSError **)error;
87+
+ (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError **)error;
8888

8989
/// The underlying `git_cred` object.
9090
- (git_cred *)git_cred __attribute__((objc_returns_inner_pointer));

ObjectiveGit/GTDiff+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
/// provides a pointer to that structure to the given `block`.
1515
///
1616
/// Returns the result of invoking `block`.
17-
+ (int)handleParsedOptionsDictionary:(nullable NSDictionary *)dictionary usingBlock:(nonnull int (^)(git_diff_options * __null_unspecified optionsStruct))block;
17+
+ (int)handleParsedOptionsDictionary:(NSDictionary * _Nullable)dictionary usingBlock:(int (^ _Nonnull)(git_diff_options * _Null_unspecified optionsStruct))block;
1818

1919
@end

0 commit comments

Comments
 (0)