From 6a3b2dd559a8e831cc0a820b3b8d02ea32df0a87 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Sun, 28 Nov 2021 23:02:26 +0100 Subject: [PATCH] Upgrade libgit2 to 1.3.0 --- deps/libgit2.mk | 18 ++-------- deps/libgit2.version | 4 +-- deps/patches/libgit2-continue-zlib.patch | 43 ---------------------- deps/patches/libgit2-hostkey.patch | 44 ++--------------------- deps/patches/libgit2-mbedtls-incdir.patch | 22 ------------ stdlib/LibGit2/src/callbacks.jl | 2 +- stdlib/LibGit2/src/types.jl | 3 ++ stdlib/LibGit2_jll/src/LibGit2_jll.jl | 4 +-- 8 files changed, 12 insertions(+), 128 deletions(-) delete mode 100644 deps/patches/libgit2-continue-zlib.patch delete mode 100644 deps/patches/libgit2-mbedtls-incdir.patch diff --git a/deps/libgit2.mk b/deps/libgit2.mk index 8f6ab58bc00dad..e3f5be7d19cb2e 100644 --- a/deps/libgit2.mk +++ b/deps/libgit2.mk @@ -40,28 +40,14 @@ $(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied: $(LIBGIT2_SRC_PATH)/so patch -p1 -f < $(SRCDIR)/patches/libgit2-agent-nonfatal.patch echo 1 > $@ -# This can be removed once a release with https://github.com/libgit2/libgit2/pull/5685 lands -$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-incdir.patch-applied: $(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied - cd $(LIBGIT2_SRC_PATH) && \ - patch -p1 -f < $(SRCDIR)/patches/libgit2-mbedtls-incdir.patch - echo 1 > $@ - -$(LIBGIT2_SRC_PATH)/libgit2-hostkey.patch-applied: $(LIBGIT2_SRC_PATH)/libgit2-mbedtls-incdir.patch-applied +$(LIBGIT2_SRC_PATH)/libgit2-hostkey.patch-applied: cd $(LIBGIT2_SRC_PATH) && \ patch -p1 -f < $(SRCDIR)/patches/libgit2-hostkey.patch echo 1 > $@ -# This can be removed once a release with https://github.com/libgit2/libgit2/pull/5740 lands -$(LIBGIT2_SRC_PATH)/libgit2-continue-zlib.patch-applied: $(LIBGIT2_SRC_PATH)/libgit2-hostkey.patch-applied - cd $(LIBGIT2_SRC_PATH) && \ - patch -p1 -f < $(SRCDIR)/patches/libgit2-continue-zlib.patch - echo 1 > $@ - $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: \ $(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied \ - $(LIBGIT2_SRC_PATH)/libgit2-mbedtls-incdir.patch-applied \ - $(LIBGIT2_SRC_PATH)/libgit2-hostkey.patch-applied \ - $(LIBGIT2_SRC_PATH)/libgit2-continue-zlib.patch-applied + $(LIBGIT2_SRC_PATH)/libgit2-hostkey.patch-applied $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: $(LIBGIT2_SRC_PATH)/source-extracted mkdir -p $(dir $@) diff --git a/deps/libgit2.version b/deps/libgit2.version index 7c7c34a4909e0c..042f76bba673e0 100644 --- a/deps/libgit2.version +++ b/deps/libgit2.version @@ -1,2 +1,2 @@ -LIBGIT2_BRANCH=v1.1.0 -LIBGIT2_SHA1=7f4fa178629d559c037a1f72f79f79af9c1ef8ce +LIBGIT2_BRANCH=v1.3.0 +LIBGIT2_SHA1=b7bad55e4bb0a285b073ba5e02b01d3f522fc95d diff --git a/deps/patches/libgit2-continue-zlib.patch b/deps/patches/libgit2-continue-zlib.patch deleted file mode 100644 index 023b8265187b8f..00000000000000 --- a/deps/patches/libgit2-continue-zlib.patch +++ /dev/null @@ -1,43 +0,0 @@ -commit 99ddda527b0e1964898c2bc9fbc23ea7afe96ae5 -Author: Edward Thomson -Date: Tue Dec 15 23:03:03 2020 +0000 - - pack: continue zlib while we can make progress - - Continue the zlib stream as long as we can make progress; stop when we - stop getting output _or_ when zlib stops taking input from us. - - (cherry picked from commit 93f61c5a9f638e76189cef2dbde7839a9af5ff54) - -diff --git a/src/pack.c b/src/pack.c -index 1b5cf670f..1a208a051 100644 ---- a/src/pack.c -+++ b/src/pack.c -@@ -841,7 +841,7 @@ static int packfile_unpack_compressed( - - do { - size_t bytes = buffer_len - total; -- unsigned int window_len; -+ unsigned int window_len, consumed; - unsigned char *in; - - if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) { -@@ -857,10 +857,15 @@ static int packfile_unpack_compressed( - - git_mwindow_close(mwindow); - -- if (!bytes) -- break; -+ consumed = window_len - (unsigned int)zstream.in_len; -+ -+ if (!bytes && !consumed) { -+ git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream"); -+ error = -1; -+ goto out; -+ } - -- *position += window_len - zstream.in_len; -+ *position += consumed; - total += bytes; - } while (!git_zstream_eos(&zstream)); - diff --git a/deps/patches/libgit2-hostkey.patch b/deps/patches/libgit2-hostkey.patch index f07d4d1e0a116f..167222b1c3e10c 100644 --- a/deps/patches/libgit2-hostkey.patch +++ b/deps/patches/libgit2-hostkey.patch @@ -1,48 +1,8 @@ -diff --git a/include/git2/cert.h b/include/git2/cert.h -index e8cd2d180..54293cd31 100644 ---- a/include/git2/cert.h -+++ b/include/git2/cert.h -@@ -111,6 +111,14 @@ typedef struct { - * have the SHA-256 hash of the hostkey. - */ - unsigned char hash_sha256[32]; -+ -+ /** -+ * Hostkey itself. -+ */ -+ int hostkey_type; -+ size_t hostkey_len; -+ unsigned char hostkey[1024]; -+ - } git_cert_hostkey; - - /** diff --git a/src/transports/ssh.c b/src/transports/ssh.c -index f4ed05bb1..ec6366a5f 100644 +index 471c3273ed..5ed7278ed6 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c -@@ -523,6 +523,7 @@ static int _git_ssh_setup_conn( - git_credential *cred = NULL; - LIBSSH2_SESSION* session=NULL; - LIBSSH2_CHANNEL* channel=NULL; -+ char *host_and_port; - - t->current_stream = NULL; - -@@ -566,6 +567,12 @@ post_extract: - - cert.parent.cert_type = GIT_CERT_HOSTKEY_LIBSSH2; - -+ key = libssh2_session_hostkey(session, &cert.hostkey_len, &cert.hostkey_type); -+ bzero(&cert.hostkey, sizeof(cert.hostkey)); -+ if (cert.hostkey_len > sizeof(cert.hostkey)) -+ cert.hostkey_len = sizeof(cert.hostkey); -+ memcpy(&cert.hostkey, key, cert.hostkey_len); -+ - #ifdef LIBSSH2_HOSTKEY_HASH_SHA256 - key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA256); - if (key != NULL) { -@@ -597,7 +604,15 @@ post_extract: +@@ -636,7 +636,15 @@ post_extract: cert_ptr = &cert; diff --git a/deps/patches/libgit2-mbedtls-incdir.patch b/deps/patches/libgit2-mbedtls-incdir.patch deleted file mode 100644 index 995200c9bd0169..00000000000000 --- a/deps/patches/libgit2-mbedtls-incdir.patch +++ /dev/null @@ -1,22 +0,0 @@ -commit 1822b0827a652d5c970a3a906e1801fb8251135b -Author: Elliot Saba -Date: Tue Oct 20 23:26:47 2020 +0000 - - Include `${MBEDTLS_INCLUDE_DIR}` when compiling `crypt_mbedtls.c` - - Without this, mbedTLS installs in non-default install locations - that are otherwise found by the `FindmbedTLS.cmake` module are not - found by the C preprocessor at compile time. - -diff --git a/deps/ntlmclient/CMakeLists.txt b/deps/ntlmclient/CMakeLists.txt -index 5fbf0d0f4..d933f4919 100644 ---- a/deps/ntlmclient/CMakeLists.txt -+++ b/deps/ntlmclient/CMakeLists.txt -@@ -16,6 +16,7 @@ ELSEIF(USE_HTTPS STREQUAL "OpenSSL") - SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c") - ELSEIF(USE_HTTPS STREQUAL "mbedTLS") - ADD_DEFINITIONS(-DCRYPT_MBEDTLS) -+ INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR}) - SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c") - ELSE() - MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto") diff --git a/stdlib/LibGit2/src/callbacks.jl b/stdlib/LibGit2/src/callbacks.jl index 18de45a9944208..ccb5cf4153bd30 100644 --- a/stdlib/LibGit2/src/callbacks.jl +++ b/stdlib/LibGit2/src/callbacks.jl @@ -366,8 +366,8 @@ struct CertHostKey sha1 :: NTuple{20,UInt8} sha256 :: NTuple{32,UInt8} type :: Cint + hostkey :: Ptr{Cchar} len :: Csize_t - data :: NTuple{1024,UInt8} end function verify_host_error(message::AbstractString) diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index b68dbb7c0bf027..2d95596cb276d9 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -230,6 +230,9 @@ Matches the [`git_remote_callbacks`](https://libgit2.org/libgit2/#HEAD/type/git_ push_update_reference::Ptr{Cvoid} = C_NULL push_negotiation::Ptr{Cvoid} = C_NULL transport::Ptr{Cvoid} = C_NULL + @static if LibGit2.VERSION >= v"1.2.0" + remote_ready::Ptr{Cvoid} = C_NULL + end payload::Any = nothing @static if LibGit2.VERSION >= v"0.99.0" resolve_url::Ptr{Cvoid} = C_NULL diff --git a/stdlib/LibGit2_jll/src/LibGit2_jll.jl b/stdlib/LibGit2_jll/src/LibGit2_jll.jl index f0d4b5dda60726..1cd7aaa79f8141 100644 --- a/stdlib/LibGit2_jll/src/LibGit2_jll.jl +++ b/stdlib/LibGit2_jll/src/LibGit2_jll.jl @@ -21,9 +21,9 @@ libgit2_path = "" if Sys.iswindows() const libgit2 = "libgit2.dll" elseif Sys.isapple() - const libgit2 = "@rpath/libgit2.1.1.dylib" + const libgit2 = "@rpath/libgit2.1.3.dylib" else - const libgit2 = "libgit2.so.1.1" + const libgit2 = "libgit2.so.1.3" end function __init__()