diff --git a/.gitmodules b/.gitmodules index f27afa9218..95c45cce48 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "libgit2-sys/libgit2"] path = libgit2-sys/libgit2 url = https://github.com/libgit2/libgit2 - branch = maint/v0.28 diff --git a/Cargo.toml b/Cargo.toml index 160b14a7f2..2ceb4344ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git2" -version = "0.10.2" +version = "0.11.0" authors = ["Josh Triplett ", "Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" @@ -20,7 +20,7 @@ url = "2.0" bitflags = "1.1.0" libc = "0.2" log = "0.4.8" -libgit2-sys = { path = "libgit2-sys", version = "0.9.2" } +libgit2-sys = { path = "libgit2-sys", version = "0.10.0" } [target."cfg(all(unix, not(target_os = \"macos\")))".dependencies] openssl-sys = { version = "0.9.0", optional = true } diff --git a/git2-curl/Cargo.toml b/git2-curl/Cargo.toml index 599a0dddef..61d5fb8fd0 100644 --- a/git2-curl/Cargo.toml +++ b/git2-curl/Cargo.toml @@ -17,7 +17,7 @@ edition = "2018" curl = "0.4" url = "2.0" log = "0.4" -git2 = { path = "..", version = "0.10", default-features = false } +git2 = { path = "..", version = "0.11", default-features = false } [dev-dependencies] civet = "0.11" diff --git a/libgit2-sys/Cargo.toml b/libgit2-sys/Cargo.toml index 7c00f843dd..525f1192c1 100644 --- a/libgit2-sys/Cargo.toml +++ b/libgit2-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libgit2-sys" -version = "0.9.2" +version = "0.10.0" authors = ["Josh Triplett ", "Alex Crichton "] links = "git2" build = "build.rs" diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index e79864c8e8..77b4d616a4 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -148,6 +148,7 @@ pub struct git_time { pub type git_off_t = i64; pub type git_time_t = i64; +pub type git_object_size_t = u64; git_enum! { pub enum git_revparse_mode_t { @@ -401,6 +402,7 @@ git_enum! { GIT_CERT_NONE, GIT_CERT_X509, GIT_CERT_HOSTKEY_LIBSSH2, + GIT_CERT_STRARRAY, } } @@ -415,6 +417,7 @@ pub struct git_cert_hostkey { pub kind: git_cert_ssh_t, pub hash_md5: [u8; 16], pub hash_sha1: [u8; 20], + pub hash_sha256: [u8; 32], } #[repr(C)] @@ -428,6 +431,7 @@ git_enum! { pub enum git_cert_ssh_t { GIT_CERT_SSH_MD5 = 1 << 0, GIT_CERT_SSH_SHA1 = 1 << 1, + GIT_CERT_SSH_SHA256 = 1 << 2, } } @@ -447,9 +451,10 @@ pub struct git_transfer_progress { pub struct git_diff_file { pub id: git_oid, pub path: *const c_char, - pub size: git_off_t, + pub size: git_object_size_t, pub flags: u32, pub mode: u16, + pub id_abbrev: u16, } pub type git_repository_create_cb = @@ -819,6 +824,7 @@ pub const GIT_ATTR_CHECK_FILE_THEN_INDEX: u32 = 0; pub const GIT_ATTR_CHECK_INDEX_THEN_FILE: u32 = 1; pub const GIT_ATTR_CHECK_INDEX_ONLY: u32 = 2; pub const GIT_ATTR_CHECK_NO_SYSTEM: u32 = 1 << 2; +pub const GIT_ATTR_CHECK_INCLUDE_HEAD: u32 = 1 << 3; #[repr(C)] pub struct git_cred { @@ -1046,6 +1052,7 @@ git_enum! { GIT_DIFF_FORMAT_RAW = 3, GIT_DIFF_FORMAT_NAME_ONLY = 4, GIT_DIFF_FORMAT_NAME_STATUS = 5, + GIT_DIFF_FORMAT_PATCH_ID = 6, } } @@ -1169,14 +1176,14 @@ git_enum! { #[repr(C)] pub struct git_merge_options { pub version: c_uint, - pub flags: git_merge_flag_t, + pub flags: u32, pub rename_threshold: c_uint, pub target_limit: c_uint, pub metric: *mut git_diff_similarity_metric, pub recursion_limit: c_uint, pub default_driver: *const c_char, pub file_favor: git_merge_file_favor_t, - pub file_flags: git_merge_file_flag_t, + pub file_flags: u32, } git_enum! { @@ -1337,7 +1344,7 @@ pub struct git_odb_backend { extern "C" fn( *mut *mut git_odb_stream, *mut git_odb_backend, - git_off_t, + git_object_size_t, git_object_t, ) -> c_int, >, @@ -1573,7 +1580,7 @@ git_enum! { #[repr(C)] pub struct git_stash_apply_options { pub version: c_uint, - pub flags: git_stash_apply_flags, + pub flags: u32, pub checkout_options: git_checkout_options, pub progress_cb: Option, pub progress_payload: *mut c_void, @@ -2206,7 +2213,7 @@ extern "C" { len: size_t, ) -> c_int; pub fn git_blob_rawcontent(blob: *const git_blob) -> *const c_void; - pub fn git_blob_rawsize(blob: *const git_blob) -> git_off_t; + pub fn git_blob_rawsize(blob: *const git_blob) -> git_object_size_t; pub fn git_blob_create_frombuffer( id: *mut git_oid, repo: *mut git_repository, @@ -3298,7 +3305,7 @@ extern "C" { pub fn git_odb_open_wstream( out: *mut *mut git_odb_stream, db: *mut git_odb, - size: git_off_t, + size: git_object_size_t, obj_type: git_object_t, ) -> c_int; pub fn git_odb_stream_write( diff --git a/libgit2-sys/libgit2 b/libgit2-sys/libgit2 index 08cfa43d0e..6bd37c3409 160000 --- a/libgit2-sys/libgit2 +++ b/libgit2-sys/libgit2 @@ -1 +1 @@ -Subproject commit 08cfa43d0e1a9214a2f1239593686078e75e5636 +Subproject commit 6bd37c3409d759cb4a2a87ffee7494a798999f20 diff --git a/src/call.rs b/src/call.rs index 1509517c0c..f1ade4a8f3 100644 --- a/src/call.rs +++ b/src/call.rs @@ -181,6 +181,7 @@ mod impls { DiffFormat::Raw => raw::GIT_DIFF_FORMAT_RAW, DiffFormat::NameOnly => raw::GIT_DIFF_FORMAT_NAME_ONLY, DiffFormat::NameStatus => raw::GIT_DIFF_FORMAT_NAME_STATUS, + DiffFormat::PatchId => raw::GIT_DIFF_FORMAT_PATCH_ID, } } } diff --git a/src/cert.rs b/src/cert.rs index 80c4ed345a..9153880b69 100644 --- a/src/cert.rs +++ b/src/cert.rs @@ -76,6 +76,17 @@ impl<'a> CertHostkey<'a> { } } } + + /// Returns the SHA-256 hash of the hostkey, if available. + pub fn hash_sha256(&self) -> Option<&[u8; 32]> { + unsafe { + if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_SHA256 as u32 == 0 { + None + } else { + Some(&(*self.raw).hash_sha256) + } + } + } } impl<'a> CertX509<'a> { diff --git a/src/lib.rs b/src/lib.rs index e24196c1b2..9533b0e47f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1187,6 +1187,8 @@ pub enum DiffFormat { NameOnly, /// like git diff --name-status NameStatus, + /// git diff as used by git patch-id + PatchId, } bitflags! { diff --git a/src/merge.rs b/src/merge.rs index edf7cee64d..417f12bbd3 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -44,7 +44,7 @@ impl MergeOptions { opts } - fn flag(&mut self, opt: raw::git_merge_flag_t, val: bool) -> &mut MergeOptions { + fn flag(&mut self, opt: u32, val: bool) -> &mut MergeOptions { if val { self.raw.flags |= opt; } else { @@ -55,25 +55,25 @@ impl MergeOptions { /// Detect file renames pub fn find_renames(&mut self, find: bool) -> &mut MergeOptions { - self.flag(raw::GIT_MERGE_FIND_RENAMES, find) + self.flag(raw::GIT_MERGE_FIND_RENAMES as u32, find) } /// If a conflict occurs, exit immediately instead of attempting to continue /// resolving conflicts pub fn fail_on_conflict(&mut self, fail: bool) -> &mut MergeOptions { - self.flag(raw::GIT_MERGE_FAIL_ON_CONFLICT, fail) + self.flag(raw::GIT_MERGE_FAIL_ON_CONFLICT as u32, fail) } /// Do not write the REUC extension on the generated index pub fn skip_reuc(&mut self, skip: bool) -> &mut MergeOptions { - self.flag(raw::GIT_MERGE_FAIL_ON_CONFLICT, skip) + self.flag(raw::GIT_MERGE_FAIL_ON_CONFLICT as u32, skip) } /// If the commits being merged have multiple merge bases, do not build a /// recursive merge base (by merging the multiple merge bases), instead /// simply use the first base. pub fn no_recursive(&mut self, disable: bool) -> &mut MergeOptions { - self.flag(raw::GIT_MERGE_NO_RECURSIVE, disable) + self.flag(raw::GIT_MERGE_NO_RECURSIVE as u32, disable) } /// Similarity to consider a file renamed (default 50) @@ -106,7 +106,7 @@ impl MergeOptions { self } - fn file_flag(&mut self, opt: raw::git_merge_file_flag_t, val: bool) -> &mut MergeOptions { + fn file_flag(&mut self, opt: u32, val: bool) -> &mut MergeOptions { if val { self.raw.file_flags |= opt; } else { @@ -117,42 +117,42 @@ impl MergeOptions { /// Create standard conflicted merge files pub fn standard_style(&mut self, standard: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_STYLE_MERGE, standard) + self.file_flag(raw::GIT_MERGE_FILE_STYLE_MERGE as u32, standard) } /// Create diff3-style file pub fn diff3_style(&mut self, diff3: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_STYLE_DIFF3, diff3) + self.file_flag(raw::GIT_MERGE_FILE_STYLE_DIFF3 as u32, diff3) } /// Condense non-alphanumeric regions for simplified diff file pub fn simplify_alnum(&mut self, simplify: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_SIMPLIFY_ALNUM, simplify) + self.file_flag(raw::GIT_MERGE_FILE_SIMPLIFY_ALNUM as u32, simplify) } /// Ignore all whitespace pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE, ignore) + self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE as u32, ignore) } /// Ignore changes in amount of whitespace pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE, ignore) + self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE as u32, ignore) } /// Ignore whitespace at end of line pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL, ignore) + self.file_flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL as u32, ignore) } /// Use the "patience diff" algorithm pub fn patience(&mut self, patience: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_DIFF_PATIENCE, patience) + self.file_flag(raw::GIT_MERGE_FILE_DIFF_PATIENCE as u32, patience) } /// Take extra time to find minimal diff pub fn minimal(&mut self, minimal: bool) -> &mut MergeOptions { - self.file_flag(raw::GIT_MERGE_FILE_DIFF_MINIMAL, minimal) + self.file_flag(raw::GIT_MERGE_FILE_DIFF_MINIMAL as u32, minimal) } /// Acquire a pointer to the underlying raw options. diff --git a/src/odb.rs b/src/odb.rs index aff1b19b26..75857b2e37 100644 --- a/src/odb.rs +++ b/src/odb.rs @@ -81,7 +81,7 @@ impl<'repo> Odb<'repo> { try_call!(raw::git_odb_open_wstream( &mut out, self.raw, - size as raw::git_off_t, + size as raw::git_object_size_t, obj_type.raw() )); Ok(OdbWriter::from_raw(out)) diff --git a/src/stash.rs b/src/stash.rs index f2654fa950..ad4155e64e 100644 --- a/src/stash.rs +++ b/src/stash.rs @@ -46,7 +46,7 @@ impl<'cb> StashApplyOptions<'cb> { /// Set stash application flag to GIT_STASH_APPLY_REINSTATE_INDEX pub fn reinstantiate_index(&mut self) -> &mut StashApplyOptions<'cb> { - self.raw_opts.flags = raw::GIT_STASH_APPLY_REINSTATE_INDEX; + self.raw_opts.flags = raw::GIT_STASH_APPLY_REINSTATE_INDEX as u32; self } diff --git a/systest/build.rs b/systest/build.rs index 57bb7c3bd8..23a57bdc1e 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -13,6 +13,7 @@ fn main() { .header("git2/sys/odb_backend.h") .header("git2/sys/mempack.h") .header("git2/sys/repository.h") + .header("git2/sys/cred.h") .header("git2/cred_helpers.h") .type_name(|s, _, _| s.to_string()); cfg.field_name(|_, f| match f {