Author SHA1 Message Date
Manuel Gauto 43b1632877 Adjust defaulting logic for handling nil case of Credentials. Completes fix for #100. 2021-02-05 19:26:55 -05:00
Manuel Gauto e1c3e89e09 Merge remote-tracking branch https://github.com/joehinkle11/SwiftGit2.git into applesilicon-support.
Initial fix for Credentials BAD_ACCESS error.
2021-02-05 19:23:07 -05:00
Joe Hinkle 3c7c920c47 Update Credentials.swift 2020-12-17 15:40:24 -05:00
Joe Hinkle 5a56c22a97 Update Credentials.swift 2020-12-15 18:10:22 -05:00
Joe Hinkle 39f160344e Credentials fix for BAD_ACCESS
This is a fix for an old issue: https://github.com/SwiftGit2/SwiftGit2/issues/100

There's a crash caused by accessing the pointer to the creds object after libgit2 frees it. libgit2 also is calling credentialsCallback, so there is no good way to prevent the crash from happening. Interestingly, libgit2 calls the callback twice, and the result of the second one doesn't seem too important. So because we don't have control over how libgit2 chooses to free objects, I just wrote a simple change to prevent the second call of credentialsCallback from accessing the pointer to the creds object.
2020-12-03 18:42:13 -05:00
24 changed files with 202 additions and 330 deletions
-1
View File
@@ -23,7 +23,6 @@ DerivedData
*.idea*
External/libgit2*.a
External/libgit2-mac
External/ios-openssl
External/libgit2-ios
External/libssh2-ios
-2
View File
@@ -19,5 +19,3 @@
[submodule "External/openssl"]
path = External/openssl
url = https://github.com/openssl/openssl.git
[submodule "libgit2"]
url = https://github.com/libgit2/libgit2.git
+2 -2
View File
@@ -1,4 +1,4 @@
github "jspahrsummers/xcconfigs" ~> 1.1
github "Quick/Quick" ~> 7.0
github "Quick/Nimble" ~> 12.0
github "Quick/Quick" ~> 2.0
github "Quick/Nimble" ~> 8.0
github "ZipArchive/ZipArchive" ~> 2.0
+3 -3
View File
@@ -1,4 +1,4 @@
github "Quick/Nimble" "v12.3.0"
github "Quick/Quick" "v7.3.0"
github "ZipArchive/ZipArchive" "2.5.5"
github "Quick/Nimble" "v8.1.2"
github "Quick/Quick" "v2.2.1"
github "ZipArchive/ZipArchive" "v2.2.3"
github "jspahrsummers/xcconfigs" "1.1"
+1 -1
View File
@@ -1 +1 @@
/opt/homebrew/opt/openssl/lib/libcrypto.a
/usr/local/opt/openssl/lib/libcrypto.a
+1 -1
View File
@@ -1 +1 @@
/opt/homebrew/opt/openssl/lib/libssl.a
/usr/local/opt/openssl/lib/libssl.a
+101 -81
View File
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 46;
objects = {
/* Begin PBXAggregateTarget section */
@@ -28,8 +28,6 @@
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; };
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
621E66A01C72958800A0F352 /* OID.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E41A1ACB1A002C3F4E /* OID.swift */; };
621E66A11C72958800A0F352 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
621E66A21C72958800A0F352 /* CheckoutStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE276B281ACCD3CF00D6DAD7 /* CheckoutStrategy.swift */; };
@@ -127,30 +125,20 @@
remoteGlobalIDString = BEB31F221A0D6F7A00F525B9;
remoteInfo = "SwiftGit2-OSX";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
50A682E52ADBF65F00FDB557 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = BEB31F1A1A0D6F7A00F525B9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = BEB31F8E1A0E563900F525B9;
remoteInfo = libgit2;
};
/* End PBXCopyFilesBuildPhase section */
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
232861421F4A3A2E00276D65 /* Diffs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diffs.swift; sourceTree = "<group>"; };
237731C61F46542B0020A3FE /* repository-with-status.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "repository-with-status.zip"; sourceTree = "<group>"; };
25499A996CA7BD416620A397 /* CommitIterator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommitIterator.swift; sourceTree = "<group>"; };
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusOptions.swift; sourceTree = "<group>"; };
50A682D82AD9901000FDB557 /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; path = script; sourceTree = "<group>"; };
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libgit2-mac.a"; path = "External/libgit2-mac/libgit2-mac.a"; sourceTree = "<group>"; };
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libgit2.xcframework; path = "External/libgit2-ios/libgit2.xcframework"; sourceTree = "<group>"; };
621E66B41C72958800A0F352 /* SwiftGit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftGit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SwiftGit2-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
621E66E11C729CE500A0F352 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -198,6 +186,7 @@
BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F581A0D75EE00F525B9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BEB31F6C1A0D78F300F525B9 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
BEB31F8F1A0E563900F525B9 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
BEB31F9F1A0E595600F525B9 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
BECB5F691A56F19900999413 /* References.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = References.swift; sourceTree = "<group>"; };
@@ -216,7 +205,6 @@
buildActionMask = 2147483647;
files = (
621E67001C72A60B00A0F352 /* libz.tbd in Frameworks */,
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */,
621E66FE1C72A5FF00A0F352 /* libiconv.tbd in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -255,15 +243,6 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
50A682D92AD994C500FDB557 /* Frameworks */ = {
isa = PBXGroup;
children = (
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */,
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
621E66D41C72965C00A0F352 /* Mac */ = {
isa = PBXGroup;
children = (
@@ -297,14 +276,12 @@
BEB31F191A0D6F7A00F525B9 = {
isa = PBXGroup;
children = (
50A682D82AD9901000FDB557 /* script */,
BEB31F251A0D6F7A00F525B9 /* SwiftGit2 */,
BEB31F261A0D6F7A00F525B9 /* Supporting Files */,
BEB31F321A0D6F7A00F525B9 /* SwiftGit2Tests */,
BEB31FA11A0E63C100F525B9 /* Libraries */,
BEB31F411A0D75EE00F525B9 /* Configuration */,
BEB31F241A0D6F7A00F525B9 /* Products */,
50A682D92AD994C500FDB557 /* Frameworks */,
);
sourceTree = "<group>";
usesTabs = 1;
@@ -314,6 +291,7 @@
children = (
BEB31F231A0D6F7A00F525B9 /* SwiftGit2.framework */,
BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */,
BEB31F8F1A0E563900F525B9 /* libgit2.a */,
621E66B41C72958800A0F352 /* SwiftGit2.framework */,
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */,
621E66E11C729CE500A0F352 /* libgit2.a */,
@@ -485,7 +463,6 @@
621E669F1C72958800A0F352 /* Sources */,
621E66AA1C72958800A0F352 /* Frameworks */,
621E66AE1C72958800A0F352 /* Headers */,
50A682E52ADBF65F00FDB557 /* Embed Frameworks */,
);
buildRules = (
);
@@ -566,7 +543,6 @@
isa = PBXNativeTarget;
buildConfigurationList = BEB31F391A0D6F7A00F525B9 /* Build configuration list for PBXNativeTarget "SwiftGit2-OSX" */;
buildPhases = (
50A682DD2AD9959500FDB557 /* Update libgit2 */,
BEB31F1E1A0D6F7A00F525B9 /* Sources */,
BEB31F1F1A0D6F7A00F525B9 /* Frameworks */,
BEB31F201A0D6F7A00F525B9 /* Headers */,
@@ -574,6 +550,7 @@
buildRules = (
);
dependencies = (
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */,
);
name = "SwiftGit2-OSX";
productName = "SwiftGit2-OSX";
@@ -598,6 +575,21 @@
productReference = BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */ = {
isa = PBXNativeTarget;
buildConfigurationList = BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */;
buildPhases = (
BEB31F931A0E567000F525B9 /* ShellScript */,
);
buildRules = (
);
dependencies = (
);
name = "libgit2-OSX";
productName = libgit2;
productReference = BEB31F8F1A0E563900F525B9 /* libgit2.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -622,6 +614,9 @@
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 1020;
};
BEB31F8E1A0E563900F525B9 = {
CreatedOnToolsVersion = 6.1;
};
C9CE0DD21E0710BD0053205D = {
CreatedOnToolsVersion = 8.2;
ProvisioningStyle = Automatic;
@@ -645,6 +640,7 @@
BEB31F2D1A0D6F7A00F525B9 /* SwiftGit2-OSXTests */,
621E66611C72958800A0F352 /* SwiftGit2-iOS */,
621E66B61C72958D00A0F352 /* SwiftGit2-iOSTests */,
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */,
621E66DC1C729CE500A0F352 /* libgit2-iOS */,
621E66E71C729EB800A0F352 /* OpenSSL-iOS */,
621E66ED1C729EBB00A0F352 /* libssh2-iOS */,
@@ -679,44 +675,21 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
50A682DD2AD9959500FDB557 /* Update libgit2 */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Update libgit2";
outputFileListPaths = (
);
outputPaths = (
"$(SRCROOT)/External/libgit2-mac/libgit2-mac.a",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "script/update_libgit2\n";
};
621E66DD1C729CE500A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
"$(SRCROOT)/External/libgit2-ios/libgit2.xcframework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "script/update_libgit2_ios\n";
shellScript = script/update_libgit2_ios;
};
621E66E81C729EB800A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -726,11 +699,10 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "script/update_libssl_ios\n";
shellScript = script/update_libssl_ios;
};
621E66EE1C729EBB00A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -740,11 +712,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "script/update_libssh2_ios\n";
shellScript = script/update_libssh2_ios;
};
BEB31F931A0E567000F525B9 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = script/update_libgit2;
};
C9CE0DD61E0710C20053205D /* Lint Sources */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -755,7 +739,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --lenient\nelse\n echo \"warning: SwiftLint is not installed\"\nfi\n";
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --lenient\nelse\n echo \"warning: SwiftLint is not installed\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
@@ -860,6 +844,11 @@
target = BEB31F221A0D6F7A00F525B9 /* SwiftGit2-OSX */;
targetProxy = BEB31F301A0D6F7A00F525B9 /* PBXContainerItemProxy */;
};
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = BEB31F8E1A0E563900F525B9 /* libgit2-OSX */;
targetProxy = BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@@ -867,7 +856,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
@@ -880,6 +868,9 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -894,7 +885,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
@@ -907,6 +897,9 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -996,8 +989,8 @@
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 5.0;
};
name = Debug;
@@ -1012,8 +1005,8 @@
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 5.0;
};
name = Release;
@@ -1028,14 +1021,14 @@
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
LIBRARY_SEARCH_PATHS = (
"External/libgit2-mac",
External/,
External,
"$(inherited)",
"$(PROJECT_DIR)/External/libgit2-mac",
);
OTHER_LDFLAGS = (
/opt/homebrew/lib/libssh2.a,
"-lgit2-mac",
"-lgit2",
"-force_load",
External/libgit2.a,
/usr/local/lib/libssh2.a,
"-lcrypto",
"-lssl",
"-lcurl",
@@ -1043,7 +1036,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
};
name = Debug;
};
@@ -1057,14 +1049,14 @@
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
LIBRARY_SEARCH_PATHS = (
"External/libgit2-mac",
External/,
External,
"$(inherited)",
"$(PROJECT_DIR)/External/libgit2-mac",
);
OTHER_LDFLAGS = (
/opt/homebrew/lib/libssh2.a,
"-lgit2-mac",
"-lgit2",
"-force_load",
External/libgit2.a,
/usr/local/lib/libssh2.a,
"-lcrypto",
"-lssl",
"-lcurl",
@@ -1072,7 +1064,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
};
name = Release;
};
@@ -1081,6 +1072,7 @@
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -1091,11 +1083,30 @@
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
BEB31F911A0E563900F525B9 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Debug;
};
BEB31F921A0E563900F525B9 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Release;
};
C9CE0DD41E0710BD0053205D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -1185,6 +1196,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */ = {
isa = XCConfigurationList;
buildConfigurations = (
BEB31F911A0E563900F525B9 /* Debug */,
BEB31F921A0E563900F525B9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C9CE0DD31E0710BD0053205D /* Build configuration list for PBXAggregateTarget "SwiftLint" */ = {
isa = XCConfigurationList;
buildConfigurations = (
+19 -2
View File
@@ -22,8 +22,23 @@ public enum Credentials {
case plaintext(username: String, password: String)
case sshMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials {
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
private static var previouslyUsedPointer: String? = nil
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials? {
// check if we had just seen this pointer
if pointer.debugDescription == previouslyUsedPointer {
// we have already used this pointer, so it is likely that libgit2
// has already freed the memory and using Unmanaged<>.fromOpaque will
// result in a BAD_ACCESS crash
return nil
} else {
// mark that we have used this pointer so that
// later attempts to use it in this function will
// be blocked
previouslyUsedPointer = pointer.debugDescription
// access the pointer and convert it into a
// Credentials Swift object
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
}
}
internal func toPointer() -> UnsafeMutableRawPointer {
@@ -55,6 +70,8 @@ internal func credentialsCallback(
result = git_cred_userpass_plaintext_new(cred, username, password)
case .sshMemory(let username, let publicKey, let privateKey, let passphrase):
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
default:
result = git_cred_default_new(cred)
}
return (result != GIT_OK.rawValue) ? -1 : 0
+1 -1
View File
@@ -9,7 +9,7 @@
import Quick
class FixturesSpec: QuickSpec {
override class func spec() {
override func spec() {
beforeSuite {
Fixtures.sharedInstance.setUp()
}
+1 -1
View File
@@ -11,7 +11,7 @@ import Nimble
import Quick
class OIDSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("OID(string:)") {
it("should be nil if string is too short") {
expect(OID(string: "123456789012345678901234567890123456789")).to(beNil())
+6 -6
View File
@@ -26,7 +26,7 @@ private extension Repository {
}
class SignatureSpec: FixturesSpec {
override class func spec() {
override func spec() {
describe("Signature(signature)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -88,7 +88,7 @@ class SignatureSpec: FixturesSpec {
}
class CommitSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Commit(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -169,7 +169,7 @@ class CommitSpec: QuickSpec {
}
class TreeEntrySpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Tree.Entry(attributes:object:name:)") {
it("should set its properties") {
let attributes = Int32(GIT_FILEMODE_BLOB.rawValue)
@@ -230,7 +230,7 @@ class TreeEntrySpec: QuickSpec {
}
class TreeSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Tree(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -281,7 +281,7 @@ class TreeSpec: QuickSpec {
}
class BlobSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Blob(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -330,7 +330,7 @@ class BlobSpec: QuickSpec {
}
class TagSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Tag(pointer)") {
it("should set its properties") {
let repo = Fixtures.simpleRepository
+3 -3
View File
@@ -25,7 +25,7 @@ private extension Repository {
}
class ReferenceSpec: FixturesSpec {
override class func spec() {
override func spec() {
describe("Reference(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -64,7 +64,7 @@ class ReferenceSpec: FixturesSpec {
}
class BranchSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("Branch(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.mantleRepository
@@ -119,7 +119,7 @@ class BranchSpec: QuickSpec {
}
class TagReferenceSpec: QuickSpec {
override class func spec() {
override func spec() {
describe("TagReference(pointer)") {
it("should work with an annotated tag") {
let repo = Fixtures.simpleRepository
+1 -1
View File
@@ -25,7 +25,7 @@ private extension Repository {
}
class RemoteSpec: FixturesSpec {
override class func spec() {
override func spec() {
describe("Remote(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.mantleRepository
+2 -2
View File
@@ -13,7 +13,7 @@ import Quick
// swiftlint:disable cyclomatic_complexity
class RepositorySpec: FixturesSpec {
override class func spec() {
override func spec() {
describe("Repository.Type.at(_:)") {
it("should work if the repo exists") {
let repo = Fixtures.simpleRepository
@@ -980,7 +980,7 @@ class RepositorySpec: FixturesSpec {
}
}
static func temporaryURL(forPurpose purpose: String) -> URL {
func temporaryURL(forPurpose purpose: String) -> URL {
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
return URL(fileURLWithPath: path)
+1 -1
View File
@@ -82,7 +82,7 @@ check_deps ()
done
brew_prefix=`brew --prefix`
expected_prefix=/opt/homebrew
expected_prefix=/usr/local
if [ "$brew_prefix" != "$expected_prefix" ]
then
+22 -30
View File
@@ -1,13 +1,15 @@
#!/bin/bash
# augment path to help it find cmake via homebrew
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
SCRIPT_DIR=$(dirname "$0")
source "${SCRIPT_DIR}/xcode_functions.sh"
function setup_build_environment ()
{
# augment path to help it find cmake installed in /usr/local/bin,
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
# ~/.MacOSX/environment.plist
PATH="/usr/local/bin:/opt/boxen/homebrew/bin:$PATH"
pushd "$SCRIPT_DIR/.." > /dev/null
ROOT_PATH="$PWD"
popd > /dev/null
@@ -20,7 +22,7 @@ function setup_build_environment ()
MACOSX_DEPLOYMENT_TARGET=""
XCODE_MAJOR_VERSION=$(xcode_major_version)
CAN_BUILD_64BIT="0"
# If IPHONEOS_DEPLOYMENT_TARGET has not been specified
@@ -28,30 +30,28 @@ function setup_build_environment ()
# directly (ie not from an Xcode proj)
if [ -z "${IPHONEOS_DEPLOYMENT_TARGET}" ]
then
IPHONEOS_DEPLOYMENT_TARGET="12.0"
IPHONEOS_DEPLOYMENT_TARGET="6.0"
fi
# Determine if we can be building 64-bit binaries
if [ "${XCODE_MAJOR_VERSION}" -ge "5" ] && [ $(echo ${IPHONEOS_DEPLOYMENT_TARGET} '>=' 6.0 | bc -l) == "1" ]
then
CAN_BUILD_64BIT="1"
fi
ARCHS=""
ARCHS="i386 armv7 armv7s"
if [ "${CAN_BUILD_64BIT}" -eq "1" ]
then
# For some stupid reason cmake needs simulator
# builds to be first
ARCHS="x86_64 ${ARCHS} arm64"
else
ARCHS="i386 ${ARCHS} armv7 armv7s"
fi
}
function build_all_archs ()
{
setup_build_environment
local setup=$1
local build_arch=$2
local finish_build=$3
@@ -63,15 +63,11 @@ function build_all_archs ()
for ARCH in ${ARCHS}
do
PLATFORMS=""
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] || [ "${ARCH}" == "arm64" ]
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]
then
PLATFORMS="${PLATFORMS} iphonesimulator"
fi
if [ "${ARCH}" == "arm64" ]
then
PLATFORMS="${PLATFORMS} iphoneos"
PLATFORM="iphonesimulator"
else
PLATFORM="iphoneos"
fi
SDKVERSION=$(ios_sdk_version)
@@ -83,21 +79,17 @@ function build_all_archs ()
HOST="${ARCH}-apple-darwin"
fi
echo "Building ${ARCH} for ${PLATFORMS}"
SDKNAME="${PLATFORM}${SDKVERSION}"
SDKROOT="$(ios_sdk_path ${SDKNAME})"
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH}"
echo "Please stand by..."
for PLATFORM in ${PLATFORMS}
do
SDKNAME="${PLATFORM}${SDKVERSION}"
SDKROOT="$(sdk_path ${SDKNAME})"
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH} on ${PLATFORM}"
echo "Please stand by..."
# run the per arch build command
eval $build_arch
done
# run the per arch build command
eval $build_arch
done
# finish the build (usually lipo)
eval $finish_build
}
+26 -102
View File
@@ -1,114 +1,38 @@
#!/bin/bash
#!/bin/sh
set -e
# augment path to help it find cmake via homebrew
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
# augment path to help it find cmake installed in /usr/local/bin,
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
# ~/.MacOSX/environment.plist
PATH="/usr/local/bin:$PATH"
SCRIPT_DIR=$(dirname "$0")
source "${SCRIPT_DIR}/xcode_functions.sh"
if [ "External/libgit2.a" -nt "External/libgit2" ]
then
echo "No update needed."
exit 0
fi
function setup_build_environment ()
{
pushd "$SCRIPT_DIR/.." > /dev/null
ROOT_PATH="$PWD"
popd > /dev/null
cd "External/libgit2"
CLANG="/usr/bin/xcrun clang"
CC="${CLANG}"
CPP="${CLANG} -E"
MACOSX_DEPLOYMENT_TARGET="10.13"
XCODE_MAJOR_VERSION=$(xcode_major_version)
XCODE_MINOR_VERSION=$(xcode_minor_version)
if [ "${XCODE_MAJOR_VERSION}" -lt "14" ]
then
echo "Requires Xcode 14 or newer."
exit 1
fi
ARCHS="x86_64 arm64"
}
function setup ()
{
if [ "${ROOT_PATH}/External/libgit2-mac/libgit2-mac.a" -nt "${ROOT_PATH}/External/libgit2" ]
then
echo "No update needed."
exit 0
fi
LIBRARY_NAME="libgit2"
LIB_PATH="${ROOT_PATH}/External/libgit2-mac"
rm -rf "${LIB_PATH}"
pushd "${ROOT_PATH}/External/libgit2" > /dev/null
}
function build_libgit2 ()
{
if [ -d "build" ]; then
rm -rf "build"
mkdir "build"
fi
pushd "build" > /dev/null
mkdir build
cd build
# install the each built arch somewhere sane
INSTALL_PREFIX="${LIB_PATH}/${SDKNAME}-${ARCH}.sdk"
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
-DLIBSSH2_INCLUDE_DIRS:PATH=/usr/local/include/ \
-DBUILD_CLAR:BOOL=OFF \
-DTHREADSAFE:BOOL=ON \
..
cmake --build .
mkdir -p "${INSTALL_PREFIX}"
LOG="${INSTALL_PREFIX}/build-libgit2.log"
echo "$LOG"
cmake \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DCMAKE_PREFIX_PATH:PATH="${ROOT_PATH}/External/libssh2-mac/bin/${SDKNAME}-${ARCH}.sdk" \
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}/" \
-DBUILD_CLAR:BOOL=OFF \
-DTHREADSAFE:BOOL=ON \
-DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${MACOSX_DEPLOYMENT_TARGET}" \
.. >> "${LOG}" 2>&1
cmake --build . --target install >> "${LOG}" 2>&1
# push the built library into the list
BUILT_LIB_PATHS+=("${INSTALL_PREFIX}/lib/libgit2.a")
popd > /dev/null
}
function fat_binary ()
{
echo "Building fat binary..."
lipo -create "${BUILT_LIB_PATHS[@]}" -output "${ROOT_PATH}/External/libgit2-mac/libgit2-mac.a"
echo "Building done."
popd > /dev/null
}
setup_build_environment
setup
echo "Building for ${ARCHS}"
for ARCH in ${ARCHS}
do
PLATFORM="macosx"
SDKVERSION=$(macos_sdk_version)
SDKNAME="${PLATFORM}${SDKVERSION}"
SDKROOT="$(sdk_path ${SDKNAME})"
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH}"
echo "Please stand by..."
# run the per arch build command
build_libgit2
done
fat_binary
product="libgit2.a"
install_path="../../${product}"
if [ "${product}" -nt "${install_path}" ]; then
cp -v "${product}" "${install_path}"
fi
echo "libgit2 has been updated."
+4 -66
View File
@@ -8,7 +8,7 @@ source "${SCRIPT_DIR}/ios_build_functions.sh"
function setup ()
{
if [ "${ROOT_PATH}/External/libgit2-ios/libgit2.xcframework" -nt "${ROOT_PATH}/External/libgit2" ]
if [ "${ROOT_PATH}/External/libgit2-ios/libgit2-ios.a" -nt "${ROOT_PATH}/External/libgit2" ]
then
echo "No update needed."
exit 0
@@ -49,14 +49,11 @@ function build_libgit2 ()
-DPKG_CONFIG_USE_CMAKE_PREFIX_PATH:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}/" \
-DBUILD_CLAR:BOOL=OFF \
-DBUILD_TESTS:BOOL=OFF \
-DREGEX_BACKEND:STRING="builtin" \
-DTHREADSAFE:BOOL=ON \
-DCURL:BOOL=OFF \
-DCMAKE_C_FLAGS:STRING="-fembed-bitcode" \
"${SYS_ROOT}" \
-DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${IPHONEOS_DEPLOYMENT_TARGET}" \
.. >> "${LOG}" 2>&1
cmake --build . --target install >> "${LOG}" 2>&1
@@ -67,72 +64,13 @@ function build_libgit2 ()
function fat_binary ()
{
echo "Building fat binary for simulator..."
echo "Building fat binary..."
# Collect all simulator build paths
for path in "${BUILT_LIB_PATHS[@]}"
do
case "$path" in
*libgit2-ios/iphonesimulator* )
SIMULATOR_LIB_PATHS+=("$path")
# Remember one header location (headers are the same, so overwriting doesn't matter)
base_dir=$(dirname $(dirname "${path}"))
HEADER_PATH="${base_dir}/include/git2.h"
;;
* )
# Ignore libs build for the actual phone
;;
esac
done
SIMULATOR_LIB_DIR="${ROOT_PATH}/External/libgit2-ios/iphonesimulator"
mkdir -p "${SIMULATOR_LIB_DIR}"
echo "... from ${SIMULATOR_LIB_PATHS[@]}"
lipo -create "${SIMULATOR_LIB_PATHS[@]}" -output "${SIMULATOR_LIB_DIR}/libgit2.a"
echo "Copying shared simulator header from ${HEADER_PATH}"
cp "${HEADER_PATH}" "${SIMULATOR_LIB_DIR}/libgit2.h"
lipo -create "${BUILT_LIB_PATHS[@]}" -output "${ROOT_PATH}/External/libgit2-ios/libgit2-ios.a"
echo "Building done."
}
function xcframework ()
{
echo "Building XCFramework..."
for path in "${BUILT_LIB_PATHS[@]}"
do
case "$path" in
*libgit2-ios/iphonesimulator* )
# Skip simulator library binaries
;;
* )
args+=("-library" "${path}")
base_dir=$(dirname $(dirname "${path}"))
args+=("-headers" "${base_dir}/include/git2.h")
;;
esac
done
args+=("-library" "${SIMULATOR_LIB_DIR}/libgit2.a")
args+=("-headers" "${SIMULATOR_LIB_DIR}/libgit2.h")
echo "... from ${args[@]}"
xcodebuild -create-xcframework \
"${args[@]}" \
-output "${ROOT_PATH}/External/libgit2-ios/libgit2.xcframework"
echo "Building done."
}
function combine_all_the_binaries ()
{
fat_binary
xcframework
popd > /dev/null
}
build_all_archs setup build_libgit2 combine_all_the_binaries
build_all_archs setup build_libgit2 fat_binary
+2 -2
View File
@@ -16,7 +16,7 @@ function setup ()
LIBRARY_NAME="libssh2"
}
function build_ssh2 ()
function build_ssh2 ()
{
mkdir -p "${ROOT_PATH}/External/libssh2-ios/lib" "${ROOT_PATH}/External/libssh2-ios/lib" "${ROOT_PATH}/External/libssh2-ios/src"
@@ -47,7 +47,7 @@ function fat_binary ()
lipo -create "${BUILT_LIBS[@]}" -output "${ROOT_PATH}/External/libssh2-ios/lib/libssh2-ios.a"
mkdir -p "${ROOT_PATH}/External/libssh2-ios/include/libssh2"
cp -R "${ROOT_PATH}/External/libssh2-ios/bin/iphonesimulator${SDKVERSION}-x86_64.sdk/include/libssh2.h" "${ROOT_PATH}/External/libssh2-ios/include/libssh2/"
cp -R "${ROOT_PATH}/External/libssh2-ios/bin/iphonesimulator${SDKVERSION}-i386.sdk/include/libssh2.h" "${ROOT_PATH}/External/libssh2-ios/include/libssh2/"
echo "Building done."
}
+2 -18
View File
@@ -14,11 +14,6 @@ function xcode_major_version ()
xcode_version | awk -F '.' '{ print $1 }'
}
function xcode_minor_version ()
{
xcode_version | awk -F '.' '{ print $2 }'
}
# Returns the latest iOS SDK version available via xcodebuild.
function ios_sdk_version ()
{
@@ -31,22 +26,11 @@ function ios_sdk_version ()
# iPhoneSimulator9.0.sdk - Simulator - iOS 9.0 (iphonesimulator9.0)
# SDKVersion: 9.0
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
}
function macos_sdk_version ()
{
# The grep command produces output like the following, singling out the
# SDKVersion of just the Mac SDKs:
#
# MacOSX11.0.sdk - macOS 11.0 (macosx11.0)
# SDKVersion: 11.0
# ...
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^MacOSX' | tail -n 1 | awk '{ print $2 }'
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
}
# Returns the path to the specified iOS SDK name
function sdk_path ()
function ios_sdk_path ()
{
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -i $1 | grep 'Path:' | awk '{ print $2 }'
}