From 42260d190d25df4853a3c5bcd6bd044d777e5bd3 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Fri, 8 Feb 2019 23:36:17 +0100 Subject: [PATCH 1/2] Update to libgit2 1.0.0 --- External/libgit2 | 2 +- ObjectiveGit/GTCredential+Private.h | 2 +- ObjectiveGit/GTCredential.h | 14 +++++++------- ObjectiveGit/GTRepository.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/External/libgit2 b/External/libgit2 index 7a2b969d5..7d3c7057f 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit 7a2b969d559b83798d93728f24d1729ffc97b717 +Subproject commit 7d3c7057f0e774aecd6fc4ef8333e69e5c4873e0 diff --git a/ObjectiveGit/GTCredential+Private.h b/ObjectiveGit/GTCredential+Private.h index 866b389a7..33a546359 100644 --- a/ObjectiveGit/GTCredential+Private.h +++ b/ObjectiveGit/GTCredential+Private.h @@ -27,4 +27,4 @@ typedef struct { __unsafe_unretained GTCredentialProvider *credProvider; } GTCredentialAcquireCallbackInfo; -int GTCredentialAcquireCallback(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); +int GTCredentialAcquireCallback(git_credential **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); diff --git a/ObjectiveGit/GTCredential.h b/ObjectiveGit/GTCredential.h index 560a8ba18..a79bee1e2 100644 --- a/ObjectiveGit/GTCredential.h +++ b/ObjectiveGit/GTCredential.h @@ -10,11 +10,11 @@ #import "git2/transport.h" /// An enum describing the data needed for authentication. -/// See `git_credtype_t`. +/// See `git_credential_t`. typedef NS_ENUM(NSInteger, GTCredentialType) { - GTCredentialTypeUserPassPlaintext = GIT_CREDTYPE_USERPASS_PLAINTEXT, - GTCredentialTypeSSHKey = GIT_CREDTYPE_SSH_KEY, - GTCredentialTypeSSHCustom = GIT_CREDTYPE_SSH_CUSTOM, + GTCredentialTypeUserPassPlaintext = GIT_CREDENTIAL_USERPASS_PLAINTEXT, + GTCredentialTypeSSHKey = GIT_CREDENTIAL_SSH_KEY, + GTCredentialTypeSSHCustom = GIT_CREDENTIAL_SSH_CUSTOM, }; NS_ASSUME_NONNULL_BEGIN @@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// The GTCredential class is used to provide authentication data. -/// It acts as a wrapper around `git_cred` objects. +/// It acts as a wrapper around `git_credential` objects. @interface GTCredential : NSObject /// Create a credential object from a username/password pair. @@ -86,8 +86,8 @@ NS_ASSUME_NONNULL_BEGIN /// Return a new GTCredential instance, or nil if an error occurred + (instancetype _Nullable)credentialWithUserName:(NSString *)userName publicKeyString:(NSString * _Nullable)publicKeyString privateKeyString:(NSString *)privateKeyString passphrase:(NSString * _Nullable)passphrase error:(NSError **)error; -/// The underlying `git_cred` object. -- (git_cred *)git_cred __attribute__((objc_returns_inner_pointer)); +/// The underlying `git_credential` object. +- (git_credential *)git_credential __attribute__((objc_returns_inner_pointer)); @end diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index b57430b50..28079183b 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -239,7 +239,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) { /// May be NULL. /// /// returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful. -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock; ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_indexer_progress *, BOOL *stop))transferProgressBlock; /// Lookup objects in the repo by oid or sha1 - (id _Nullable)lookUpObjectByOID:(GTOID *)oid objectType:(GTObjectType)type error:(NSError **)error; From b366a22d7aa326625f85cec91f5e30cfe9386941 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Wed, 9 Feb 2022 13:30:43 +0100 Subject: [PATCH 2/2] More changes --- ObjectiveGit/GTOID.m | 2 +- ObjectiveGit/GTRepository+Merging.m | 8 ++++---- ObjectiveGit/GTRepository+Pull.h | 2 +- ObjectiveGit/GTRepository+RemoteOperations.h | 2 +- ObjectiveGit/GTRepository+RemoteOperations.m | 6 +++--- ObjectiveGit/GTRepository.m | 6 +++--- ObjectiveGitTests/GTRemoteSpec.m | 2 +- ObjectiveGitTests/GTRepository+PullSpec.m | 10 +++++----- ObjectiveGitTests/GTRepositorySpec.m | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ObjectiveGit/GTOID.m b/ObjectiveGit/GTOID.m index 8010c2885..57bb06867 100644 --- a/ObjectiveGit/GTOID.m +++ b/ObjectiveGit/GTOID.m @@ -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 diff --git a/ObjectiveGit/GTRepository+Merging.m b/ObjectiveGit/GTRepository+Merging.m index f7b9837df..3832024f6 100644 --- a/ObjectiveGit/GTRepository+Merging.m +++ b/ObjectiveGit/GTRepository+Merging.m @@ -20,7 +20,7 @@ #import "GTOdbObject.h" #import "GTObjectDatabase.h" -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *stats, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *stats, BOOL *stop); @implementation GTRepository (Merging) @@ -181,7 +181,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize the ancestor's merge file input git_merge_file_input ancestorInput; - int gitError = git_merge_file_init_input(&ancestorInput, GIT_MERGE_FILE_INPUT_VERSION); + int gitError = git_merge_file_input_init(&ancestorInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input for ancestor"]; return nil; @@ -199,7 +199,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize our merge file input git_merge_file_input ourInput; - gitError = git_merge_file_init_input(&ourInput, GIT_MERGE_FILE_INPUT_VERSION); + gitError = git_merge_file_options_init(&ourInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input for our side"]; return nil; @@ -217,7 +217,7 @@ - (NSString * _Nullable)contentsOfDiffWithAncestor:(GTIndexEntry *)ancestor ourS // initialize their merge file input git_merge_file_input theirInput; - gitError = git_merge_file_init_input(&theirInput, GIT_MERGE_FILE_INPUT_VERSION); + gitError = git_merge_file_input_init(&theirInput, GIT_MERGE_FILE_INPUT_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create merge file input other side"]; return nil; diff --git a/ObjectiveGit/GTRepository+Pull.h b/ObjectiveGit/GTRepository+Pull.h index cbc1f74fd..939930e20 100644 --- a/ObjectiveGit/GTRepository+Pull.h +++ b/ObjectiveGit/GTRepository+Pull.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *progress, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *progress, BOOL *stop); @interface GTRepository (Pull) diff --git a/ObjectiveGit/GTRepository+RemoteOperations.h b/ObjectiveGit/GTRepository+RemoteOperations.h index d93ebaad7..0e292dda1 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.h +++ b/ObjectiveGit/GTRepository+RemoteOperations.h @@ -51,7 +51,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) { /// /// Returns YES if the fetch was successful, NO otherwise (and `error`, if provided, /// will point to an error describing what happened). -- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(const git_transfer_progress *stats, BOOL *stop))progressBlock; +- (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary * _Nullable)options error:(NSError **)error progress:(void (^ _Nullable)(const git_indexer_progress *stats, BOOL *stop))progressBlock; /// Enumerate all available fetch head entries. /// diff --git a/ObjectiveGit/GTRepository+RemoteOperations.m b/ObjectiveGit/GTRepository+RemoteOperations.m index 57c92096a..7865d31cb 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.m +++ b/ObjectiveGit/GTRepository+RemoteOperations.m @@ -30,7 +30,7 @@ NSString *const GTRepositoryRemoteOptionsDownloadTags = @"GTRepositoryRemoteOptionsDownloadTags"; NSString *const GTRepositoryRemoteOptionsPushNotes = @"GTRepositoryRemoteOptionsPushNotes"; -typedef void (^GTRemoteFetchTransferProgressBlock)(const git_transfer_progress *stats, BOOL *stop); +typedef void (^GTRemoteFetchTransferProgressBlock)(const git_indexer_progress *stats, BOOL *stop); typedef void (^GTRemotePushTransferProgressBlock)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop); @implementation GTRepository (RemoteOperations) @@ -45,7 +45,7 @@ @implementation GTRepository (RemoteOperations) git_direction direction; } GTRemoteConnectionInfo; -int GTRemoteFetchTransferProgressCallback(const git_transfer_progress *stats, void *payload) { +int GTRemoteFetchTransferProgressCallback(const git_indexer_progress *stats, void *payload) { GTRemoteConnectionInfo *info = payload; BOOL stop = NO; @@ -281,7 +281,7 @@ - (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions git_push_options push_options = GIT_PUSH_OPTIONS_INIT; - gitError = git_push_init_options(&push_options, GIT_PUSH_OPTIONS_VERSION); + gitError = git_push_options_init(&push_options, GIT_PUSH_OPTIONS_VERSION); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to init push options"]; return NO; diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index 2af904d8e..035a2ca66 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -214,9 +214,9 @@ - (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceiling } -typedef void(^GTTransferProgressBlock)(const git_transfer_progress *progress, BOOL *stop); +typedef void(^GTTransferProgressBlock)(const git_indexer_progress *progress, BOOL *stop); -static int transferProgressCallback(const git_transfer_progress *progress, void *payload) { +static int transferProgressCallback(const git_indexer_progress *progress, void *payload) { if (payload == NULL) return 0; struct GTClonePayload *pld = payload; if (pld->transferProgressBlock == NULL) return 0; @@ -244,7 +244,7 @@ static int remoteCreate(git_remote **remote, git_repository *repo, const char *n git_remote_callbacks remoteCallbacks; }; -+ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_transfer_progress *, BOOL *stop))transferProgressBlock { ++ (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL options:(NSDictionary * _Nullable)options error:(NSError **)error transferProgressBlock:(void (^ _Nullable)(const git_indexer_progress *, BOOL *stop))transferProgressBlock { git_clone_options cloneOptions = GIT_CLONE_OPTIONS_INIT; diff --git a/ObjectiveGitTests/GTRemoteSpec.m b/ObjectiveGitTests/GTRemoteSpec.m index e7ac77891..0269a3f67 100644 --- a/ObjectiveGitTests/GTRemoteSpec.m +++ b/ObjectiveGitTests/GTRemoteSpec.m @@ -180,7 +180,7 @@ __block unsigned int receivedObjects = 0; __block BOOL transferProgressed = NO; - BOOL success = [fetchingRepo fetchRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *stats, BOOL *stop) { + BOOL success = [fetchingRepo fetchRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *stats, BOOL *stop) { receivedObjects += stats->received_objects; transferProgressed = YES; }]; diff --git a/ObjectiveGitTests/GTRepository+PullSpec.m b/ObjectiveGitTests/GTRepository+PullSpec.m index 3c36ebde6..77eb77126 100644 --- a/ObjectiveGitTests/GTRepository+PullSpec.m +++ b/ObjectiveGitTests/GTRepository+PullSpec.m @@ -79,7 +79,7 @@ // Pull __block BOOL transferProgressed = NO; - BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) { + BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *progress, BOOL *stop) { transferProgressed = YES; }]; expect(error).to(beNil()); @@ -124,7 +124,7 @@ // Pull __block BOOL transferProgressed = NO; - BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) { + BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *progress, BOOL *stop) { transferProgressed = YES; }]; expect(@(result)).to(beTruthy()); @@ -165,7 +165,7 @@ // Pull __block BOOL transferProgressed = NO; - BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) { + BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *progress, BOOL *stop) { transferProgressed = YES; }]; expect(error).to(beNil()); @@ -219,7 +219,7 @@ // Pull __block BOOL transferProgressed = NO; - BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) { + BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *progress, BOOL *stop) { transferProgressed = YES; }]; expect(@(result)).to(beTruthy()); @@ -251,7 +251,7 @@ // Pull __block BOOL transferProgressed = NO; - BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) { + BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_indexer_progress *progress, BOOL *stop) { transferProgressed = YES; }]; NSString *fileContents = [NSString stringWithContentsOfURL:[localRepo.fileURL URLByAppendingPathComponent:@"test.txt"] encoding:NSUTF8StringEncoding error:nil]; diff --git a/ObjectiveGitTests/GTRepositorySpec.m b/ObjectiveGitTests/GTRepositorySpec.m index 2ff1aaf88..88d7571de 100644 --- a/ObjectiveGitTests/GTRepositorySpec.m +++ b/ObjectiveGitTests/GTRepositorySpec.m @@ -68,7 +68,7 @@ describe(@"+cloneFromURL:toWorkingDirectory:options:error:transferProgressBlock:checkoutProgressBlock:", ^{ __block BOOL transferProgressCalled = NO; __block BOOL checkoutProgressCalled = NO; - __block void (^transferProgressBlock)(const git_transfer_progress *, BOOL *); + __block void (^transferProgressBlock)(const git_indexer_progress *, BOOL *); __block void (^checkoutProgressBlock)(NSString *, NSUInteger, NSUInteger); __block NSURL *originURL; __block NSURL *workdirURL; @@ -78,7 +78,7 @@ beforeEach(^{ transferProgressCalled = NO; checkoutProgressCalled = NO; - transferProgressBlock = ^(const git_transfer_progress *progress, BOOL *stop) { + transferProgressBlock = ^(const git_indexer_progress *progress, BOOL *stop) { transferProgressCalled = YES; }; checkoutProgressBlock = ^(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps) {