Skip to content

Commit 289a0be

Browse files
author
Ben Chatelain
committed
GTRepository nullability
1 parent 6eec24e commit 289a0be

9 files changed

+179
-77
lines changed

ObjectiveGit/GTRepository+Attributes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "GTRepository.h"
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
@interface GTRepository (Attributes)
1214

1315
/// Look up the value for the attribute of the given name for the given path.
@@ -16,6 +18,8 @@
1618
/// path - The path to use for the lookup. Cannot be nil.
1719
///
1820
/// Returns the value of the attribute or nil.
19-
- (NSString *)attributeWithName:(NSString *)name path:(NSString *)path;
21+
- (nullable NSString *)attributeWithName:(NSString *)name path:(NSString *)path;
2022

2123
@end
24+
25+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Committing.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "GTRepository.h"
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
@interface GTRepository (Committing)
1214

1315
/// Creates a new commit.
@@ -23,10 +25,12 @@
2325
/// error - The error if one occurred.
2426
///
2527
/// Returns the newly created commit, or nil if an error occurred.
26-
- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError **)error;
28+
- (nullable GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message author:(GTSignature *)author committer:(GTSignature *)committer parents:(nullable NSArray *)parents updatingReferenceNamed:(nullable NSString *)refName error:(NSError **)error;
2729

2830
/// Creates a new commit using +createCommitWithTree:message:author:committer:parents:updatingReferenceNamed:error:
2931
/// with -userSignatureForNow as both the author and committer.
30-
- (GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(NSArray *)parents updatingReferenceNamed:(NSString *)refName error:(NSError **)error;
32+
- (nullable GTCommit *)createCommitWithTree:(GTTree *)tree message:(NSString *)message parents:(nullable NSArray *)parents updatingReferenceNamed:(nullable NSString *)refName error:(NSError **)error;
3133

3234
@end
35+
36+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Private.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
#import "GTRepository.h"
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
@interface GTRepository ()
12-
- (id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError **)error;
13-
- (id)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError **)error;
14+
15+
- (nullable id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError **)error;
16+
- (nullable id)lookUpObjectByGitOid:(const git_oid *)oid error:(NSError **)error;
17+
1418
@end
19+
20+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+RemoteOperations.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,32 @@
1313
/// A `GTCredentialProvider`, that will be used to authenticate against the remote.
1414
extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
1515

16+
NS_ASSUME_NONNULL_BEGIN
17+
1618
@interface GTRepository (RemoteOperations)
1719

1820
#pragma mark - Fetch
1921

2022
/// Fetch a remote.
2123
///
22-
/// remote - The remote to fetch from.
23-
/// options - Options applied to the fetch operation.
24+
/// remote - The remote to fetch from. Must not be nil.
25+
/// options - Options applied to the fetch operation. May be nil.
2426
/// Recognized options are :
2527
/// `GTRepositoryRemoteOptionsCredentialProvider`
2628
/// error - The error if one occurred. Can be NULL.
29+
/// progressBlock - Optional callback to receive fetch progress stats during the
30+
/// transfer. May be nil.
2731
///
2832
/// Returns YES if the fetch was successful, NO otherwise (and `error`, if provided,
2933
/// will point to an error describing what happened).
30-
- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(const git_transfer_progress *stats, BOOL *stop))progressBlock;
34+
- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(nullable NSDictionary *)options error:(NSError **)error progress:(nullable void (^)(const git_transfer_progress *stats, BOOL *stop))progressBlock;
3135

3236
/// Enumerate all available fetch head entries.
3337
///
3438
/// error - The error if one ocurred. Can be NULL.
35-
/// block - A block to execute for each FETCH_HEAD entry. `fetchHeadEntry` will be the current
36-
/// fetch head entry. Setting `stop` to YES will cause enumeration to stop after the block returns.
39+
/// block - A block to execute for each FETCH_HEAD entry. `fetchHeadEntry` will
40+
/// be the current fetch head entry. Setting `stop` to YES will cause
41+
/// enumeration to stop after the block returns. Must not be nil.
3742
///
3843
/// Returns YES if the operation succedded, NO otherwise.
3944
- (BOOL)enumerateFetchHeadEntriesWithError:(NSError **)error usingBlock:(void (^)(GTFetchHeadEntry *fetchHeadEntry, BOOL *stop))block;
@@ -42,7 +47,7 @@ extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
4247
///
4348
/// error - The error if one ocurred. Can be NULL.
4449
///
45-
/// Retruns an array with GTFetchHeadEntry objects
50+
/// Retruns a (possibly empty) array with GTFetchHeadEntry objects. Will not be nil.
4651
- (NSArray *)fetchHeadEntriesWithError:(NSError **)error;
4752

