From 5079554f475524c1df33b02c6bae53c66eec367b Mon Sep 17 00:00:00 2001 From: Gonen <830775+goneng@users.noreply.github.com> Date: Sat, 19 Sep 2026 01:01:10 +0300 Subject: [PATCH] Stop NSData+Git depending on the deprecated buffer API The two checks on the category were the file's only reason to import git2/deprecated.h, and neither needs a git_buf at all. * Ask libgit2 about the bytes directly, with git_blob_data_is_binary, which is what git_buf_is_binary forwards to. * Look for the NUL byte with memchr, which is all git_buf_contains_nul does once its two wrappers are unwound. * Drop the import, and the header comments describing a git_buf that is no longer built. --- ObjectiveGit/Categories/NSData+Git.h | 6 ++---- ObjectiveGit/Categories/NSData+Git.m | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ObjectiveGit/Categories/NSData+Git.h b/ObjectiveGit/Categories/NSData+Git.h index 9054bbb10..d042332f8 100644 --- a/ObjectiveGit/Categories/NSData+Git.h +++ b/ObjectiveGit/Categories/NSData+Git.h @@ -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 diff --git a/ObjectiveGit/Categories/NSData+Git.m b/ObjectiveGit/Categories/NSData+Git.m index 42d31f218..592a4b5e6 100644 --- a/ObjectiveGit/Categories/NSData+Git.m +++ b/ObjectiveGit/Categories/NSData+Git.m @@ -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) @@ -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