Skip to content

Commit eea9477

Browse files
KristofferCIanButterworth
authored andcommitted
use LibGit2_jll for LibGit2 library (#51294)
Fixes #51293 (cherry picked from commit 377f9df)
1 parent 76277fe commit eea9477

26 files changed

+209
-208
lines changed

pkgimage.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $(eval $(call pkgimg_builder,GMP_jll,Artifacts Libdl))
8383
$(eval $(call pkgimg_builder,LLVMLibUnwind_jll,Artifacts Libdl))
8484
$(eval $(call pkgimg_builder,LibUV_jll,Artifacts Libdl))
8585
$(eval $(call pkgimg_builder,LibUnwind_jll,Artifacts Libdl))
86-
$(eval $(call pkgimg_builder,MbedTLS_jll,Artifacts Libdl))
86+
$(eval $(call sysimg_builder,MbedTLS_jll,Artifacts Libdl))
8787
$(eval $(call pkgimg_builder,nghttp2_jll,Artifacts Libdl))
8888
$(eval $(call pkgimg_builder,OpenLibm_jll,Artifacts Libdl))
8989
$(eval $(call pkgimg_builder,PCRE2_jll,Artifacts Libdl))
@@ -100,25 +100,25 @@ $(eval $(call pkgimg_builder,DelimitedFiles,Mmap))
100100

101101
# 2-depth packages
102102
$(eval $(call pkgimg_builder,LLD_jll,Zlib_jll libLLVM_jll Artifacts Libdl))
103-
$(eval $(call pkgimg_builder,LibSSH2_jll,Artifacts Libdl MbedTLS_jll))
103+
$(eval $(call sysimg_builder,LibSSH2_jll,Artifacts Libdl MbedTLS_jll))
104104
$(eval $(call pkgimg_builder,MPFR_jll,Artifacts Libdl GMP_jll))
105105
$(eval $(call sysimg_builder,LinearAlgebra,Libdl libblastrampoline_jll OpenBLAS_jll))
106106
$(eval $(call sysimg_builder,Dates,Printf))
107107
$(eval $(call pkgimg_builder,Distributed,Random Serialization Sockets))
108108
$(eval $(call sysimg_builder,Future,Random))
109109
$(eval $(call sysimg_builder,InteractiveUtils,Markdown))
110-
$(eval $(call sysimg_builder,LibGit2,NetworkOptions Printf SHA Base64))
111110
$(eval $(call sysimg_builder,UUIDs,Random SHA))
112111

113112
# 3-depth packages
114-
# LibGit2_jll
113+
$(eval $(call sysimg_builder,LibGit2_jll,MbedTLS_jll LibSSH2_jll Artifacts Libdl))
115114
$(eval $(call pkgimg_builder,LibCURL_jll,LibSSH2_jll nghttp2_jll MbedTLS_jll Zlib_jll Artifacts Libdl))
116115
$(eval $(call sysimg_builder,REPL,InteractiveUtils Markdown Sockets Unicode))
117116
$(eval $(call pkgimg_builder,SharedArrays,Distributed Mmap Random Serialization))
118117
$(eval $(call sysimg_builder,TOML,Dates))
119118
$(eval $(call pkgimg_builder,Test,Logging Random Serialization InteractiveUtils))
120119

121120
# 4-depth packages
121+
$(eval $(call sysimg_builder,LibGit2,LibGit2_jll NetworkOptions Printf SHA Base64))
122122
$(eval $(call sysimg_builder,LibCURL,LibCURL_jll MozillaCACerts_jll))
123123

124124
# 5-depth packages

stdlib/LibGit2/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
33

44
[deps]
55
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
6+
LibGit2_jll = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
67
NetworkOptions = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
78
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
89
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

stdlib/LibGit2/src/LibGit2.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ using SHA: sha1, sha256
1414

1515
export with, GitRepo, GitConfig
1616

17+
using LibGit2_jll
18+
1719
const GITHUB_REGEX =
1820
r"^(?:(?:ssh://)?git@|git://|https://(?:[\w\.\+\-]+@)?)github.com[:/](([^/].+)/(.+?))(?:\.git)?$"i
1921

@@ -983,15 +985,15 @@ function ensure_initialized()
983985
end
984986

985987
@noinline function initialize()
986-
@check ccall((:git_libgit2_init, :libgit2), Cint, ())
988+
@check ccall((:git_libgit2_init, libgit2), Cint, ())
987989

988990
cert_loc = NetworkOptions.ca_roots()
989991
cert_loc !== nothing && set_ssl_cert_locations(cert_loc)
990992

991993
atexit() do
992994
# refcount zero, no objects to be finalized
993995
if Threads.atomic_sub!(REFCOUNT, 1) == 1
994-
ccall((:git_libgit2_shutdown, :libgit2), Cint, ())
996+
ccall((:git_libgit2_shutdown, libgit2), Cint, ())
995997
end
996998
end
997999
end
@@ -1003,7 +1005,7 @@ function set_ssl_cert_locations(cert_loc)
10031005
else # files, /dev/null, non-existent paths, etc.
10041006
cert_file = cert_loc
10051007
end
1006-
ret = @ccall "libgit2".git_libgit2_opts(
1008+
ret = @ccall libgit2.git_libgit2_opts(
10071009
Consts.SET_SSL_CERT_LOCATIONS::Cint;
10081010
cert_file::Cstring,
10091011
cert_dir::Cstring)::Cint
@@ -1029,7 +1031,7 @@ end
10291031
Sets the system tracing configuration to the specified level.
10301032
"""
10311033
function trace_set(level::Union{Integer,Consts.GIT_TRACE_LEVEL}, cb=trace_cb())
1032-
@check @ccall "libgit2".git_trace_set(level::Cint, cb::Ptr{Cvoid})::Cint
1034+
@check @ccall libgit2.git_trace_set(level::Cint, cb::Ptr{Cvoid})::Cint
10331035
end
10341036

10351037
end # module

stdlib/LibGit2/src/blame.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ which commits to probe - see [`BlameOptions`](@ref) for more information.
1111
function GitBlame(repo::GitRepo, path::AbstractString; options::BlameOptions=BlameOptions())
1212
ensure_initialized()
1313
blame_ptr_ptr = Ref{Ptr{Cvoid}}(C_NULL)
14-
@check ccall((:git_blame_file, :libgit2), Cint,
14+
@check ccall((:git_blame_file, libgit2), Cint,
1515
(Ptr{Ptr{Cvoid}}, Ptr{Cvoid}, Cstring, Ptr{BlameOptions}),
1616
blame_ptr_ptr, repo.ptr, path, Ref(options))
1717
return GitBlame(repo, blame_ptr_ptr[])
@@ -27,7 +27,7 @@ that function later.
2727
"""
2828
function counthunks(blame::GitBlame)
2929
ensure_initialized()
30-
return ccall((:git_blame_get_hunk_count, :libgit2), Int32, (Ptr{Cvoid},), blame.ptr)
30+
return ccall((:git_blame_get_hunk_count, libgit2), Int32, (Ptr{Cvoid},), blame.ptr)
3131
end
3232

3333
function Base.getindex(blame::GitBlame, i::Integer)
@@ -36,7 +36,7 @@ function Base.getindex(blame::GitBlame, i::Integer)
3636
end
3737
ensure_initialized()
3838
GC.@preserve blame begin
39-
hunk_ptr = ccall((:git_blame_get_hunk_byindex, :libgit2),
39+
hunk_ptr = ccall((:git_blame_get_hunk_byindex, libgit2),
4040
Ptr{BlameHunk},
4141
(Ptr{Cvoid}, Csize_t), blame.ptr, i-1)
4242
elem = unsafe_load(hunk_ptr)

stdlib/LibGit2/src/blob.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
function Base.length(blob::GitBlob)
44
ensure_initialized()
5-
return ccall((:git_blob_rawsize, :libgit2), Int64, (Ptr{Cvoid},), blob.ptr)
5+
return ccall((:git_blob_rawsize, libgit2), Int64, (Ptr{Cvoid},), blob.ptr)
66
end
77

88
"""
@@ -20,7 +20,7 @@ is binary and not valid Unicode.
2020
"""
2121
function rawcontent(blob::GitBlob)
2222
ensure_initialized()
23-
ptr = ccall((:git_blob_rawcontent, :libgit2), Ptr{UInt8}, (Ptr{Cvoid},), blob.ptr)
23+
ptr = ccall((:git_blob_rawcontent, libgit2), Ptr{UInt8}, (Ptr{Cvoid},), blob.ptr)
2424
copy(unsafe_wrap(Array, ptr, (length(blob),), own = false))
2525
end
2626

@@ -47,7 +47,7 @@ the first 8000 bytes.
4747
"""
4848
function isbinary(blob::GitBlob)
4949
ensure_initialized()
50-
bin_flag = ccall((:git_blob_is_binary, :libgit2), Cint, (Ptr{Cvoid},), blob.ptr)
50+
bin_flag = ccall((:git_blob_is_binary, libgit2), Cint, (Ptr{Cvoid},), blob.ptr)
5151
return bin_flag == 1
5252
end
5353

@@ -67,7 +67,7 @@ id = LibGit2.addblob!(repo, blob_file)
6767
function addblob!(repo::GitRepo, path::AbstractString)
6868
ensure_initialized()
6969
id_ref = Ref{GitHash}()
70-
@check ccall((:git_blob_create_from_disk, :libgit2), Cint,
70+
@check ccall((:git_blob_create_from_disk, libgit2), Cint,
7171
(Ptr{GitHash}, Ptr{Cvoid}, Cstring),
7272
id_ref, repo.ptr, path)
7373
return id_ref[]

stdlib/LibGit2/src/callbacks.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function mirror_callback(remote::Ptr{Ptr{Cvoid}}, repo_ptr::Ptr{Cvoid},
99
ensure_initialized()
1010
# Create the remote with a mirroring url
1111
fetch_spec = "+refs/*:refs/*"
12-
err = ccall((:git_remote_create_with_fetchspec, :libgit2), Cint,
12+
err = ccall((:git_remote_create_with_fetchspec, libgit2), Cint,
1313
(Ptr{Ptr{Cvoid}}, Ptr{Cvoid}, Cstring, Cstring, Cstring),
1414
remote, repo_ptr, name, url, fetch_spec)
1515
err != 0 && return Cint(err)
@@ -43,23 +43,23 @@ end
4343
function user_abort()
4444
ensure_initialized()
4545
# Note: Potentially it could be better to just throw a Julia error.
46-
ccall((:giterr_set_str, :libgit2), Cvoid,
46+
ccall((:giterr_set_str, libgit2), Cvoid,
4747
(Cint, Cstring), Cint(Error.Callback),
4848
"Aborting, user cancelled credential request.")
4949
return Cint(Error.EUSER)
5050
end
5151

5252
function prompt_limit()
5353
ensure_initialized()
54-
ccall((:giterr_set_str, :libgit2), Cvoid,
54+
ccall((:giterr_set_str, libgit2), Cvoid,
5555
(Cint, Cstring), Cint(Error.Callback),
5656
"Aborting, maximum number of prompts reached.")
5757
return Cint(Error.EAUTH)
5858
end
5959

6060
function exhausted_abort()
6161
ensure_initialized()
62-
ccall((:giterr_set_str, :libgit2), Cvoid,
62+
ccall((:giterr_set_str, libgit2), Cvoid,
6363
(Cint, Cstring), Cint(Error.Callback),
6464
"All authentication methods have failed.")
6565
return Cint(Error.EAUTH)
@@ -79,7 +79,7 @@ function authenticate_ssh(libgit2credptr::Ptr{Ptr{Cvoid}}, p::CredentialPayload,
7979

8080
# first try ssh-agent if credentials support its usage
8181
if p.use_ssh_agent && username_ptr != Cstring(C_NULL) && (!revised || !isfilled(cred))
82-
err = ccall((:git_cred_ssh_key_from_agent, :libgit2), Cint,
82+
err = ccall((:git_cred_ssh_key_from_agent, libgit2), Cint,
8383
(Ptr{Ptr{Cvoid}}, Cstring), libgit2credptr, username_ptr)
8484

8585
p.use_ssh_agent = false # use ssh-agent only one time
@@ -175,7 +175,7 @@ function authenticate_ssh(libgit2credptr::Ptr{Ptr{Cvoid}}, p::CredentialPayload,
175175
if !revised
176176
return exhausted_abort()
177177
end
178-
return ccall((:git_cred_ssh_key_new, :libgit2), Cint,
178+
return ccall((:git_cred_ssh_key_new, libgit2), Cint,
179179
(Ptr{Ptr{Cvoid}}, Cstring, Cstring, Cstring, Cstring),
180180
libgit2credptr, cred.user, cred.pubkey, cred.prvkey, cred.pass)
181181
end
@@ -235,7 +235,7 @@ function authenticate_userpass(libgit2credptr::Ptr{Ptr{Cvoid}}, p::CredentialPay
235235
return exhausted_abort()
236236
end
237237

238-
return ccall((:git_cred_userpass_plaintext_new, :libgit2), Cint,
238+
return ccall((:git_cred_userpass_plaintext_new, libgit2), Cint,
239239
(Ptr{Ptr{Cvoid}}, Cstring, Cstring),
240240
libgit2credptr, cred.user, cred.pass)
241241
end
@@ -339,7 +339,7 @@ function credentials_callback(libgit2credptr::Ptr{Ptr{Cvoid}}, url_ptr::Cstring,
339339
if err == 0
340340
if p.explicit !== nothing
341341
ensure_initialized()
342-
ccall((:giterr_set_str, :libgit2), Cvoid, (Cint, Cstring), Cint(Error.Callback),
342+
ccall((:giterr_set_str, libgit2), Cvoid, (Cint, Cstring), Cint(Error.Callback),
343343
"The explicitly provided credential is incompatible with the requested " *
344344
"authentication methods.")
345345
end

stdlib/LibGit2/src/commit.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function message(c::GitCommit, raw::Bool=false)
1414
ensure_initialized()
1515
GC.@preserve c begin
1616
local msg_ptr::Cstring
17-
msg_ptr = raw ? ccall((:git_commit_message_raw, :libgit2), Cstring, (Ptr{Cvoid},), c.ptr) :
18-
ccall((:git_commit_message, :libgit2), Cstring, (Ptr{Cvoid},), c.ptr)
17+
msg_ptr = raw ? ccall((:git_commit_message_raw, libgit2), Cstring, (Ptr{Cvoid},), c.ptr) :
18+
ccall((:git_commit_message, libgit2), Cstring, (Ptr{Cvoid},), c.ptr)
1919
if msg_ptr == C_NULL
2020
return nothing
2121
end
@@ -33,7 +33,7 @@ the person who made changes to the relevant file(s). See also [`committer`](@ref
3333
function author(c::GitCommit)
3434
ensure_initialized()
3535
GC.@preserve c begin
36-
ptr = ccall((:git_commit_author, :libgit2), Ptr{SignatureStruct}, (Ptr{Cvoid},), c.ptr)
36+
ptr = ccall((:git_commit_author, libgit2), Ptr{SignatureStruct}, (Ptr{Cvoid},), c.ptr)
3737
@assert ptr != C_NULL
3838
sig = Signature(ptr)
3939
end
@@ -51,7 +51,7 @@ a `committer` who committed it.
5151
function committer(c::GitCommit)
5252
ensure_initialized()
5353
GC.@preserve c begin
54-
ptr = ccall((:git_commit_committer, :libgit2), Ptr{SignatureStruct}, (Ptr{Cvoid},), c.ptr)
54+
ptr = ccall((:git_commit_committer, libgit2), Ptr{SignatureStruct}, (Ptr{Cvoid},), c.ptr)
5555
sig = Signature(ptr)
5656
end
5757
return sig
@@ -74,7 +74,7 @@ function commit(repo::GitRepo,
7474
commit_id_ptr = Ref(GitHash())
7575
nparents = length(parents)
7676
parentptrs = Ptr{Cvoid}[c.ptr for c in parents]
77-
@check ccall((:git_commit_create, :libgit2), Cint,
77+
@check ccall((:git_commit_create, libgit2), Cint,
7878
(Ptr{GitHash}, Ptr{Cvoid}, Ptr{UInt8},
7979
Ptr{SignatureStruct}, Ptr{SignatureStruct},
8080
Ptr{UInt8}, Ptr{UInt8}, Ptr{Cvoid},

0 commit comments

Comments
 (0)