Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*]
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions GitUp/Application/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ - (WelcomeWindowController*)welcomeWindowController {

#pragma mark - Initialize
+ (void)initialize {
// Ignore when libgit2 writes on a closed pipe
// This signal() call causes libgit's closed pipe writes to fail with an EPIPE error, which libgit2 seems to handle correctly.
// Without this line, GitUp would instead immediately exit, with no crash log.
// libgit2 has what looks like a built-in solution (`disable_signals()`), but it doesn't seem to work for us.
signal(SIGPIPE, SIG_IGN);

NSDictionary* defaults = @{
GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters : @(YES),
GICommitMessageViewUserDefaultKey_ShowMargins : @(YES),
Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Core/GCTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ - (GCLiveRepository *)liveRepository {
}

- (GCRepository *)createLocalRepositoryAtPath:(NSString *)path bare:(BOOL)bare {
GCLiveRepository* repo = [[GCLiveRepository alloc] initWithNewLocalRepository:path bare:bare error:NULL];
GCLiveRepository* repo = [[GCLiveRepository alloc] initWithNewLocalRepository:path bare:bare defaultBranchName:@"master" error:NULL];
XCTAssertNotNil(repo);

repo.delegate = self;
Expand Down
33 changes: 33 additions & 0 deletions GitUpKit/GitUpKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,31 @@
PRODUCT_NAME = GitUpKit;
SDKROOT = macosx;
SKIP_INSTALL = YES;
WARNING_CFLAGS = (
"-Wall",
"-Weverything",
"-Wno-pedantic",
"-Wno-padded",
"-Wno-direct-ivar-access",
"-Wno-documentation-unknown-command",
"-Wno-objc-missing-property-synthesis",
"-Wno-implicit-retain-self",
"-Wno-explicit-ownership-type",
"-Wno-assign-enum",
"-Wno-cast-align",
"-Wno-switch-enum",
"-Wno-cstring-format-directive",
"-Wno-cast-qual",
"-Wno-nullable-to-nonnull-conversion",
"-Wno-reserved-id-macro",
"-Wno-nonnull",
"-Wno-double-promotion",
"-Wno-objc-messaging-id",
"-Wno-auto-import",
"-Wno-atimport-in-framework-header",
"-Wno-declaration-after-statement",
"-Wno-documentation-deprecated-sync",
);
};
name = Debug;
};
Expand All @@ -1660,6 +1685,14 @@
PRODUCT_NAME = GitUpKit;
SDKROOT = macosx;
SKIP_INSTALL = YES;
WARNING_CFLAGS = (
"-Wall",
"-Wno-nonnull",
"-Wno-property-attribute-mismatch",
"-Wno-auto-import",
"-Wno-atimport-in-framework-header",
"-Wno-documentation-deprecated-sync",
);
};
name = Release;
};
Expand Down
154 changes: 114 additions & 40 deletions GitUpKit/Third-Party/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import PackageDescription
import Foundation

let libgit2OriginPath = "./libgit2"
let httpClientPath = "\(libgit2OriginPath)/deps/http-parser"
let llhttpPath = "\(libgit2OriginPath)/deps/llhttp"
let ntlmClientPath = "\(libgit2OriginPath)/deps/ntlmclient"

let librariesPath = "."
let libssh2Path = "\(librariesPath)/libssh2.xcframework"
let libsslPath = "\(librariesPath)/libssl.xcframework"
let libcryptoPath = "\(librariesPath)/libcrypto.xcframework"

let silenceWarningsCSettings: [CSetting] = [ // to see libgit2 warnings, set to empty array
CSetting.unsafeFlags(["-w"])
]

