Skip to content

Commit

Permalink
Upgrade libgit2 to 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Nov 28, 2021
1 parent 5c357e9 commit 4d7fc84
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 123 deletions.
18 changes: 2 additions & 16 deletions deps/libgit2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@)
Expand Down
4 changes: 2 additions & 2 deletions deps/libgit2.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LIBGIT2_BRANCH=v1.1.0
LIBGIT2_SHA1=7f4fa178629d559c037a1f72f79f79af9c1ef8ce
LIBGIT2_BRANCH=v1.3.0
LIBGIT2_SHA1=b7bad55e4bb0a285b073ba5e02b01d3f522fc95d
43 changes: 0 additions & 43 deletions deps/patches/libgit2-continue-zlib.patch

This file was deleted.

42 changes: 5 additions & 37 deletions deps/patches/libgit2-hostkey.patch
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
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..32189d0979 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -523,6 +523,7 @@ static int _git_ssh_setup_conn(
@@ -525,6 +525,7 @@ static int _git_ssh_setup_conn(
git_credential *cred = NULL;
LIBSSH2_SESSION* session=NULL;
LIBSSH2_CHANNEL* channel=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 +637,15 @@ post_extract:

cert_ptr = &cert;

Expand Down
22 changes: 0 additions & 22 deletions deps/patches/libgit2-mbedtls-incdir.patch

This file was deleted.

2 changes: 1 addition & 1 deletion stdlib/LibGit2/src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/LibGit2/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LibGit2_jll/src/LibGit2_jll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down

0 comments on commit 4d7fc84

Please sign in to comment.