diff --git a/.github/workflows/BuildPR.yml b/.github/workflows/BuildPR.yml new file mode 100644 index 000000000..0a1a7d32f --- /dev/null +++ b/.github/workflows/BuildPR.yml @@ -0,0 +1,23 @@ +name: PullRequest + +on: [pull_request] + +jobs: + build-objective-git: + name: Build objective-git + runs-on: macOS-latest + strategy: + fail-fast: false + matrix: + xcode: [Xcode_11.7, Xcode_12.2, Xcode_12.4] + steps: + - name: Checkout + uses: actions/checkout@v2.3.3 + with: + fetch-depth: 0 + submodules: true + - name: Set XCode Version + run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app + - name: Build project + run: xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive | xcpretty + diff --git a/Cartfile.private b/Cartfile.private index 476c2a1f6..0dfa9b497 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,4 +1,4 @@ github "jspahrsummers/xcconfigs" "master" -github "Quick/Quick" ~> 1.2.0 -github "Quick/Nimble" ~> 7.1.0 -github "ZipArchive/ZipArchive" ~> 2.1.2 +github "Quick/Quick" ~> 1.3.4 +github "Quick/Nimble" ~> 7.3.3 +github "ZipArchive/ZipArchive" ~> 2.1.4 diff --git a/Cartfile.resolved b/Cartfile.resolved index ef51bc1cb..36c5288e0 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "Quick/Nimble" "v7.1.0" -github "Quick/Quick" "v1.2.0" -github "ZipArchive/ZipArchive" "v2.1.2" +github "Quick/Nimble" "v7.3.3" +github "Quick/Quick" "v1.3.4" +github "ZipArchive/ZipArchive" "v2.1.4" github "jspahrsummers/xcconfigs" "bb795558a76e5daf3688500055bbcfe243bffa8d" diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble index 5e11474ae..9a281b1cf 160000 --- a/Carthage/Checkouts/Nimble +++ b/Carthage/Checkouts/Nimble @@ -1 +1 @@ -Subproject commit 5e11474ae6ea796a07e722fea49269d26710744d +Subproject commit 9a281b1cfa1c53d1e8bd92e1798e4e473af8d263 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick index 0ff81f2c6..f2b5a0644 160000 --- a/Carthage/Checkouts/Quick +++ b/Carthage/Checkouts/Quick @@ -1 +1 @@ -Subproject commit 0ff81f2c665b4381f526bd656f8708dd52a9ea2f +Subproject commit f2b5a06440ea87eba1a167cab37bf6496646c52e diff --git a/Carthage/Checkouts/ZipArchive b/Carthage/Checkouts/ZipArchive index 3ad651c62..e8b08ceb6 160000 --- a/Carthage/Checkouts/ZipArchive +++ b/Carthage/Checkouts/ZipArchive @@ -1 +1 @@ -Subproject commit 3ad651c62c059102acc7384dae6b0d4e0142e990 +Subproject commit e8b08ceb6ab9ff56e0826913b13680a129a92828 diff --git a/External/libgit2 b/External/libgit2 index f23dc5b29..1a107fac0 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit f23dc5b29f1394928a940d7ec447f4bfd53dad1f +Subproject commit 1a107fac0fc88a4d74b64ffc9ae2fd178ba631c0 diff --git a/External/libssh2 b/External/libssh2 index 30e9c1347..f15b1e297 160000 --- a/External/libssh2 +++ b/External/libssh2 @@ -1 +1 @@ -Subproject commit 30e9c1347e3b8baa2951db612f05e6d87fc8e2f2 +Subproject commit f15b1e297f72882214988101ccdc5e6ad30d7e6e diff --git a/ObjectiveGit.modulemap b/ObjectiveGit.modulemap index 3ef32bc58..9e7980ed3 100644 --- a/ObjectiveGit.modulemap +++ b/ObjectiveGit.modulemap @@ -50,6 +50,7 @@ framework module ObjectiveGit { header "git2/tree.h" header "git2/types.h" header "git2/version.h" + header "git2/sys/alloc.h" header "git2/sys/commit.h" header "git2/sys/config.h" header "git2/sys/diff.h" @@ -59,6 +60,7 @@ framework module ObjectiveGit { header "git2/sys/mempack.h" header "git2/sys/merge.h" header "git2/sys/odb_backend.h" + header "git2/sys/path.h" header "git2/sys/refdb_backend.h" header "git2/sys/reflog.h" header "git2/sys/refs.h" @@ -72,74 +74,74 @@ framework module ObjectiveGit { exclude header "git2/inttypes.h" exclude header "git2/stdint.h" - exclude header "git2/sys/git2/annotated_commit.h" - exclude header "git2/sys/git2/attr.h" - exclude header "git2/sys/git2/blame.h" - exclude header "git2/sys/git2/blob.h" - exclude header "git2/sys/git2/branch.h" - exclude header "git2/sys/git2/buffer.h" - exclude header "git2/sys/git2/checkout.h" - exclude header "git2/sys/git2/cherrypick.h" - exclude header "git2/sys/git2/clone.h" - exclude header "git2/sys/git2/commit.h" - exclude header "git2/sys/git2/cred_helpers.h" - exclude header "git2/sys/git2/describe.h" - exclude header "git2/sys/git2/errors.h" - exclude header "git2/sys/git2/global.h" - exclude header "git2/sys/git2/graph.h" - exclude header "git2/sys/git2/ignore.h" - exclude header "git2/sys/git2/index.h" - exclude header "git2/sys/git2/indexer.h" - exclude header "git2/sys/git2/inttypes.h" - exclude header "git2/sys/git2/merge.h" - exclude header "git2/sys/git2/message.h" - exclude header "git2/sys/git2/notes.h" - exclude header "git2/sys/git2/object.h" - exclude header "git2/sys/git2/odb_backend.h" - exclude header "git2/sys/git2/oidarray.h" - exclude header "git2/sys/git2/pack.h" - exclude header "git2/sys/git2/patch.h" - exclude header "git2/sys/git2/pathspec.h" - exclude header "git2/sys/git2/rebase.h" - exclude header "git2/sys/git2/refdb.h" - exclude header "git2/sys/git2/reflog.h" - exclude header "git2/sys/git2/refs.h" - exclude header "git2/sys/git2/refspec.h" - exclude header "git2/sys/git2/remote.h" - exclude header "git2/sys/git2/repository.h" - exclude header "git2/sys/git2/reset.h" - exclude header "git2/sys/git2/revert.h" - exclude header "git2/sys/git2/revparse.h" - exclude header "git2/sys/git2/revwalk.h" - exclude header "git2/sys/git2/signature.h" - exclude header "git2/sys/git2/stash.h" - exclude header "git2/sys/git2/stdint.h" - exclude header "git2/sys/git2/strarray.h" - exclude header "git2/sys/git2/submodule.h" - exclude header "git2/sys/git2/tag.h" - exclude header "git2/sys/git2/trace.h" - exclude header "git2/sys/git2/transaction.h" - exclude header "git2/sys/git2/transport.h" - exclude header "git2/sys/git2/tree.h" - exclude header "git2/sys/git2/version.h" - exclude header "git2/sys/git2/sys/commit.h" - exclude header "git2/sys/git2/sys/config.h" - exclude header "git2/sys/git2/sys/diff.h" - exclude header "git2/sys/git2/sys/filter.h" - exclude header "git2/sys/git2/sys/hashsig.h" - exclude header "git2/sys/git2/sys/index.h" - exclude header "git2/sys/git2/sys/mempack.h" - exclude header "git2/sys/git2/sys/merge.h" - exclude header "git2/sys/git2/sys/odb_backend.h" - exclude header "git2/sys/git2/sys/openssl.h" - exclude header "git2/sys/git2/sys/refdb_backend.h" - exclude header "git2/sys/git2/sys/reflog.h" - exclude header "git2/sys/git2/sys/refs.h" - exclude header "git2/sys/git2/sys/repository.h" - exclude header "git2/sys/git2/sys/stream.h" - exclude header "git2/sys/git2/sys/time.h" - exclude header "git2/sys/git2/sys/transport.h" - exclude header "git2/sys/git2/sys/worktree.h" + exclude header "git2/sys/annotated_commit.h" + exclude header "git2/sys/attr.h" + exclude header "git2/sys/blame.h" + exclude header "git2/sys/blob.h" + exclude header "git2/sys/branch.h" + exclude header "git2/sys/buffer.h" + exclude header "git2/sys/checkout.h" + exclude header "git2/sys/cherrypick.h" + exclude header "git2/sys/clone.h" + exclude header "git2/sys/commit.h" + exclude header "git2/sys/cred_helpers.h" + exclude header "git2/sys/describe.h" + exclude header "git2/sys/errors.h" + exclude header "git2/sys/global.h" + exclude header "git2/sys/graph.h" + exclude header "git2/sys/ignore.h" + exclude header "git2/sys/index.h" + exclude header "git2/sys/indexer.h" + exclude header "git2/sys/inttypes.h" + exclude header "git2/sys/merge.h" + exclude header "git2/sys/message.h" + exclude header "git2/sys/notes.h" + exclude header "git2/sys/object.h" + exclude header "git2/sys/odb_backend.h" + exclude header "git2/sys/oidarray.h" + exclude header "git2/sys/pack.h" + exclude header "git2/sys/patch.h" + exclude header "git2/sys/pathspec.h" + exclude header "git2/sys/rebase.h" + exclude header "git2/sys/refdb.h" + exclude header "git2/sys/reflog.h" + exclude header "git2/sys/refs.h" + exclude header "git2/sys/refspec.h" + exclude header "git2/sys/remote.h" + exclude header "git2/sys/repository.h" + exclude header "git2/sys/reset.h" + exclude header "git2/sys/revert.h" + exclude header "git2/sys/revparse.h" + exclude header "git2/sys/revwalk.h" + exclude header "git2/sys/signature.h" + exclude header "git2/sys/stash.h" + exclude header "git2/sys/stdint.h" + exclude header "git2/sys/strarray.h" + exclude header "git2/sys/submodule.h" + exclude header "git2/sys/tag.h" + exclude header "git2/sys/trace.h" + exclude header "git2/sys/transaction.h" + exclude header "git2/sys/transport.h" + exclude header "git2/sys/tree.h" + exclude header "git2/sys/version.h" + exclude header "git2/sys/commit.h" + exclude header "git2/sys/config.h" + exclude header "git2/sys/diff.h" + exclude header "git2/sys/filter.h" + exclude header "git2/sys/hashsig.h" + exclude header "git2/sys/index.h" + exclude header "git2/sys/mempack.h" + exclude header "git2/sys/merge.h" + exclude header "git2/sys/odb_backend.h" + exclude header "git2/sys/openssl.h" + exclude header "git2/sys/refdb_backend.h" + exclude header "git2/sys/reflog.h" + exclude header "git2/sys/refs.h" + exclude header "git2/sys/repository.h" + exclude header "git2/sys/stream.h" + exclude header "git2/sys/time.h" + exclude header "git2/sys/transport.h" + exclude header "git2/sys/worktree.h" export * module * { export * } diff --git a/ObjectiveGit/Categories/NSData+Git.m b/ObjectiveGit/Categories/NSData+Git.m index 2f06dd9fc..6498dfbe0 100644 --- a/ObjectiveGit/Categories/NSData+Git.m +++ b/ObjectiveGit/Categories/NSData+Git.m @@ -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]]; diff --git a/ObjectiveGit/Categories/NSError+Git.m b/ObjectiveGit/Categories/NSError+Git.m index e66d2fcb3..422b32d1f 100644 --- a/ObjectiveGit/Categories/NSError+Git.m +++ b/ObjectiveGit/Categories/NSError+Git.m @@ -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; diff --git a/ObjectiveGit/GTBlameHunk.m b/ObjectiveGit/GTBlameHunk.m index 3be7dd4da..9c136fc70 100644 --- a/ObjectiveGit/GTBlameHunk.m +++ b/ObjectiveGit/GTBlameHunk.m @@ -39,7 +39,9 @@ - (GTSignature *)finalSignature { } - (NSString *)originalPath { - return @(self.git_blame_hunk.orig_path); + NSString *path = @(self.git_blame_hunk.orig_path); + NSAssert(path, @"string was nil"); + return path; } - (BOOL)isBoundary { diff --git a/ObjectiveGit/GTBlob.m b/ObjectiveGit/GTBlob.m index 1f1e5213c..a1634dcf5 100644 --- a/ObjectiveGit/GTBlob.m +++ b/ObjectiveGit/GTBlob.m @@ -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"]; diff --git a/ObjectiveGit/GTConfiguration.m b/ObjectiveGit/GTConfiguration.m index 940753cf9..acd46cd74 100644 --- a/ObjectiveGit/GTConfiguration.m +++ b/ObjectiveGit/GTConfiguration.m @@ -112,7 +112,10 @@ - (BOOL)deleteValueForKey:(NSString *)key error:(NSError **)error { static int configCallback(const git_config_entry *entry, void *payload) { NSMutableArray *configurationKeysArray = (__bridge NSMutableArray *)payload; - [configurationKeysArray addObject:@(entry->name)]; + NSString *name = @(entry->name); + NSCAssert(name, @"string was nil"); + + [configurationKeysArray addObject:name]; return 0; } diff --git a/ObjectiveGit/GTCredential.m b/ObjectiveGit/GTCredential.m index 0ee809b0e..1d3894b44 100644 --- a/ObjectiveGit/GTCredential.m +++ b/ObjectiveGit/GTCredential.m @@ -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; } @@ -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; } diff --git a/ObjectiveGit/GTDiffFile.m b/ObjectiveGit/GTDiffFile.m index 135f758a0..24b3c7b11 100644 --- a/ObjectiveGit/GTDiffFile.m +++ b/ObjectiveGit/GTDiffFile.m @@ -22,8 +22,9 @@ - (instancetype)initWithGitDiffFile:(git_diff_file)file { self = [super init]; if (self == nil) return nil; - _path = @(file.path); - if (_path == nil) return nil; + NSString *path = @(file.path); + if (path == nil) return nil; + _path = path; _git_diff_file = file; _size = (NSUInteger)file.size; diff --git a/ObjectiveGit/GTDiffPatch.m b/ObjectiveGit/GTDiffPatch.m index fe28d662a..715db5a13 100644 --- a/ObjectiveGit/GTDiffPatch.m +++ b/ObjectiveGit/GTDiffPatch.m @@ -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; } diff --git a/ObjectiveGit/GTFilterSource.m b/ObjectiveGit/GTFilterSource.m index 91de241b3..65878319f 100644 --- a/ObjectiveGit/GTFilterSource.m +++ b/ObjectiveGit/GTFilterSource.m @@ -27,10 +27,13 @@ - (instancetype)initWithGitFilterSource:(const git_filter_source *)source { self = [super init]; if (self == nil) return nil; - const char *path = git_repository_workdir(git_filter_source_repo(source)); - _repositoryURL = [NSURL fileURLWithPath:@(path)]; - - _path = @(git_filter_source_path(source)); + NSString *path = @(git_repository_workdir(git_filter_source_repo(source))); + NSAssert(path, @"workdir was nil"); + _repositoryURL = [NSURL fileURLWithPath:path]; + + path = @(git_filter_source_path(source)); + NSAssert(path, @"path was nil"); + _path = path; const git_oid *gitOid = git_filter_source_id(source); if (gitOid != NULL) _OID = [[GTOID alloc] initWithGitOid:gitOid]; diff --git a/ObjectiveGit/GTIndexEntry.m b/ObjectiveGit/GTIndexEntry.m index a218ed398..c687d0060 100644 --- a/ObjectiveGit/GTIndexEntry.m +++ b/ObjectiveGit/GTIndexEntry.m @@ -74,7 +74,9 @@ - (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry { #pragma mark Properties - (NSString *)path { - return @(self.git_index_entry->path); + NSString *path = @(self.git_index_entry->path); + NSAssert(path, @"path is nil"); + return path; } - (int)flags { @@ -125,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) { diff --git a/ObjectiveGit/GTNote.m b/ObjectiveGit/GTNote.m index 0c18fe2b5..b87039de1 100644 --- a/ObjectiveGit/GTNote.m +++ b/ObjectiveGit/GTNote.m @@ -42,7 +42,9 @@ - (git_note *)git_note { } - (NSString *)note { - return @(git_note_message(self.git_note)); + NSString *message = @(git_note_message(self.git_note)); + NSAssert(message, @"message is nil"); + return message; } - (GTSignature *)author { @@ -96,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; } diff --git a/ObjectiveGit/GTOID.m b/ObjectiveGit/GTOID.m index c97da8735..8010c2885 100644 --- a/ObjectiveGit/GTOID.m +++ b/ObjectiveGit/GTOID.m @@ -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; diff --git a/ObjectiveGit/GTObject.h b/ObjectiveGit/GTObject.h index 66ef8b89c..a74ed418c 100644 --- a/ObjectiveGit/GTObject.h +++ b/ObjectiveGit/GTObject.h @@ -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; diff --git a/ObjectiveGit/GTObject.m b/ObjectiveGit/GTObject.m index 46ae4ae0e..503585092 100644 --- a/ObjectiveGit/GTObject.m +++ b/ObjectiveGit/GTObject.m @@ -82,18 +82,18 @@ - (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: @@ -101,7 +101,7 @@ - (id)initWithObj:(git_object *)object inRepository:(GTRepository *)repo { } 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; } @@ -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; diff --git a/ObjectiveGit/GTObjectDatabase.m b/ObjectiveGit/GTObjectDatabase.m index 534df08da..99c431a48 100644 --- a/ObjectiveGit/GTObjectDatabase.m +++ b/ObjectiveGit/GTObjectDatabase.m @@ -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); }; diff --git a/ObjectiveGit/GTReference.h b/ObjectiveGit/GTReference.h index 786739fac..c24a9fc7b 100644 --- a/ObjectiveGit/GTReference.h +++ b/ObjectiveGit/GTReference.h @@ -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 diff --git a/ObjectiveGit/GTReference.m b/ObjectiveGit/GTReference.m index bdb0fb13a..080375dd2 100644 --- a/ObjectiveGit/GTReference.m +++ b/ObjectiveGit/GTReference.m @@ -45,7 +45,7 @@ @interface GTReference () case GTReferenceTypeInvalid: return @"invalid"; - case GTReferenceTypeOid: + case GTReferenceTypeDirect: return @"direct"; case GTReferenceTypeSymbolic: @@ -118,10 +118,12 @@ - (BOOL)isNote { } - (NSString *)name { - const char *refName = git_reference_name(self.git_reference); - NSAssert(refName != nil, @"Unexpected nil name"); + const char *cRefName = git_reference_name(self.git_reference); + NSAssert(cRefName != nil, @"Unexpected nil name"); - return @(refName); + NSString *refName = @(cRefName); + NSAssert(refName, @"refname is nil"); + return refName; } - (GTReference *)referenceByRenaming:(NSString *)newName error:(NSError **)error { @@ -142,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; @@ -158,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; } @@ -179,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; diff --git a/ObjectiveGit/GTRepository+RemoteOperations.m b/ObjectiveGit/GTRepository+RemoteOperations.m index 57c92096a..822171ab9 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.m +++ b/ObjectiveGit/GTRepository+RemoteOperations.m @@ -126,9 +126,15 @@ int GTFetchHeadEntriesCallback(const char *ref_name, const char *remote_url, con GTRepository *repository = entriesPayload->repository; GTRemoteEnumerateFetchHeadEntryBlock enumerationBlock = entriesPayload->enumerationBlock; - GTReference *reference = [repository lookUpReferenceWithName:@(ref_name) error:NULL]; + NSString *refName = @(ref_name); + NSCAssert(refName, @"refName is nil"); - GTFetchHeadEntry *entry = [[GTFetchHeadEntry alloc] initWithReference:reference remoteURLString:@(remote_url) targetOID:[GTOID oidWithGitOid:oid] isMerge:(BOOL)is_merge]; + NSString *remoteURL = @(remote_url); + NSCAssert(remote_url, @"remoteURL is nil"); + + GTReference *reference = [repository lookUpReferenceWithName:refName error:NULL]; + + GTFetchHeadEntry *entry = [[GTFetchHeadEntry alloc] initWithReference:reference remoteURLString:remoteURL targetOID:[GTOID oidWithGitOid:oid] isMerge:(BOOL)is_merge]; BOOL stop = NO; diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index dde113c2c..133216cd4 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -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]; @@ -637,18 +637,22 @@ - (NSArray *)referenceNamesWithError:(NSError **)error { } - (NSURL *)fileURL { - const char *path = git_repository_workdir(self.git_repository); + const char *cPath = git_repository_workdir(self.git_repository); // bare repository, you may be looking for gitDirectoryURL - if (path == NULL) return nil; + if (cPath == NULL) return nil; - return [NSURL fileURLWithPath:@(path) isDirectory:YES]; + NSString *path = @(cPath); + NSAssert(path, @"workdir is nil"); + return [NSURL fileURLWithPath:path isDirectory:YES]; } - (NSURL *)gitDirectoryURL { - const char *path = git_repository_path(self.git_repository); - if (path == NULL) return nil; + const char *cPath = git_repository_path(self.git_repository); + if (cPath == NULL) return nil; - return [NSURL fileURLWithPath:@(path) isDirectory:YES]; + NSString *path = @(cPath); + NSAssert(path, @"gitdirectory is nil"); + return [NSURL fileURLWithPath:path isDirectory:YES]; } - (BOOL)isBare { @@ -679,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; } @@ -737,7 +741,9 @@ static int submoduleEnumerationCallback(git_submodule *git_submodule, const char NSError *error; // Use -submoduleWithName:error: so that we get a git_submodule that we own. - GTSubmodule *submodule = [info->parentRepository submoduleWithName:@(name) error:&error]; + NSString *submoduleName = @(name); + NSCAssert(submoduleName, @"submodule name is nil"); + GTSubmodule *submodule = [info->parentRepository submoduleWithName:submoduleName error:&error]; BOOL stop = NO; info->block(submodule, error, &stop); diff --git a/ObjectiveGit/GTSubmodule.m b/ObjectiveGit/GTSubmodule.m index 968920d83..5d61b20c2 100644 --- a/ObjectiveGit/GTSubmodule.m +++ b/ObjectiveGit/GTSubmodule.m @@ -62,21 +62,30 @@ - (NSString *)name { const char *cName = git_submodule_name(self.git_submodule); NSAssert(cName != NULL, @"Unexpected nil submodule name"); - return @(cName); + NSString *name = @(cName); + NSAssert(name, @"name is nil"); + + return name; } - (NSString *)path { const char *cPath = git_submodule_path(self.git_submodule); NSAssert(cPath != NULL, @"Unexpected nil submodule path"); - return @(cPath); + NSString *path = @(cPath); + NSAssert(path, @"message is nil"); + + return path; } - (NSString *)URLString { const char *cURL = git_submodule_url(self.git_submodule); NSAssert(cURL != NULL, @"Unexpected nil submodule URL"); - return @(cURL); + NSString *URL = @(cURL); + NSAssert(URL, @"URL is nil"); + + return URL; } #pragma mark Lifecycle diff --git a/ObjectiveGit/GTTag.m b/ObjectiveGit/GTTag.m index 3c8c617c8..e2cd31a94 100644 --- a/ObjectiveGit/GTTag.m +++ b/ObjectiveGit/GTTag.m @@ -47,11 +47,15 @@ - (NSString *)description { #pragma mark API - (NSString *)message { - return @(git_tag_message(self.git_tag)); + NSString *message = @(git_tag_message(self.git_tag)); + NSAssert(message, @"message is nil"); + return message; } - (NSString *)name { - return @(git_tag_name(self.git_tag)); + NSString *name = @(git_tag_name(self.git_tag)); + NSAssert(name, @"message is nil"); + return name; } - (GTObject *)target { diff --git a/ObjectiveGit/GTTreeBuilder.m b/ObjectiveGit/GTTreeBuilder.m index 5ae85646a..d53118e9d 100644 --- a/ObjectiveGit/GTTreeBuilder.m +++ b/ObjectiveGit/GTTreeBuilder.m @@ -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; diff --git a/ObjectiveGit/GTTreeEntry.m b/ObjectiveGit/GTTreeEntry.m index 809ae0eae..946b1f06f 100644 --- a/ObjectiveGit/GTTreeEntry.m +++ b/ObjectiveGit/GTTreeEntry.m @@ -94,7 +94,9 @@ + (instancetype)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTr } - (NSString *)name { - return @(git_tree_entry_name(self.git_tree_entry)); + NSString *name = @(git_tree_entry_name(self.git_tree_entry)); + NSAssert(name, @"name was nil"); + return name; } - (NSInteger)attributes { diff --git a/ObjectiveGitFramework.xcodeproj/project.pbxproj b/ObjectiveGitFramework.xcodeproj/project.pbxproj index 66b9339a3..da937cf9a 100644 --- a/ObjectiveGitFramework.xcodeproj/project.pbxproj +++ b/ObjectiveGitFramework.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ 23F39FAE1C86DB1C00849F3C /* GTRepository+Merging.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F39FAC1C86DB1C00849F3C /* GTRepository+Merging.m */; }; 23F39FAF1C86DD0A00849F3C /* GTRepository+Merging.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F39FAB1C86DB1C00849F3C /* GTRepository+Merging.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23F39FB01C86E01800849F3C /* GTRepository+Merging.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F39FAC1C86DB1C00849F3C /* GTRepository+Merging.m */; }; + 2970FCDB2395526E0042C0DC /* git2 in Headers */ = {isa = PBXBuildFile; fileRef = 889923F919FF5DD40092A9A6 /* git2 */; settings = {ATTRIBUTES = (Public, ); }; }; 3011D86B1668E48500CE3409 /* GTDiffFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 3011D8691668E48500CE3409 /* GTDiffFile.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3011D86D1668E48500CE3409 /* GTDiffFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 3011D86A1668E48500CE3409 /* GTDiffFile.m */; }; 3011D8711668E78500CE3409 /* GTDiffHunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3011D86F1668E78500CE3409 /* GTDiffHunk.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -134,7 +135,6 @@ 88746CC417FA1C950005888A /* GTRepository+Committing.h in Headers */ = {isa = PBXBuildFile; fileRef = 88746CC217FA1C950005888A /* GTRepository+Committing.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88746CC617FA1C950005888A /* GTRepository+Committing.m in Sources */ = {isa = PBXBuildFile; fileRef = 88746CC317FA1C950005888A /* GTRepository+Committing.m */; }; 88948AC91779243600809CDA /* GTObjectDatabaseSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88948AC81779243600809CDA /* GTObjectDatabaseSpec.m */; }; - 889923FB19FF5DD40092A9A6 /* git2 in Headers */ = {isa = PBXBuildFile; fileRef = 889923F919FF5DD40092A9A6 /* git2 */; settings = {ATTRIBUTES = (Public, ); }; }; 88A994BA16FCE7D400402C7B /* GTBranchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994B916FCE7D400402C7B /* GTBranchSpec.m */; }; 88A994CB16FCED1D00402C7B /* QuickSpec+GTFixtures.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994CA16FCED1D00402C7B /* QuickSpec+GTFixtures.m */; }; 88B2131C1B20E785005CF2C5 /* GTRepository+References.h in Headers */ = {isa = PBXBuildFile; fileRef = 88B2131A1B20E785005CF2C5 /* GTRepository+References.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -452,7 +452,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 200578C418932A82001C06C3 /* GTBlameSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTBlameSpec.m; sourceTree = ""; }; 2089E43B17D9A58000F451DA /* GTTagSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTTagSpec.m; sourceTree = ""; }; @@ -592,6 +591,7 @@ BDFAF9C2131C1845000508BC /* GTIndex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTIndex.m; sourceTree = ""; }; BDFAF9C7131C1868000508BC /* GTIndexEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTIndexEntry.h; sourceTree = ""; }; BDFAF9C8131C1868000508BC /* GTIndexEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GTIndexEntry.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + C9088CC322B98E8300DB4A02 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; D00F6815175D373C004DB9D6 /* GTReferenceSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTReferenceSpec.m; sourceTree = ""; }; D015F7C817F695E800AD5E1F /* GTRepository+Stashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTRepository+Stashing.h"; sourceTree = ""; }; D015F7C917F695E800AD5E1F /* GTRepository+Stashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTRepository+Stashing.m"; sourceTree = ""; }; @@ -1135,6 +1135,8 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 2970FCDB2395526E0042C0DC /* git2 in Headers */, + D01B6F1419F82F6000D411BC /* git2.h in Headers */, D01B6F3D19F82F8700D411BC /* GTTag.h in Headers */, D01B6F4119F82F8700D411BC /* GTIndexEntry.h in Headers */, D01B6F2319F82F8700D411BC /* GTRepository+Reset.h in Headers */, @@ -1188,9 +1190,7 @@ D01B6F1B19F82F7B00D411BC /* NSDate+GTTimeAdditions.h in Headers */, F964D5F21CE9D9B200F1D8DD /* GTNote.h in Headers */, D01B6F6319F82FA600D411BC /* GTFilterList.h in Headers */, - 889923FB19FF5DD40092A9A6 /* git2 in Headers */, F8D1BDEF1B31FE7C00CDEC90 /* GTRepository+Pull.h in Headers */, - D01B6F1419F82F6000D411BC /* git2.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1225,6 +1225,7 @@ 79262F0F13C697BE00A4B1EA /* Copy git2 Headers */, BEF7E4DF1A3A47450035BB8E /* Copy git2 Headers again */, 8DC2EF500486A6940098B216 /* Headers */, + 4D751E9D215D765D003CD3CE /* Package external libraries */, ); buildRules = ( ); @@ -1281,7 +1282,7 @@ attributes = { LastSwiftUpdateCheck = 0700; LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1120; ORGANIZATIONNAME = "GitHub, Inc"; TargetAttributes = { 88F05A6A16011E5400B7AD1D = { @@ -1302,14 +1303,14 @@ }; buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "ObjectiveGitFramework" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 1; knownRegions = ( - English, - Japanese, - French, - German, en, + ja, + fr, + de, + Base, ); mainGroup = 0867D691FE84028FC02AAC07 /* ObjectiveGitFramework */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; @@ -1356,6 +1357,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 4D751E9D215D765D003CD3CE /* Package external libraries */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Package external libraries"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "./script/repackage-dylibs.rb"; + }; 6A28265317C69CB400C6A948 /* OpenSSL-iOS */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1669,7 +1684,7 @@ 089C1666FE841158C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( - 089C1667FE841158C02AAC07 /* English */, + C9088CC322B98E8300DB4A02 /* en */, ); name = InfoPlist.strings; sourceTree = ""; @@ -1760,13 +1775,13 @@ ., External, ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 10.9; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "$(inherited)", "-DGIT_SSH", ); - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; WARNING_CFLAGS = ( "$(inherited)", @@ -1799,12 +1814,12 @@ ., External, ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 10.9; OTHER_CFLAGS = ( "$(inherited)", "-DGIT_SSH", ); - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; WARNING_CFLAGS = ( "$(inherited)", @@ -1883,7 +1898,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1904,7 +1919,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1932,12 +1947,12 @@ ., External, ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 10.9; OTHER_CFLAGS = ( "$(inherited)", "-DGIT_SSH", ); - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; WARNING_CFLAGS = ( "$(inherited)", @@ -1992,7 +2007,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Test; }; @@ -2000,7 +2015,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D019778C19F830D100F523DA /* iOS-Framework.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2057,7 +2072,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D019778C19F830D100F523DA /* iOS-Framework.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2082,7 +2097,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D019778C19F830D100F523DA /* iOS-Framework.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2107,7 +2122,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D019778C19F830D100F523DA /* iOS-Framework.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2152,12 +2167,12 @@ ., External, ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 10.9; OTHER_CFLAGS = ( "$(inherited)", "-DGIT_SSH", ); - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; WARNING_CFLAGS = ( "$(inherited)", @@ -2212,7 +2227,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Profile; }; diff --git a/ObjectiveGitTests/GTReferenceSpec.m b/ObjectiveGitTests/GTReferenceSpec.m index 811a7e952..a3b9b4022 100644 --- a/ObjectiveGitTests/GTReferenceSpec.m +++ b/ObjectiveGitTests/GTReferenceSpec.m @@ -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", ^{ @@ -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"); }); }); @@ -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"); }); }); diff --git a/ObjectiveGitTests/GTRepositorySpec.m b/ObjectiveGitTests/GTRepositorySpec.m index 8da554cc8..2ff1aaf88 100644 --- a/ObjectiveGitTests/GTRepositorySpec.m +++ b/ObjectiveGitTests/GTRepositorySpec.m @@ -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", ^{ @@ -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", ^{ @@ -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", ^{ diff --git a/English.lproj/InfoPlist.strings b/en.lproj/InfoPlist.strings similarity index 100% rename from English.lproj/InfoPlist.strings rename to en.lproj/InfoPlist.strings diff --git a/script/bootstrap b/script/bootstrap index 18f76616a..aca53e814 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -62,7 +62,7 @@ check_deps () fi # Ensure that we have libgit2's dependencies installed. - installed=`brew list` + installed=`brew list --formula` for tool in $REQUIRED_TOOLS do diff --git a/script/repackage-dylibs.rb b/script/repackage-dylibs.rb new file mode 100755 index 000000000..f6b35a300 --- /dev/null +++ b/script/repackage-dylibs.rb @@ -0,0 +1,124 @@ +#!/usr/bin/ruby + +# This script looks up an executable's list of shared libraries, copies +# non-standard ones (ie. anything not under /usr or /System/) into the target's +# bundle and updates the executable install_name to point to the "packaged" +# version. + +# Usage: +# Add the script as a Run Script build phase in the target using Xcode. + +# FIXMEs: +# - only handles dylibs +# - only tested against a framework target +# - doesn't care about codesigning + + +require 'fileutils' +require 'ostruct' + +def err(msg) + puts "error: " + msg + exit 1 +end + +def warn(msg) + puts "warning: " + msg +end + +def note(msg) + puts "note: " + msg +end + +envvars = %w( + TARGET_BUILD_DIR + EXECUTABLE_PATH + FRAMEWORKS_FOLDER_PATH +) + +envvars.each do |var| + raise "Must be run in an Xcode Run Phase" unless ENV[var] + Kernel.const_set var, ENV[var] +end + +TARGET_EXECUTABLE_PATH = File.join(TARGET_BUILD_DIR, EXECUTABLE_PATH) +TARGET_FRAMEWORKS_PATH = File.join(TARGET_BUILD_DIR, FRAMEWORKS_FOLDER_PATH) + +def extract_link_dependencies(executable) + deps = `otool -L #{executable}` + + lines = deps.split("\n").map(&:strip) + lines.shift + # lines.shift + lines.map do |dep| + path, compat, current = /^(.*) \(compatibility version (.*), current version (.*)\)$/.match(dep)[1..3] + err "Failed to parse #{dep}" if path.nil? + + dep = OpenStruct.new + dep.is_self = (File.basename(path) == File.basename(executable)) + dep.executable = executable + dep.install_name = path + dep.current_version = current + dep.compat_version = compat + dep.type = File.extname(path) + dep.name = File.basename(path) + dep.is_packaged = !!(dep.install_name =~ /^@rpath/) + dep.path = if dep.install_name =~ /^@rpath/ + File.join(TARGET_FRAMEWORKS_PATH, dep.name) + else + dep.install_name + end + + dep + end +end + +def repackage_dependency(dep) + return if dep.is_self or dep.is_packaged or dep.path =~ /^(\/usr\/lib|\/System\/Library)/ + + note "Packaging #{dep.name}…" + + FileUtils.mkdir(TARGET_FRAMEWORKS_PATH) unless Dir.exist?(TARGET_FRAMEWORKS_PATH) + packaged_path = File.join(TARGET_FRAMEWORKS_PATH, dep.name) + + case dep.type + when ".dylib" + if File.exist? packaged_path + warn "#{dep.path} already in Frameworks directory, removing" + FileUtils.rm packaged_path + end + + note "Copying #{dep[:path]} to TARGET_FRAMEWORKS_PATH" + FileUtils.cp dep[:path], TARGET_FRAMEWORKS_PATH + FileUtils.chmod "u=rw", packaged_path + + out = `install_name_tool -change #{dep.path} "@rpath/#{dep.name}" #{dep.executable}` + if $? != 0 + err "install_name_tool failed with error #{$?}:\n#{out}" + end + + dep.path = packaged_path + dep.install_name = "@rpath/#{dep.name}" + dep.is_packaged = true + else + warn "Unhandled type #{dep.type} for #{dep.path}, ignoring" + end +end + +def fix_install_id(dep) + note "Fixing #{dep.name} install_name id…" + out = `install_name_tool -id @rpath/#{dep.name} #{dep.executable}` + if $? != 0 + err "install_name_tool failed with error #{$?}:\n#{out}" + end +end + +deps = extract_link_dependencies(TARGET_EXECUTABLE_PATH) +while (dep = deps.shift) do + repackage_dependency dep + fix_install_id dep if dep.is_self and dep.executable != TARGET_EXECUTABLE_PATH + deps += extract_link_dependencies(dep[:path]) if dep.is_packaged and not dep.is_self +end + +note "Packaging done" +exit 0