enum FeaturesExtractor {
private struct Define: CustomStringConvertible {
let define: String
Expand Down Expand Up @@ -70,35 +74,29 @@ let package = Package(
name: "SwiftPackage",
platforms: [.macOS(.v10_13)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(name: "Libgit2Origin",
targets: ["Libgit2Origin"]
),
.library(name: "http-client",
targets: ["http-client"]
.library(name: "llhttp",
targets: ["llhttp"]
),
.library(name: "ntlmclient",
targets: ["ntlmclient"]
),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
// Since we don't run libgit2's actual CMake build, we need to replicate its effects here: the files it includes, and the options it resolves
.target(name: "Libgit2Origin",
dependencies: [
"libssh2", "libssl", "libcrypto", "http-client", "ntlmclient"
"libssl", "libcrypto", "llhttp", "ntlmclient"
],
path: libgit2OriginPath,
exclude: [
// ./
"xcode",
"ci",
"cmake",
"deps",
"docs",
"examples",
"fuzzers",
Expand All @@ -113,43 +111,119 @@ let package = Package(
"README.md",
"SECURITY.md",
"update-xcode.sh",

// ./deps/
"deps/chromium-zlib",
"deps/llhttp",
"deps/ntlmclient",
"deps/pcre",
"deps/winhttp",
// xdiff is the only dependency we're building as part of the Libgit2Origin target, because it seems to need access to some libgit2 files
"deps/zlib",

// ./deps/
"deps/xdiff/CMakeLists.txt",

// ./src/
"src/cli",
"src/CMakeLists.txt",
"src/features.h.in",
// ./src/hash/sha1
"src/hash/sha1/common_crypto.h",
"src/hash/sha1/common_crypto.c",
"src/hash/sha1/generic.h",
"src/hash/sha1/generic.c",
"src/hash/sha1/mbedtls.h",
"src/hash/sha1/mbedtls.c",
"src/hash/sha1/openssl.h",
"src/hash/sha1/openssl.c",
"src/hash/sha1/win32.h",
"src/hash/sha1/win32.c",
// ./src/hash/
"src/hash/sha1.h",

// ./src/win32
"src/win32",
"src/README.md",

// ./src/libgit2/
"src/libgit2/CMakeLists.txt",
"src/libgit2/config.cmake.in",
"src/libgit2/experimental.h.in",
"src/libgit2/git2.rc",

// ./src/util/
"src/util/CMakeLists.txt",
"src/util/git2_features.h.in",
"src/util/win32",

// ./src/util/hash/
"src/util/hash/builtin.h",
"src/util/hash/builtin.c",
"src/util/hash/mbedtls.h",
"src/util/hash/mbedtls.c",
"src/util/hash/openssl.h",
"src/util/hash/openssl.c",
"src/util/hash/sha1dc/sha1.h",
"src/util/hash/win32.h",
"src/util/hash/win32.c",

// ./include/git2/
"include/git2/stdint.h",

],
sources: ["src"],
sources: ["deps/xdiff", "src"],
resources: nil,
publicHeadersPath: "include",
cSettings: [
.headerSearchPath("src"),
.headerSearchPath("deps/http-parser"),
.headerSearchPath("src/libgit2"),
.headerSearchPath("src/util"),
.headerSearchPath("deps/llhttp"),
.headerSearchPath("deps/ntlmclient"),
.headerSearchPath("deps/xdiff"),

.define("HAVE_QSORT_R_BSD"),
.define("_FILE_OFFSET_BITS", to: "64"),
.define("GIT_IO_POLL", to: "1"),
.define("GIT_IO_SELECT", to: "1"),
.define("GIT_HTTPPARSER_BUILTIN", to: "1"),

// Above we exclude git2_features.h.in, which is a template suppose to set feature flags.
// So we need to 1. tell libgit2 the file isn't included and 2. manually set the flags here.
.define("LIBGIT2_NO_FEATURES_H", to: "1"),

.define("GIT_TRACE", to: "1"),
.define("GIT_THREADS", to: "1"),
.define("GIT_ARCH_64", to: "1"),
.define("GIT_USE_ICONV", to: "1"),
.define("GIT_USE_NSEC", to: "1"),
.define("GIT_USE_STAT_MTIMESPEC", to: "1"),
.define("GIT_USE_FUTIMENS", to: "1"),
.define("GIT_REGEX_REGCOMP_L"),
.define("GIT_NTLM", to: "1"),
.define("GIT_HTTPS", to: "1"),
.define("GIT_SECURE_TRANSPORT", to: "1"),
.define("GIT_SHA1_COLLISIONDETECT", to: "1"),
.define("GIT_SSH_MEMORY_CREDENTIALS", to: "1"),
.define("GIT_SSH", to: "1"),

// See libgit2/cmake/SelectRegex.cmake
.define("GIT_REGEX_REGCOMP_L", to: "1"),

// Options set when USE_SSH="exec" (default value is ON. exec uses OpenSSH, which supports SSH config files)
// See libgit2/cmake/SelectSSH.cmake
.define("USE_SSH", to: "exec"),
.define("GIT_SSH", to: "1"),
.define("GIT_SSH_EXEC", to: "1"),

// Options set when USE_HTTPS="ON" (default value)
// See libgit2/cmake/SelectHTTPSBackend.cmake
.define("USE_HTTPS", to: "SecureTransport"),

// Options set when USE_SHA1="CollisionDetection" (default value)
// See libgit2/cmake/SelectHashes.cmake, libgit2/src/util/CMakeLists.txt
.define("USE_SHA1", to: "CollisionDetection"),
.define("GIT_SHA1_COLLISIONDETECT", to: "1"),
.define("SHA1DC_NO_STANDARD_INCLUDES", to: "1"),
.define("SHA1DC_CUSTOM_INCLUDE_SHA1_C", to: "\"common.h\""),
.define("SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C", to: "\"common.h\""),
] + FeaturesExtractor.extraLibgit2CSettings(),
.define("SHA1DC_CUSTOM_INCLUDE_SHA1_C", to: "\"git2_util.h\""),
.define("SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C", to: "\"git2_util.h\""),

// Options set when USE_SHA256="ON" (default value)
// See libgit2/cmake/SelectHashes.cmake
.define("USE_SHA256", to: "CommonCrypto"),
.define("GIT_SHA256_COMMON_CRYPTO", to: "1"),

// Options set when USE_THREADS="ON" (default value)
// See libgit2/src/CMakeLists.txt
.define("GIT_THREADS", to: "1"),

]
+ FeaturesExtractor.extraLibgit2CSettings()
+ silenceWarningsCSettings,
cxxSettings: nil,
swiftSettings: nil,
linkerSettings: [
Expand All @@ -160,17 +234,16 @@ let package = Package(
]
),

.target(name: "http-client",
.target(name: "llhttp",
dependencies: [],
path: httpClientPath,
path: llhttpPath,
exclude: [
"CMakeLists.txt",
"COPYING"
"CMakeLists.txt"
],
sources: nil,
resources: nil,
publicHeadersPath: ".",
cSettings: [],
cSettings: silenceWarningsCSettings,
cxxSettings: nil,
swiftSettings: nil,
linkerSettings: []
Expand All @@ -191,15 +264,16 @@ let package = Package(
"ntlm.c",
"unicode_iconv.c",
"util.c",
"crypt_commoncrypto.c"
"crypt_commoncrypto.c"// maybe include
],
resources: nil,
publicHeadersPath: ".",
cSettings: [
.define("NTLM_STATIC", to: "1"),
.define("CRYPT_COMMONCRYPTO"),
.define("UNICODE_ICONV", to: "1")
],
]
+ silenceWarningsCSettings,
cxxSettings: nil,
swiftSettings: nil,
linkerSettings: []
Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Third-Party/libgit2
Submodule libgit2 updated 1773 files