Skip to content

Commit

Permalink
LibGit2: add resolve_url to RemoteCallbacksStruct for LibGit2 0.99.0 (#…
Browse files Browse the repository at this point in the history
…35232)

* LibGit2: amend GitError enum

Since upstream commit
libgit2/libgit2@e9cef7c
("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
libgit2/libgit2@59647e1
("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
libgit2/libgit2@b9c5b15
("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 <nalimilan@club.fr>
(cherry picked from commit 59a315c)
  • Loading branch information
diabonas authored and KristofferC committed Jun 1, 2020
1 parent 91216bf commit 53f0393
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion stdlib/LibGit2/src/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export GitError
Callback,
CherryPick,
Describe,
Rebase)
Rebase,
Filesystem,
Patch,
WorkTree,
SHA1,
HTTP)

struct ErrorStruct
message::Ptr{UInt8}
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 @@ -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

"""
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53f0393

Please sign in to comment.