4853
#pragma mark - Push
@@ -55,11 +60,11 @@ extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
5560
/// Recognized options are:
5661
/// `GTRepositoryRemoteOptionsCredentialProvider`
5762
/// error - The error if one occurred. Can be NULL.
58-
/// progressBlock - An optional callback for monitoring progress.
63+
/// progressBlock - An optional callback for monitoring progress. May be NULL.
5964
///
6065
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
6166
/// will point to an error describing what happened).
62-
- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
67+
- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(nullable NSDictionary *)options error:(NSError **)error progress:(nullable void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
6368

6469
/// Push an array of branches to a remote.
6570
///
@@ -69,10 +74,12 @@ extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
6974
/// Recognized options are:
7075
/// `GTRepositoryRemoteOptionsCredentialProvider`
7176
/// error - The error if one occurred. Can be NULL.
72-
/// progressBlock - An optional callback for monitoring progress.
77+
/// progressBlock - An optional callback for monitoring progress. May be NULL.
7378
///
7479
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
7580
/// will point to an error describing what happened).
76-
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
81+
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(nullable NSDictionary *)options error:(NSError **)error progress:(nullable void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
7782

7883
@end
84+
85+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Reset.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ typedef NS_ENUM(NSInteger, GTRepositoryResetType) {
1717
GTRepositoryResetTypeHard = GIT_RESET_HARD,
1818
};
1919

20+
NS_ASSUME_NONNULL_BEGIN
21+
2022
@interface GTRepository (Reset)
2123

2224
/// Reset the repository's HEAD to the given commit.
@@ -38,3 +40,5 @@ typedef NS_ENUM(NSInteger, GTRepositoryResetType) {
3840
- (BOOL)resetPathspecs:(NSArray *)pathspecs toCommit:(GTCommit *)commit error:(NSError **)error;
3941

4042
@end
43+
44+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Stashing.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ typedef NS_OPTIONS(NSInteger, GTRepositoryStashFlag) {
1919
GTRepositoryStashFlagIncludeIgnored = GIT_STASH_INCLUDE_IGNORED
2020
};
2121

22+
NS_ASSUME_NONNULL_BEGIN
23+
2224
@interface GTRepository (Stashing)
2325

2426
/// Stash the repository's changes.
@@ -30,14 +32,14 @@ typedef NS_OPTIONS(NSInteger, GTRepositoryStashFlag) {
3032
///
3133
/// Returns a commit representing the stashed changes if successful, or nil
3234
/// otherwise.
33-
- (GTCommit *)stashChangesWithMessage:(NSString *)message flags:(GTRepositoryStashFlag)flags error:(NSError **)error;
35+
- (nullable GTCommit *)stashChangesWithMessage:(nullable NSString *)message flags:(GTRepositoryStashFlag)flags error:(NSError **)error;
3436

3537
/// Enumerate over all the stashes in the repository, from most recent to oldest.
3638
///
3739
/// block - A block to execute for each stash found. `index` will be the zero-based
3840
/// stash index (where 0 is the most recent stash). Setting `stop` to YES
39-
/// will cause enumeration to stop after the block returns.
40-
- (void)enumerateStashesUsingBlock:(void (^)(NSUInteger index, NSString *message, GTOID *oid, BOOL *stop))block;
41+
/// will cause enumeration to stop after the block returns. Must not be nil.
42+
- (void)enumerateStashesUsingBlock:(void (^)(NSUInteger index, NSString * __nullable message, GTOID * __nullable oid, BOOL *stop))block;
4143

4244
/// Drop a stash from the repository's list of stashes.
4345
///
@@ -48,3 +50,5 @@ typedef NS_OPTIONS(NSInteger, GTRepositoryStashFlag) {
4850
- (BOOL)dropStashAtIndex:(NSUInteger)index error:(NSError **)error;
4951

5052
@end
53+
54+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Status.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ typedef enum {
8181
/// Defaults to including all files.
8282
extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey;
8383

84+
NS_ASSUME_NONNULL_BEGIN
85+
8486
@interface GTRepository (Status)
8587

8688
/// `YES` if the working directory has no modified, new, or deleted files.
@@ -111,12 +113,26 @@ extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey;
111113
///
112114
/// Returns `NO` in case of a failure or `YES` if the enumeration completed
113115
/// successfully.
114-
- (BOOL)enumerateFileStatusWithOptions:(NSDictionary *)options error:(NSError **)error usingBlock:(void (^)(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop))block;
116+
- (BOOL)enumerateFileStatusWithOptions:(nullable NSDictionary *)options error:(NSError **)error usingBlock:(nullable void (^)(GTStatusDelta * __nullable headToIndex, GTStatusDelta * __nullable indexToWorkingDirectory, BOOL *stop))block;
115117

116118
/// Query the status of one file
117-
- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(BOOL *)success error:(NSError **)error;
119+
///
120+
/// filePath - A string path relative to the working copy. The must not be nil.
121+
/// success - If not NULL, will be set to indicate success or fail.
122+
/// error - If not nil, set to any error that occurs.
123+
///
124+
/// Returns the combined GTFileStatusFlags for the file.
125+
- (GTFileStatusFlags)statusForFile:(NSString *)filePath success:(nullable BOOL *)success error:(NSError **)error;
118126

119-
/// Should the file be considered as ignored ?
120-
- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSError **)error;
127+
/// Tests the ignore rules to see if the file should be considered as ignored.
128+
///
129+
/// fileURL - A string path relative to the working copy. Must not be nil.
130+
/// success - If not NULL, will be set to indicate success or fail.
131+
/// error - If not nil, set to any error that occurs.
132+
///
133+
/// Returns YES if the file should be ignored; NO otherwise.
134+
- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(nullable BOOL *)success error:(NSError **)error;
121135

122136
@end
137+
138+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)