Skip to content

Commit

Permalink
Add EOWNER and use main libgit2 branch
Browse files Browse the repository at this point in the history
Co-Authored-By: Eric Huss <43198+ehuss@users.noreply.github.com>
  • Loading branch information
davidkna and ehuss committed May 9, 2022
1 parent efa63de commit 0b1639f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
48 changes: 31 additions & 17 deletions libgit2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ fn main() {
let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
if try_to_use_system_libgit2 {
let mut cfg = pkg_config::Config::new();
if let Ok(lib) = cfg
.range_version("1.4.3".."1.5.0")
.print_system_libs(false)
.probe("libgit2")
{
if let Ok(lib) = cfg.range_version("1.4.3".."1.5.0").probe("libgit2") {
for include in &lib.include_paths {
println!("cargo:root={}", include.display());
}
Expand All @@ -45,20 +41,21 @@ fn main() {
cp_r("libgit2/include", &include);

cfg.include(&include)
.include("libgit2/src")
.include("libgit2/src/libgit2")
.include("libgit2/src/util")
.out_dir(dst.join("build"))
.warnings(false);

// Include all cross-platform C files
add_c_files(&mut cfg, "libgit2/src");
add_c_files(&mut cfg, "libgit2/src/xdiff");
add_c_files(&mut cfg, "libgit2/src/libgit2");
add_c_files(&mut cfg, "libgit2/src/util");
add_c_files(&mut cfg, "libgit2/src/libgit2/xdiff");

// These are activated by features, but they're all unconditionally always
// compiled apparently and have internal #define's to make sure they're
// compiled correctly.
add_c_files(&mut cfg, "libgit2/src/transports");
add_c_files(&mut cfg, "libgit2/src/streams");
add_c_files(&mut cfg, "libgit2/src/libgit2/transports");
add_c_files(&mut cfg, "libgit2/src/libgit2/streams");

// Always use bundled http-parser for now
cfg.include("libgit2/deps/http-parser")
Expand Down Expand Up @@ -87,11 +84,11 @@ fn main() {
// when when COMPILE_PCRE8 is not defined, which is the default.
add_c_files(&mut cfg, "libgit2/deps/pcre");

cfg.file("libgit2/src/allocators/failalloc.c");
cfg.file("libgit2/src/allocators/stdalloc.c");
cfg.file("libgit2/src/util/allocators/failalloc.c");
cfg.file("libgit2/src/util/allocators/stdalloc.c");

if windows {
add_c_files(&mut cfg, "libgit2/src/win32");
add_c_files(&mut cfg, "libgit2/src/util/win32");
cfg.define("STRSAFE_NO_DEPRECATE", None);
cfg.define("WIN32", None);
cfg.define("_WIN32_WINNT", Some("0x0600"));
Expand All @@ -103,7 +100,7 @@ fn main() {
cfg.define("__USE_MINGW_ANSI_STDIO", "1");
}
} else {
add_c_files(&mut cfg, "libgit2/src/unix");
add_c_files(&mut cfg, "libgit2/src/util/unix");
cfg.flag("-fvisibility=hidden");
}
if target.contains("solaris") || target.contains("illumos") {
Expand Down Expand Up @@ -161,9 +158,26 @@ fn main() {
cfg.define("SHA1DC_NO_STANDARD_INCLUDES", "1");
cfg.define("SHA1DC_CUSTOM_INCLUDE_SHA1_C", "\"common.h\"");
cfg.define("SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C", "\"common.h\"");
cfg.file("libgit2/src/hash/sha1/collisiondetect.c");
cfg.file("libgit2/src/hash/sha1/sha1dc/sha1.c");
cfg.file("libgit2/src/hash/sha1/sha1dc/ubc_check.c");
cfg.file("libgit2/src/util/hash/collisiondetect.c");
cfg.file("libgit2/src/util/hash/sha1dc/sha1.c");
cfg.file("libgit2/src/util/hash/sha1dc/ubc_check.c");

if https {
if windows {
features.push_str("#define GIT_SHA256_WIN32 1\n");
cfg.file("libgit2/src/util/hash/win32.c");
} else if target.contains("apple") {
features.push_str("#define GIT_SHA256_COMMON_CRYPTO 1\n");
cfg.file("libgit2/src/util/hash/common_crypto.c");
} else {
features.push_str("#define GIT_SHA256_OPENSSL 1\n");
cfg.file("libgit2/src/util/hash/openssl.c");
}
} else {
features.push_str("#define GIT_SHA256_BUILTIN 1\n");
cfg.file("libgit2/src/util/hash/builtin.c");
cfg.file("libgit2/src/util/hash/rfc6234/sha224-256.c");
}

if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
cfg.include(path);
Expand Down
1 change: 1 addition & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ git_enum! {
GIT_EMISMATCH = -33,
GIT_EINDEXDIRTY = -34,
GIT_EAPPLYFAIL = -35,
GIT_EOWNER = -36,
}
}

Expand Down
2 changes: 1 addition & 1 deletion libgit2-sys/libgit2
Submodule libgit2 updated 931 files
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl Error {
raw::GIT_EMISMATCH => super::ErrorCode::HashsumMismatch,
raw::GIT_EINDEXDIRTY => super::ErrorCode::IndexDirty,
raw::GIT_EAPPLYFAIL => super::ErrorCode::ApplyFail,
raw::GIT_EOWNER => super::ErrorCode::Owner,
_ => super::ErrorCode::GenericError,
}
}
Expand Down Expand Up @@ -163,6 +164,7 @@ impl Error {
ErrorCode::HashsumMismatch => raw::GIT_EMISMATCH,
ErrorCode::IndexDirty => raw::GIT_EINDEXDIRTY,
ErrorCode::ApplyFail => raw::GIT_EAPPLYFAIL,
ErrorCode::Owner => raw::GIT_EOWNER,
};
}

Expand Down Expand Up @@ -293,6 +295,7 @@ impl Error {
GIT_EMISMATCH,
GIT_EINDEXDIRTY,
GIT_EAPPLYFAIL,
GIT_EOWNER,
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ pub enum ErrorCode {
IndexDirty,
/// Patch application failed
ApplyFail,
/// The object is not owned by the current user
Owner,
}

/// An enumeration of possible categories of things that can have
Expand Down

0 comments on commit 0b1639f

Please sign in to comment.