Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ObjectiveGit/Categories/NSData+Git.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
/// behavior of the returned buffer is undefined.
- (git_buf)git_buf;

/// Creates a git_buf from the data and then checks if the buffer contains a NUL
/// byte.
/// Returns whether the data contains a NUL byte.
- (BOOL)git_containsNUL;

/// Creates a git_buf from the data and then checks if the buffer looks like it
/// contains binary data.
/// Returns whether the data looks like it contains binary data.
- (BOOL)git_isBinary;

@end
8 changes: 3 additions & 5 deletions ObjectiveGit/Categories/NSData+Git.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#import "NSData+Git.h"
#import "NSError+Git.h"

#import "git2/blob.h"
#import "git2/errors.h"
#import "git2/deprecated.h"

@implementation NSData (Git)

Expand Down Expand Up @@ -46,13 +46,11 @@ - (git_buf)git_buf {
}

- (BOOL)git_containsNUL {
git_buf buffer = self.git_buf;
return git_buf_contains_nul(&buffer) > 0;
return memchr(self.bytes, '\0', self.length) != NULL;
}

- (BOOL)git_isBinary {
git_buf buffer = self.git_buf;
return git_buf_is_binary(&buffer) > 0;
return git_blob_data_is_binary(self.bytes, self.length) > 0;
}

@end
Loading