diff --git a/External/libgit2 b/External/libgit2 index 7a2b969d5..f7164261c 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit 7a2b969d559b83798d93728f24d1729ffc97b717 +Subproject commit f7164261c9bc0a7e0ebf767c584e5192810a8b24 diff --git a/ObjectiveGit/Categories/NSData+Git.m b/ObjectiveGit/Categories/NSData+Git.m index 6498dfbe0..9d02e6eda 100644 --- a/ObjectiveGit/Categories/NSData+Git.m +++ b/ObjectiveGit/Categories/NSData+Git.m @@ -6,6 +6,7 @@ #import "NSError+Git.h" #import "git2/errors.h" +#import "git2/deprecated.h" @implementation NSData (Git) diff --git a/ObjectiveGit/GTBlame.h b/ObjectiveGit/GTBlame.h index 12db9a5c2..30181ff0c 100644 --- a/ObjectiveGit/GTBlame.h +++ b/ObjectiveGit/GTBlame.h @@ -7,6 +7,7 @@ // #import +#import "git2/types.h" #import "git2/blame.h" @class GTBlameHunk; diff --git a/ObjectiveGit/GTBlameHunk.h b/ObjectiveGit/GTBlameHunk.h index 72e3f1764..1c62db8fe 100644 --- a/ObjectiveGit/GTBlameHunk.h +++ b/ObjectiveGit/GTBlameHunk.h @@ -7,6 +7,7 @@ // #import +#import "git2/types.h" #import "git2/blame.h" @class GTOID; diff --git a/ObjectiveGit/GTBlob.m b/ObjectiveGit/GTBlob.m index a1634dcf5..4d7f48bb0 100644 --- a/ObjectiveGit/GTBlob.m +++ b/ObjectiveGit/GTBlob.m @@ -136,7 +136,7 @@ - (NSData *)data { - (NSData *)applyFiltersForPath:(NSString *)path error:(NSError **)error { NSCParameterAssert(path != nil); - git_buf buffer = GIT_BUF_INIT_CONST(0, NULL); + git_buf buffer = GIT_BUF_INIT; int gitError = git_blob_filtered_content(&buffer, self.git_blob, path.UTF8String, 1); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to apply filters for path %@ to blob", path]; diff --git a/ObjectiveGit/GTBranch.m b/ObjectiveGit/GTBranch.m index ec54cbd5d..ee238840b 100644 --- a/ObjectiveGit/GTBranch.m +++ b/ObjectiveGit/GTBranch.m @@ -115,7 +115,7 @@ - (GTOID *)OID { } - (NSString *)remoteName { - git_buf remote_name = GIT_BUF_INIT_CONST(0, NULL); + git_buf remote_name = GIT_BUF_INIT; int gitError = git_branch_remote_name(&remote_name, self.repository.git_repository, self.reference.name.UTF8String); if (gitError != GIT_OK) return nil; diff --git a/ObjectiveGit/GTCredential.h b/ObjectiveGit/GTCredential.h index 560a8ba18..e73989b6f 100644 --- a/ObjectiveGit/GTCredential.h +++ b/ObjectiveGit/GTCredential.h @@ -7,6 +7,7 @@ // #import +#import "git2/deprecated.h" #import "git2/transport.h" /// An enum describing the data needed for authentication. diff --git a/ObjectiveGit/GTCredential.m b/ObjectiveGit/GTCredential.m index 1d3894b44..d79e808c0 100644 --- a/ObjectiveGit/GTCredential.m +++ b/ObjectiveGit/GTCredential.m @@ -105,8 +105,7 @@ int GTCredentialAcquireCallback(git_cred **git_cred, const char *url, const char GTCredentialProvider *provider = info->credProvider; if (provider == nil) { - git_error_set_str(GIT_EUSER, "No GTCredentialProvider set, but authentication was requested."); - return GIT_ERROR; + return GIT_EAUTH; } NSString *URL = (url != NULL ? @(url) : @""); @@ -114,8 +113,7 @@ int GTCredentialAcquireCallback(git_cred **git_cred, const char *url, const char GTCredential *cred = [provider credentialForType:(GTCredentialType)allowed_types URL:URL userName:userName]; if (cred == nil) { - git_error_set_str(GIT_EUSER, "GTCredentialProvider failed to provide credentials."); - return GIT_ERROR; + return GIT_EAUTH; } *git_cred = cred.git_cred; diff --git a/ObjectiveGit/GTDiffPatch.m b/ObjectiveGit/GTDiffPatch.m index 715db5a13..dad33f8dc 100644 --- a/ObjectiveGit/GTDiffPatch.m +++ b/ObjectiveGit/GTDiffPatch.m @@ -65,7 +65,7 @@ - (NSUInteger)sizeWithContext:(BOOL)includeContext hunkHeaders:(BOOL)includeHunk } - (NSData *)patchData { - git_buf buf = GIT_BUF_INIT_CONST(0, NULL); + git_buf buf = GIT_BUF_INIT; git_patch_to_buf(&buf, self.git_patch); NSData *buffer = [[NSData alloc] initWithBytes:buf.ptr length:buf.size]; diff --git a/ObjectiveGit/GTFilterList.m b/ObjectiveGit/GTFilterList.m index 1780293a4..042cff922 100644 --- a/ObjectiveGit/GTFilterList.m +++ b/ObjectiveGit/GTFilterList.m @@ -54,7 +54,7 @@ - (NSData *)applyToData:(NSData *)inputData error:(NSError **)error { NSParameterAssert(inputData != nil); git_buf input = inputData.git_buf; - git_buf output = GIT_BUF_INIT_CONST(0, NULL); + git_buf output = GIT_BUF_INIT; int gitError = git_filter_list_apply_to_data(&output, self.git_filter_list, &input); if (gitError != GIT_OK) { @@ -69,7 +69,7 @@ - (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)re NSParameterAssert(relativePath != nil); NSParameterAssert(repository != nil); - git_buf output = GIT_BUF_INIT_CONST(0, NULL); + git_buf output = GIT_BUF_INIT; // fixme: This is a workaround for an issue where `git_filter_list_apply_to_file` // will not resolve relative paths against the worktree. It should be reverted when // libgit2 has been updated to resolve that. @@ -87,7 +87,7 @@ - (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)re - (NSData *)applyToBlob:(GTBlob *)blob error:(NSError **)error { NSParameterAssert(blob != nil); - git_buf output = GIT_BUF_INIT_CONST(0, NULL); + git_buf output = GIT_BUF_INIT; int gitError = git_filter_list_apply_to_blob(&output, self.git_filter_list, blob.git_blob); if (gitError != GIT_OK) { diff --git a/ObjectiveGit/GTNote.h b/ObjectiveGit/GTNote.h index 008b78a5a..9c1c74ca8 100644 --- a/ObjectiveGit/GTNote.h +++ b/ObjectiveGit/GTNote.h @@ -28,7 +28,9 @@ // #import -#import "git2/oid.h" +#import "git2/types.h" +#import "git2/notes.h" +#import "git2/repository.h" @class GTSignature; @class GTRepository; @@ -88,4 +90,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - diff --git a/ObjectiveGit/GTOID.m b/ObjectiveGit/GTOID.m index 8010c2885..23412df4a 100644 --- a/ObjectiveGit/GTOID.m +++ b/ObjectiveGit/GTOID.m @@ -29,7 +29,7 @@ - (const git_oid *)git_oid { - (NSString *)SHA { char *SHA = git_oid_tostr_s(self.git_oid); NSString *str = [[NSString alloc] initWithBytes:SHA - length:GIT_OID_HEXSZ + length:GIT_OID_SHA1_HEXSIZE encoding:NSUTF8StringEncoding]; NSAssert(str != nil, @"Failed to create SHA string"); return str; @@ -98,7 +98,7 @@ + (instancetype)oidWithSHACString:(const char *)SHA { } - (BOOL)isZero { - return git_oid_iszero(self.git_oid) != 0; + return git_oid_is_zero(self.git_oid) != 0; } #pragma mark NSObject @@ -109,7 +109,7 @@ - (NSString *)description { - (NSUInteger)hash { // Hash the raw OID. - NSData *data = [[NSData alloc] initWithBytesNoCopy:_git_oid.id length:GIT_OID_RAWSZ freeWhenDone:NO]; + NSData *data = [[NSData alloc] initWithBytesNoCopy:_git_oid.id length:GIT_OID_SHA1_SIZE freeWhenDone:NO]; return data.hash; } diff --git a/ObjectiveGit/GTRepository+Blame.h b/ObjectiveGit/GTRepository+Blame.h index 603274f25..1b3dec2cd 100644 --- a/ObjectiveGit/GTRepository+Blame.h +++ b/ObjectiveGit/GTRepository+Blame.h @@ -9,6 +9,7 @@ #import #import "GTRepository.h" +#import "git2/types.h" #import "git2/blame.h" @class GTBlame; diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index b57430b50..5ecd113c0 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -38,6 +38,7 @@ #import "git2/checkout.h" #import "git2/repository.h" #import "git2/transport.h" +#import "git2/deprecated.h" #import "git2/sys/transport.h" @class GTBlob; @@ -58,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN /// Transport flags sent as options to +cloneFromURL... method typedef NS_OPTIONS(NSInteger, GTTransportFlags) { - GTTransportFlagsNone = GIT_TRANSPORTFLAGS_NONE + GTTransportFlagsNone = 0 }; /// An `NSNumber` wrapped `GTTransportFlags`, documented above. diff --git a/script/update_libgit2 b/script/update_libgit2 index 3152c4463..7037c764f 100755 --- a/script/update_libgit2 +++ b/script/update_libgit2 @@ -28,8 +28,9 @@ PATH="$ARCH_PREFIX/bin:$PATH" cmake --version cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ - -DBUILD_CLAR:BOOL=OFF \ - -DTHREADSAFE:BOOL=ON \ + -DBUILD_TESTS:BOOL=OFF \ + -DBUILD_CLI:BOOL=OFF \ + -DUSE_SSH=libssh2 \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ .. cmake --build .