Skip to content

Commit bbea49d

Browse files
author
David Catmull
committed
Use asserts because GTOID.SHA should never be nil.
1 parent fc9e959 commit bbea49d

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

ObjectiveGit/GTOID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
1616
@interface GTOID : NSObject <NSCopying>
1717

1818
/// The SHA pointed to by the OID.
19-
@property (nonatomic, readonly, copy, nullable) NSString *SHA;
19+
@property (nonatomic, readonly, copy) NSString *SHA;
2020

2121
/// Is the OID all zero? This usually indicates that the object has not been
2222
/// inserted into the ODB yet.

ObjectiveGit/GTOID.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ - (const git_oid *)git_oid {
2828

2929
- (NSString *)SHA {
3030
char *SHA = malloc(GIT_OID_HEXSZ);
31-
if (SHA == NULL) return nil;
31+
NSAssert(SHA != NULL, @"Failed to malloc SHA string");
3232

3333
git_oid_fmt(SHA, self.git_oid);
3434

3535
NSString *str = [[NSString alloc] initWithBytesNoCopy:SHA length:GIT_OID_HEXSZ encoding:NSUTF8StringEncoding freeWhenDone:YES];
36-
if (str == nil) free(SHA);
36+
NSAssert(str != nil, @"Failed to allocate SHA string");
3737
return str;
3838
}
3939

ObjectiveGit/GTRepository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
167167
@interface GTRepository : NSObject
168168

169169
/// The file URL for the repository's working directory.
170+
/// Returns nil for a bare repository.
170171
@property (nonatomic, readonly, strong, nullable) NSURL *fileURL;
171172
/// The file URL for the repository's .git directory.
172173
@property (nonatomic, readonly, strong, nullable) NSURL *gitDirectoryURL;

0 commit comments

Comments
 (0)