From 59a315cac72f048847b85e285ae19ef2dc9514c3 Mon Sep 17 00:00:00 2001 From: Jonas Witschel Date: Fri, 29 May 2020 03:05:15 +0000 Subject: [PATCH] LibGit2: add resolve_url to RemoteCallbacksStruct for LibGit2 0.99.0 (#35232) * LibGit2: amend GitError enum Since upstream commit https://github.com/libgit2/libgit2/commit/e9cef7c4b16b2cb572ac19fcd39217f7934cfa99 ("http: introduce GIT_ERROR_HTTP") an invalid content type yields a GIT_ERROR_HTTP instead of a GIT_ERROR_NET error. Update the enum to include this new error so that the unit test for LibGit2 doesn't fail with "invalid value for Enum Class: 34". * LibGit2: add resolve_url to RemoteCallbacksStruct for LibGit2 0.99.0 Upstream commit https://github.com/libgit2/libgit2/commit/59647e1ad095f80112918971b7bbe05adfaf8c3c ("remote: add callback to resolve URLs before connecting") introduced a new callback "resolve_url" in LibGit2 0.99.0. Even though it is not currently used in Julia, it needs to be accounted for to get the correct size for FetchOptionsStruct. An incorrectly aligned FetchOptionsStruct leads to error messages like "invalid version 0 on git_proxy_options" when trying to use the latest LibGit2 version. * LibGit2: update error message checking for LibGit2 0.99.0 Upstream commit https://github.com/libgit2/libgit2/commit/b9c5b15a7958ab4ecb83504a6d858efd18610297 ("http: use the new httpclient") changed the error message to include additional quotes. Relax the unit test to allow these if present. Co-authored-by: Milan Bouchet-Valat --- stdlib/LibGit2/src/error.jl | 7 ++++++- stdlib/LibGit2/src/types.jl | 3 +++ stdlib/LibGit2/test/libgit2.jl | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stdlib/LibGit2/src/error.jl b/stdlib/LibGit2/src/error.jl index 4d1e915cef314..61eff41855ae4 100644 --- a/stdlib/LibGit2/src/error.jl +++ b/stdlib/LibGit2/src/error.jl @@ -58,7 +58,12 @@ export GitError Callback, CherryPick, Describe, - Rebase) + Rebase, + Filesystem, + Patch, + WorkTree, + SHA1, + HTTP) struct ErrorStruct message::Ptr{UInt8} diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index 6ffbe67ea2775..e00a0f161e79b 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -223,6 +223,9 @@ end push_negotiation::Ptr{Cvoid} = C_NULL transport::Ptr{Cvoid} = C_NULL payload::Ptr{Cvoid} = C_NULL + @static if LibGit2.VERSION >= v"0.99.0" + resolve_url::Ptr{Cvoid} = C_NULL + end end """ diff --git a/stdlib/LibGit2/test/libgit2.jl b/stdlib/LibGit2/test/libgit2.jl index 8f890ab0478ca..65b8f6b9e26c2 100644 --- a/stdlib/LibGit2/test/libgit2.jl +++ b/stdlib/LibGit2/test/libgit2.jl @@ -3048,7 +3048,7 @@ mktempdir() do dir deserialize(f) end @test err.code == LibGit2.Error.ERROR - @test lowercase(err.msg) == lowercase("invalid Content-Type: text/plain") + @test occursin(r"invalid content-type: '?text/plain'?"i, err.msg) end # OpenSSL s_server should still be running