Skip to content

Commit

Permalink
Update to libgit2 v0.28.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
tiennou committed Feb 8, 2019
1 parent a9cd846 commit 7ab537e
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion External/libgit2
Submodule libgit2 updated 6582 files
2 changes: 1 addition & 1 deletion ObjectiveGit/Categories/NSData+Git.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ - (BOOL)git_getOid:(git_oid *)oid error:(NSError **)error {
if ([self length] != sizeof(git_oid)) {
if (error != NULL) {
*error = [NSError errorWithDomain:GTGitErrorDomain
code:GITERR_INVALID
code:GIT_ERROR_INVALID
userInfo:
[NSDictionary dictionaryWithObject:@"can't extract oid from data of incorrect length"
forKey:NSLocalizedDescriptionKey]];
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveGit/Categories/NSError+Git.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ + (NSError *)git_errorFor:(int)code {
}

+ (NSString *)git_descriptionForErrorCode:(int)code {
const git_error *gitLastError = giterr_last();
const git_error *gitLastError = git_error_last();
if (gitLastError != NULL) {
return @(gitLastError->message);
} else if (code == GITERR_OS) {
} else if (code == GIT_ERROR_OS) {
return @(strerror(errno));
} else {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTBlob.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (instancetype)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)re
NSParameterAssert(repository != nil);

git_object *obj;
int gitError = git_object_lookup(&obj, repository.git_repository, oid, (git_otype) GTObjectTypeBlob);
int gitError = git_object_lookup(&obj, repository.git_repository, oid, (git_object_t) GTObjectTypeBlob);
if (gitError < GIT_OK) {
if (error != NULL) {
*error = [NSError git_errorFor:gitError description:@"Failed to lookup blob"];
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveGit/GTCredential.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int GTCredentialAcquireCallback(git_cred **git_cred, const char *url, const char
GTCredentialProvider *provider = info->credProvider;

if (provider == nil) {
giterr_set_str(GIT_EUSER, "No GTCredentialProvider set, but authentication was requested.");
git_error_set_str(GIT_EUSER, "No GTCredentialProvider set, but authentication was requested.");
return GIT_ERROR;
}

Expand All @@ -114,7 +114,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) {
giterr_set_str(GIT_EUSER, "GTCredentialProvider failed to provide credentials.");
git_error_set_str(GIT_EUSER, "GTCredentialProvider failed to provide credentials.");
return GIT_ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTDiffPatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (NSData *)patchData {
git_patch_to_buf(&buf, self.git_patch);

NSData *buffer = [[NSData alloc] initWithBytes:buf.ptr length:buf.size];
git_buf_free(&buf);
git_buf_dispose(&buf);

return buffer;
}
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTIndexEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ + (instancetype)objectWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError *

- (instancetype)initWithIndexEntry:(GTIndexEntry *)indexEntry error:(NSError **)error {
git_object *obj;
int gitError = git_object_lookup(&obj, indexEntry.repository.git_repository, indexEntry.OID.git_oid, (git_otype)GTObjectTypeAny);
int gitError = git_object_lookup(&obj, indexEntry.repository.git_repository, indexEntry.OID.git_oid, (git_object_t)GTObjectTypeAny);

if (gitError < GIT_OK) {
if (error != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTNote.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ + (NSString *)defaultReferenceNameForRepository:(GTRepository *)repository error
if (error != NULL) *error = [NSError git_errorFor:GIT_ERROR description:@"Unable to get default git notes reference name"];
}

git_buf_free(&default_ref_name);
git_buf_dispose(&default_ref_name);

return noteRef;
}
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTOID.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ + (instancetype)OIDByHashingData:(NSData *)data type:(GTObjectType)type error:(N
NSParameterAssert(data != nil);

git_oid oid;
int gitError = git_odb_hash(&oid, data.bytes, data.length, (git_otype)type);
int gitError = git_odb_hash(&oid, data.bytes, data.length, (git_object_t)type);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to hash"];
return nil;
Expand Down
18 changes: 8 additions & 10 deletions ObjectiveGit/GTObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
#import "git2/types.h"

typedef NS_ENUM(int, GTObjectType) {
GTObjectTypeAny = GIT_OBJ_ANY, /**< Object can be any of the following */
GTObjectTypeBad = GIT_OBJ_BAD, /**< Object is invalid. */
GTObjectTypeExt1 = GIT_OBJ__EXT1, /**< Reserved for future use. */
GTObjectTypeCommit = GIT_OBJ_COMMIT, /**< A commit object. */
GTObjectTypeTree = GIT_OBJ_TREE, /**< A tree (directory listing) object. */
GTObjectTypeBlob = GIT_OBJ_BLOB, /**< A file revision object. */
GTObjectTypeTag = GIT_OBJ_TAG, /**< An annotated tag object. */
GTObjectTypeExt2 = GIT_OBJ__EXT2, /**< Reserved for future use. */
GTObjectTypeOffsetDelta = GIT_OBJ_OFS_DELTA,/**< A delta, base is given by an offset. */
GTObjectTypeRefDelta = GIT_OBJ_REF_DELTA, /**< A delta, base is given by object id. */
GTObjectTypeAny = GIT_OBJECT_ANY, /**< Object can be any of the following */
GTObjectTypeBad = GIT_OBJECT_INVALID, /**< Object is invalid. */
GTObjectTypeCommit = GIT_OBJECT_COMMIT, /**< A commit object. */
GTObjectTypeTree = GIT_OBJECT_TREE, /**< A tree (directory listing) object. */
GTObjectTypeBlob = GIT_OBJECT_BLOB, /**< A file revision object. */
GTObjectTypeTag = GIT_OBJECT_TAG, /**< An annotated tag object. */
GTObjectTypeOffsetDelta = GIT_OBJECT_OFS_DELTA,/**< A delta, base is given by an offset. */
GTObjectTypeRefDelta = GIT_OBJECT_REF_DELTA, /**< A delta, base is given by object id. */
};

@class GTRepository;
Expand Down
14 changes: 7 additions & 7 deletions ObjectiveGit/GTObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,26 @@ - (id)initWithObj:(git_object *)object inRepository:(GTRepository *)repo {
NSAssert(object_repo == repo.git_repository, @"object %p doesn't belong to repo %@", object, repo);

Class objectClass = nil;
git_otype t = git_object_type(object);
git_object_t t = git_object_type(object);
switch (t) {
case GIT_OBJ_COMMIT:
case GIT_OBJECT_COMMIT:
objectClass = [GTCommit class];
break;
case GIT_OBJ_TREE:
case GIT_OBJECT_TREE:
objectClass = [GTTree class];
break;
case GIT_OBJ_BLOB:
case GIT_OBJECT_BLOB:
objectClass = [GTBlob class];
break;
case GIT_OBJ_TAG:
case GIT_OBJECT_TAG:
objectClass = [GTTag class];
break;
default:
break;
}

if (!objectClass) {
NSLog(@"Unknown git_otype %s (%d)", git_object_type2string(t), (int)t);
NSLog(@"Unknown git_object_t %s (%d)", git_object_type2string(t), (int)t);
return nil;
}

Expand Down Expand Up @@ -149,7 +149,7 @@ - (GTOdbObject *)odbObjectWithError:(NSError **)error {

- (id)objectByPeelingToType:(GTObjectType)type error:(NSError **)error {
git_object *peeled = NULL;
int gitError = git_object_peel(&peeled, self.git_object, (git_otype)type);
int gitError = git_object_peel(&peeled, self.git_object, (git_object_t)type);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Cannot peel object"];
return nil;
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTObjectDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (GTOID *)writeData:(NSData *)data type:(GTObjectType)type error:(NSError **)er
NSParameterAssert(data != nil);

git_odb_stream *stream;
int gitError = git_odb_open_wstream(&stream, self.git_odb, data.length, (git_otype)type);
int gitError = git_odb_open_wstream(&stream, self.git_odb, data.length, (git_object_t)type);
@onExit {
if (stream != NULL) git_odb_stream_free(stream);
};
Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGit/GTReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ typedef NS_ENUM(NSInteger, GTReferenceErrorCode) {
};

typedef NS_OPTIONS(NSInteger, GTReferenceType) {
GTReferenceTypeInvalid = GIT_REF_INVALID, /** Invalid reference */
GTReferenceTypeOid = GIT_REF_OID, /** A reference which points at an object id */
GTReferenceTypeSymbolic = GIT_REF_SYMBOLIC, /** A reference which points at another reference */
GTReferenceTypeInvalid = GIT_REFERENCE_INVALID, /** Invalid reference */
GTReferenceTypeDirect = GIT_REFERENCE_DIRECT, /** A reference which points at an object id */
GTReferenceTypeSymbolic = GIT_REFERENCE_SYMBOLIC, /** A reference which points at another reference */
};

NS_ASSUME_NONNULL_BEGIN
Expand Down
8 changes: 4 additions & 4 deletions ObjectiveGit/GTReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ @interface GTReference ()
case GTReferenceTypeInvalid:
return @"invalid";

case GTReferenceTypeOid:
case GTReferenceTypeDirect:
return @"direct";

case GTReferenceTypeSymbolic:
Expand Down Expand Up @@ -144,7 +144,7 @@ - (GTReferenceType)referenceType {
}

- (id)unresolvedTarget {
if (self.referenceType == GTReferenceTypeOid) {
if (self.referenceType == GTReferenceTypeDirect) {
const git_oid *oid = git_reference_target(self.git_reference);
if (oid == NULL) return nil;

Expand All @@ -160,7 +160,7 @@ - (id)unresolvedTarget {

- (id)resolvedTarget {
git_object *obj;
if (git_reference_peel(&obj, self.git_reference, GIT_OBJ_ANY) != GIT_OK) {
if (git_reference_peel(&obj, self.git_reference, GIT_OBJECT_ANY) != GIT_OK) {
return nil;
}

Expand All @@ -181,7 +181,7 @@ - (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSStri

int gitError;
git_reference *newRef = NULL;
if (git_reference_type(self.git_reference) == GIT_REF_OID) {
if (git_reference_type(self.git_reference) == GIT_REFERENCE_DIRECT) {
GTOID *oid = [[GTOID alloc] initWithSHA:newTarget error:error];
if (oid == nil) return nil;

Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGit/GTRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ + (instancetype _Nullable)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NS
- (id)lookUpObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type error:(NSError **)error {
git_object *obj;

int gitError = git_object_lookup(&obj, self.git_repository, oid, (git_otype)type);
int gitError = git_object_lookup(&obj, self.git_repository, oid, (git_object_t)type);
if (gitError < GIT_OK) {
if (error != NULL) {
char oid_str[GIT_OID_HEXSZ+1];
Expand Down Expand Up @@ -683,13 +683,13 @@ - (NSString *)preparedMessageWithError:(NSError * __autoreleasing *)error {
int errorCode = git_repository_message(&msg, self.git_repository);
if (errorCode != GIT_OK) {
setErrorFromCode(errorCode);
git_buf_free(&msg);
git_buf_dispose(&msg);
return nil;
}

NSString *message = [[NSString alloc] initWithBytes:msg.ptr length:msg.size encoding:NSUTF8StringEncoding];

git_buf_free(&msg);
git_buf_dispose(&msg);

return message;
}
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTTreeBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ - (GTTree *)writeTree:(NSError **)error {
}

git_object *object = NULL;
status = git_object_lookup(&object, self.repository.git_repository, &treeOid, GIT_OBJ_TREE);
status = git_object_lookup(&object, self.repository.git_repository, &treeOid, GIT_OBJECT_TREE);
if (status != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to lookup tree in repository."];
return nil;
Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGitTests/GTReferenceSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
expect(ref).notTo(beNil());
expect(error).to(beNil());

expectValidReference(ref, @"36060c58702ed4c2a40832c51758d5344201d89a", GTReferenceTypeOid, @"refs/heads/master");
expectValidReference(ref, @"36060c58702ed4c2a40832c51758d5344201d89a", GTReferenceTypeDirect, @"refs/heads/master");
});

it(@"should return a valid reference to a tag", ^{
Expand All @@ -144,7 +144,7 @@
expect(ref).notTo(beNil());
expect(error).to(beNil());

expectValidReference(ref, @"5b5b025afb0b4c913b4c338a42934a3863bf3644", GTReferenceTypeOid, @"refs/tags/v0.9");
expectValidReference(ref, @"5b5b025afb0b4c913b4c338a42934a3863bf3644", GTReferenceTypeDirect, @"refs/tags/v0.9");
});
});

Expand All @@ -170,7 +170,7 @@
expect(error).to(beNil());
expect(ref).notTo(beNil());

expectValidReference(ref, @"36060c58702ed4c2a40832c51758d5344201d89a", GTReferenceTypeOid, @"refs/heads/unit_test");
expectValidReference(ref, @"36060c58702ed4c2a40832c51758d5344201d89a", GTReferenceTypeDirect, @"refs/heads/unit_test");
});
});

Expand Down
6 changes: 3 additions & 3 deletions ObjectiveGitTests/GTRepositorySpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
expect(head).notTo(beNil());
expect(error).to(beNil());
expect(head.targetOID.SHA).to(equal(@"36060c58702ed4c2a40832c51758d5344201d89a"));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeOid)));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeDirect)));
});

it(@"should handle bare clones", ^{
Expand All @@ -139,7 +139,7 @@
expect(head).notTo(beNil());
expect(error).to(beNil());
expect(head.targetOID.SHA).to(equal(@"36060c58702ed4c2a40832c51758d5344201d89a"));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeOid)));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeDirect)));
});

it(@"should have set a valid remote URL", ^{
Expand Down Expand Up @@ -212,7 +212,7 @@
expect(head).notTo(beNil());
expect(error).to(beNil());
expect(head.targetOID.SHA).to(equal(@"36060c58702ed4c2a40832c51758d5344201d89a"));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeOid)));
expect(@(head.referenceType)).to(equal(@(GTReferenceTypeDirect)));
});

it(@"should fail to return HEAD for an unborn repo", ^{
Expand Down

0 comments on commit 7ab537e

Please sign in to comment.