From a660082a733237cb876d5a01b0d5cc4d7c4d7ebc Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 4 Jan 2025 11:23:29 -0800 Subject: [PATCH] Update libgit2 to 1.9 --- Cargo.toml | 4 ++-- README.md | 4 ++-- git2-curl/Cargo.toml | 4 ++-- git2-curl/src/lib.rs | 2 +- libgit2-sys/Cargo.toml | 2 +- libgit2-sys/build.rs | 2 +- libgit2-sys/lib.rs | 23 +++++++++++++++++------ libgit2-sys/libgit2 | 2 +- src/lib.rs | 2 +- src/repo.rs | 12 ++++++------ systest/build.rs | 1 + tests/add_extensions.rs | 21 ++++++++++++++------- tests/get_extensions.rs | 19 +++++++++++++------ tests/remove_extensions.rs | 6 +++--- 14 files changed, 65 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e6fd81f56..80fbd142bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git2" -version = "0.19.0" +version = "0.20.0" authors = ["Josh Triplett ", "Alex Crichton "] license = "MIT OR Apache-2.0" readme = "README.md" @@ -20,7 +20,7 @@ url = "2.0" bitflags = "2.1.0" libc = "0.2" log = "0.4.8" -libgit2-sys = { path = "libgit2-sys", version = "0.17.0" } +libgit2-sys = { path = "libgit2-sys", version = "0.18.0" } [target."cfg(all(unix, not(target_os = \"macos\")))".dependencies] openssl-sys = { version = "0.9.45", optional = true } diff --git a/README.md b/README.md index b23b24e35d..ae1c377da9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ libgit2 bindings for Rust. ```toml [dependencies] -git2 = "0.19.0" +git2 = "0.20.0" ``` ## Rust version requirements @@ -16,7 +16,7 @@ stable release as well. ## Version of libgit2 -Currently this library requires libgit2 1.8.1 (or newer patch versions). The +Currently this library requires libgit2 1.9.0 (or newer patch versions). The source for libgit2 is included in the libgit2-sys crate so there's no need to pre-install the libgit2 library, the libgit2-sys crate will figure that and/or build that for you. On the other hand, if an appropriate version of `libgit2` diff --git a/git2-curl/Cargo.toml b/git2-curl/Cargo.toml index f63819149d..11dae7f8a4 100644 --- a/git2-curl/Cargo.toml +++ b/git2-curl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git2-curl" -version = "0.20.0" +version = "0.21.0" authors = ["Josh Triplett ", "Alex Crichton "] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/git2-rs" @@ -16,7 +16,7 @@ edition = "2018" curl = "0.4.33" url = "2.0" log = "0.4" -git2 = { path = "..", version = "0.19", default-features = false } +git2 = { path = "..", version = "0.20", default-features = false } [dev-dependencies] civet = "0.11" diff --git a/git2-curl/src/lib.rs b/git2-curl/src/lib.rs index f480ffc71c..6fa4532772 100644 --- a/git2-curl/src/lib.rs +++ b/git2-curl/src/lib.rs @@ -15,7 +15,7 @@ //! > **NOTE**: At this time this crate likely does not support a `git push` //! > operation, only clones. -#![doc(html_root_url = "https://docs.rs/git2-curl/0.20")] +#![doc(html_root_url = "https://docs.rs/git2-curl/0.21")] #![deny(missing_docs)] #![warn(rust_2018_idioms)] #![cfg_attr(test, deny(warnings))] diff --git a/libgit2-sys/Cargo.toml b/libgit2-sys/Cargo.toml index ff911c99f5..68bf0c0048 100644 --- a/libgit2-sys/Cargo.toml +++ b/libgit2-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libgit2-sys" -version = "0.17.0+1.8.1" +version = "0.18.0+1.9.0" authors = ["Josh Triplett ", "Alex Crichton "] links = "git2" build = "build.rs" diff --git a/libgit2-sys/build.rs b/libgit2-sys/build.rs index 1abf628c6e..57686ad5cf 100644 --- a/libgit2-sys/build.rs +++ b/libgit2-sys/build.rs @@ -7,7 +7,7 @@ use std::process::Command; /// Tries to use system libgit2 and emits necessary build script instructions. fn try_system_libgit2() -> Result { let mut cfg = pkg_config::Config::new(); - match cfg.range_version("1.8.1".."1.9.0").probe("libgit2") { + match cfg.range_version("1.9.0".."1.10.0").probe("libgit2") { Ok(lib) => { for include in &lib.include_paths { println!("cargo:root={}", include.display()); diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 383db6c37e..03c4a0a34f 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.17")] +#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.18")] #![allow(non_camel_case_types, unused_extern_crates)] // This is required to link libz when libssh2-sys is not included. @@ -395,6 +395,15 @@ pub struct git_remote_callbacks { pub remote_ready: git_remote_ready_cb, pub payload: *mut c_void, pub resolve_url: git_url_resolve_cb, + pub update_refs: Option< + extern "C" fn( + *const c_char, + *const git_oid, + *const git_oid, + *mut git_refspec, + *mut c_void, + ) -> c_int, + >, } #[repr(C)] @@ -668,8 +677,7 @@ pub struct git_status_entry { git_enum! { pub enum git_checkout_strategy_t { - GIT_CHECKOUT_NONE = 0, - GIT_CHECKOUT_SAFE = 1 << 0, + GIT_CHECKOUT_SAFE = 0, GIT_CHECKOUT_FORCE = 1 << 1, GIT_CHECKOUT_RECREATE_MISSING = 1 << 2, GIT_CHECKOUT_ALLOW_CONFLICTS = 1 << 4, @@ -686,6 +694,7 @@ git_enum! { GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = 1 << 19, GIT_CHECKOUT_CONFLICT_STYLE_MERGE = 1 << 20, GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = 1 << 21, + GIT_CHECKOUT_NONE = 1 << 30, GIT_CHECKOUT_UPDATE_SUBMODULES = 1 << 16, GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = 1 << 17, @@ -808,10 +817,13 @@ pub struct git_blame_hunk { pub final_commit_id: git_oid, pub final_start_line_number: usize, pub final_signature: *mut git_signature, + pub final_committer: *mut git_signature, pub orig_commit_id: git_oid, pub orig_path: *const c_char, pub orig_start_line_number: usize, pub orig_signature: *mut git_signature, + pub orig_committer: *mut git_signature, + pub summary: *const c_char, pub boundary: c_char, } @@ -870,7 +882,6 @@ pub struct git_config_entry { pub origin_path: *const c_char, pub include_depth: c_uint, pub level: git_config_level_t, - pub free: Option, } git_enum! { @@ -2906,7 +2917,7 @@ extern "C" { message: *const c_char, tree: *const git_tree, parent_count: size_t, - parents: *const *mut git_commit, + parents: *mut *const git_commit, ) -> c_int; pub fn git_commit_create_buffer( out: *mut git_buf, @@ -2917,7 +2928,7 @@ extern "C" { message: *const c_char, tree: *const git_tree, parent_count: size_t, - parents: *const *mut git_commit, + parents: *mut *const git_commit, ) -> c_int; pub fn git_commit_header_field( out: *mut git_buf, diff --git a/libgit2-sys/libgit2 b/libgit2-sys/libgit2 index 36f7e21ad7..338e6fb681 160000 --- a/libgit2-sys/libgit2 +++ b/libgit2-sys/libgit2 @@ -1 +1 @@ -Subproject commit 36f7e21ad757a3dacc58cf7944329da6bc1d6e96 +Subproject commit 338e6fb681369ff0537719095e22ce9dc602dbf0 diff --git a/src/lib.rs b/src/lib.rs index f5ee545adc..01c9a93517 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,7 +65,7 @@ //! source `Repository`, to ensure that they do not outlive the repository //! itself. -#![doc(html_root_url = "https://docs.rs/git2/0.19")] +#![doc(html_root_url = "https://docs.rs/git2/0.20")] #![allow(trivial_numeric_casts, trivial_casts)] #![deny(missing_docs)] #![warn(rust_2018_idioms)] diff --git a/src/repo.rs b/src/repo.rs index cae4e90b2f..efdb49259e 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1302,9 +1302,9 @@ impl Repository { parents: &[&Commit<'_>], ) -> Result { let update_ref = crate::opt_cstr(update_ref)?; - let parent_ptrs = parents + let mut parent_ptrs = parents .iter() - .map(|p| p.raw() as *mut raw::git_commit) + .map(|p| p.raw() as *const raw::git_commit) .collect::>(); let message = CString::new(message)?; let mut raw = raw::git_oid { @@ -1321,7 +1321,7 @@ impl Repository { message, tree.raw(), parents.len() as size_t, - parent_ptrs.as_ptr() + parent_ptrs.as_mut_ptr() )); Ok(Binding::from_raw(&raw as *const _)) } @@ -1340,9 +1340,9 @@ impl Repository { tree: &Tree<'_>, parents: &[&Commit<'_>], ) -> Result { - let parent_ptrs = parents + let mut parent_ptrs = parents .iter() - .map(|p| p.raw() as *mut raw::git_commit) + .map(|p| p.raw() as *const raw::git_commit) .collect::>(); let message = CString::new(message)?; let buf = Buf::new(); @@ -1356,7 +1356,7 @@ impl Repository { message, tree.raw(), parents.len() as size_t, - parent_ptrs.as_ptr() + parent_ptrs.as_mut_ptr() )); Ok(buf) } diff --git a/systest/build.rs b/systest/build.rs index 85e8b4b437..9503af7e10 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -15,6 +15,7 @@ fn main() { .header("git2/sys/mempack.h") .header("git2/sys/repository.h") .header("git2/sys/cred.h") + .header("git2/sys/email.h") .header("git2/cred_helpers.h") .type_name(|s, _, _| s.to_string()); cfg.field_name(|_, f| match f { diff --git a/tests/add_extensions.rs b/tests/add_extensions.rs index f3e2c42ae3..d49c33cf79 100644 --- a/tests/add_extensions.rs +++ b/tests/add_extensions.rs @@ -10,14 +10,21 @@ fn test_add_extensions() -> Result<(), Error> { } let extensions = unsafe { get_extensions() }?; + let extensions: Vec<_> = extensions.iter().collect(); - assert_eq!(extensions.len(), 4); - assert_eq!(extensions.get(0), Some("custom")); - assert_eq!(extensions.get(1), Some("noop")); - // The objectformat extension was added in 1.6 - assert_eq!(extensions.get(2), Some("objectformat")); - // The worktreeconfig extension was added in 1.8 - assert_eq!(extensions.get(3), Some("worktreeconfig")); + assert_eq!( + extensions, + [ + Some("custom"), + Some("noop"), + // The objectformat extension was added in 1.6 + Some("objectformat"), + // The preciousobjects extension was added in 1.9 + Some("preciousobjects"), + // The worktreeconfig extension was added in 1.8 + Some("worktreeconfig") + ] + ); Ok(()) } diff --git a/tests/get_extensions.rs b/tests/get_extensions.rs index 3a9148f20b..2ac362d0ba 100644 --- a/tests/get_extensions.rs +++ b/tests/get_extensions.rs @@ -6,13 +6,20 @@ use git2::Error; #[test] fn test_get_extensions() -> Result<(), Error> { let extensions = unsafe { get_extensions() }?; + let extensions: Vec<_> = extensions.iter().collect(); - assert_eq!(extensions.len(), 3); - assert_eq!(extensions.get(0), Some("noop")); - // The objectformat extension was added in 1.6 - assert_eq!(extensions.get(1), Some("objectformat")); - // The worktreeconfig extension was added in 1.8 - assert_eq!(extensions.get(2), Some("worktreeconfig")); + assert_eq!( + extensions, + [ + Some("noop"), + // The objectformat extension was added in 1.6 + Some("objectformat"), + // The preciousobjects extension was added in 1.9 + Some("preciousobjects"), + // The worktreeconfig extension was added in 1.8 + Some("worktreeconfig") + ] + ); Ok(()) } diff --git a/tests/remove_extensions.rs b/tests/remove_extensions.rs index 5384daea5c..3e54b427b7 100644 --- a/tests/remove_extensions.rs +++ b/tests/remove_extensions.rs @@ -11,16 +11,16 @@ fn test_remove_extensions() -> Result<(), Error> { "!ignore", "!noop", "!objectformat", + "!preciousobjects", "!worktreeconfig", "other", ])?; } let extensions = unsafe { get_extensions() }?; + let extensions: Vec<_> = extensions.iter().collect(); - assert_eq!(extensions.len(), 2); - assert_eq!(extensions.get(0), Some("custom")); - assert_eq!(extensions.get(1), Some("other")); + assert_eq!(extensions, [Some("custom"), Some("other")]); Ok(()) }