From 2c4c068e58fd3b42cad2c093d81a9eefb6846e3a Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sun, 10 Sep 2023 14:07:57 -0400 Subject: [PATCH 1/5] libgit2 1.7.0 support --- stdlib/LibGit2/src/consts.jl | 65 ++++++++++++++++++++++++++++-------- stdlib/LibGit2/src/error.jl | 7 ++-- stdlib/LibGit2/src/types.jl | 8 ++++- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/stdlib/LibGit2/src/consts.jl b/stdlib/LibGit2/src/consts.jl index f3a460108db6b..9db0f19b46ab3 100644 --- a/stdlib/LibGit2/src/consts.jl +++ b/stdlib/LibGit2/src/consts.jl @@ -341,6 +341,10 @@ const LIBSSH2_KNOWNHOST_CHECK_MISMATCH = 1 const LIBSSH2_KNOWNHOST_CHECK_NOTFOUND = 2 const LIBSSH2_KNOWNHOST_CHECK_FAILURE = 3 +# Constants for fetch depth (shallowness of fetch). +const FETCH_DEPTH_FULL = 0 +const FETCH_DEPTH_UNSHALLOW = 2147483647 + @enum(GIT_SUBMODULE_IGNORE, SUBMODULE_IGNORE_UNSPECIFIED = -1, # use the submodule's configuration SUBMODULE_IGNORE_NONE = 1, # any change or untracked == dirty SUBMODULE_IGNORE_UNTRACKED = 2, # dirty if tracked files change @@ -432,19 +436,49 @@ Global library options. These are used to select which global option to set or get and are used in `git_libgit2_opts()`. """ -@enum(GIT_OPT, GET_MWINDOW_SIZE = 0, - SET_MWINDOW_SIZE = 1, - GET_MWINDOW_MAPPED_LIMIT = 2, - SET_MWINDOW_MAPPED_LIMIT = 3, - GET_SEARCH_PATH = 4, - SET_SEARCH_PATH = 5, - SET_CACHE_OBJECT_LIMIT = 6, - SET_CACHE_MAX_SIZE = 7, - ENABLE_CACHING = 8, - GET_CACHED_MEMORY = 9, - GET_TEMPLATE_PATH = 10, - SET_TEMPLATE_PATH = 11, - SET_SSL_CERT_LOCATIONS = 12) +@enum(GIT_OPT, GET_MWINDOW_SIZE = 0, + SET_MWINDOW_SIZE, + GET_MWINDOW_MAPPED_LIMIT, + SET_MWINDOW_MAPPED_LIMIT, + GET_SEARCH_PATH, + SET_SEARCH_PATH, + SET_CACHE_OBJECT_LIMIT, + SET_CACHE_MAX_SIZE, + ENABLE_CACHING, + GET_CACHED_MEMORY, + GET_TEMPLATE_PATH, + SET_TEMPLATE_PATH, + SET_SSL_CERT_LOCATIONS, + SET_USER_AGENT, + ENABLE_STRICT_OBJECT_CREATION, + ENABLE_STRICT_SYMBOLIC_REF_CREATION, + SET_SSL_CIPHERS, + GET_USER_AGENT, + ENABLE_OFS_DELTA, + ENABLE_FSYNC_GITDIR, + GET_WINDOWS_SHAREMODE, + SET_WINDOWS_SHAREMODE, + ENABLE_STRICT_HASH_VERIFICATION, + SET_ALLOCATOR, + ENABLE_UNSAVED_INDEX_SAFETY, + GET_PACK_MAX_OBJECTS, + SET_PACK_MAX_OBJECTS, + DISABLE_PACK_KEEP_FILE_CHECKS, + ENABLE_HTTP_EXPECT_CONTINUE, + GET_MWINDOW_FILE_LIMIT, + SET_MWINDOW_FILE_LIMIT, + SET_ODB_PACKED_PRIORITY, + SET_ODB_LOOSE_PRIORITY, + GET_EXTENSIONS, + SET_EXTENSIONS, + GET_OWNER_VALIDATION, + SET_OWNER_VALIDATION, + GET_HOMEDIR, + SET_HOMEDIR, + SET_SERVER_CONNECT_TIMEOUT, + GET_SERVER_CONNECT_TIMEOUT, + SET_SERVER_TIMEOUT, + GET_SERVER_TIMEOUT) """ Option flags for `GitProxy`. @@ -468,4 +502,9 @@ Option flags for `GitProxy`. TRACE_TRACE end +# The type of object id +@enum(GIT_OID_TYPE, + OID_DEFAULT = 0, + OID_SHA1 = 1) + end diff --git a/stdlib/LibGit2/src/error.jl b/stdlib/LibGit2/src/error.jl index fd70ed8ce5706..1a493006ea1b5 100644 --- a/stdlib/LibGit2/src/error.jl +++ b/stdlib/LibGit2/src/error.jl @@ -33,7 +33,8 @@ export GitError EMISMATCH = Cint(-33), # hashsum mismatch in object EINDEXDIRTY = Cint(-34), # unsaved changes in the index would be overwritten EAPPLYFAIL = Cint(-35), # patch application failed - EOWNER = Cint(-36)) # the object is not owned by the current user + EOWNER = Cint(-36), # the object is not owned by the current user + TIMEOUT = Cint(-37)) # The operation timed out @enum(Class, None, NoMemory, @@ -69,7 +70,9 @@ export GitError Patch, WorkTree, SHA1, - HTTP) + HTTP, + Internal, + Grafts) struct ErrorStruct message::Ptr{UInt8} diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index 6af95b894f1ca..25163b1db343d 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -2,7 +2,7 @@ using Base: something import Base.@kwdef -import .Consts: GIT_SUBMODULE_IGNORE, GIT_MERGE_FILE_FAVOR, GIT_MERGE_FILE, GIT_CONFIG +import .Consts: GIT_SUBMODULE_IGNORE, GIT_MERGE_FILE_FAVOR, GIT_MERGE_FILE, GIT_CONFIG, GIT_OID_TYPE const OID_RAWSZ = 20 const OID_HEXSZ = OID_RAWSZ * 2 @@ -346,6 +346,9 @@ The fields represent: @static if LibGit2.VERSION >= v"0.25.0" proxy_opts::ProxyOptions = ProxyOptions() end + @static if LibGit2.VERSION >= v"1.7.0" + depth::Cuint = Cuint(Consts.FETCH_DEPTH_FULL) + end @static if LibGit2.VERSION >= v"1.4.0" follow_redirects::Cuint = Cuint(0) end @@ -439,6 +442,9 @@ The fields represent: # options controlling how the diff text is generated context_lines::UInt32 = UInt32(3) interhunk_lines::UInt32 = UInt32(0) + @static if LibGit2.VERSION >= v"1.7.0" + oid_type::GIT_OID_TYPE = Consts.OID_DEFAULT + end id_abbrev::UInt16 = UInt16(7) max_size::Int64 = Int64(512*1024*1024) #512Mb old_prefix::Cstring = Cstring(C_NULL) From ce0c49f7783445877a88535a4873d19ecba5fbc4 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sun, 10 Sep 2023 14:27:09 -0400 Subject: [PATCH 2/5] Add support for a few more remote operations * Detached remote * Read remote reference advertisement list * Read remote default branch --- stdlib/LibGit2/src/LibGit2.jl | 38 +++++++++++++++ stdlib/LibGit2/src/consts.jl | 5 ++ stdlib/LibGit2/src/remote.jl | 75 +++++++++++++++++++++++++++++ stdlib/LibGit2/src/types.jl | 25 +++++++++- stdlib/LibGit2/test/online-tests.jl | 17 +++++++ 5 files changed, 159 insertions(+), 1 deletion(-) diff --git a/stdlib/LibGit2/src/LibGit2.jl b/stdlib/LibGit2/src/LibGit2.jl index 13b78c1046490..43b960e8d509d 100644 --- a/stdlib/LibGit2/src/LibGit2.jl +++ b/stdlib/LibGit2/src/LibGit2.jl @@ -596,6 +596,44 @@ function clone(repo_url::AbstractString, repo_path::AbstractString; return repo end +""" + connect(rmt::GitRemote, direction::Consts.GIT_DIRECTION; kwargs...) + +Open a connection to a remote. `direction` can be either `DIRECTION_FETCH` +or `DIRECTION_PUSH`. + +The keyword arguments are: + * `credentials::Creds=nothing`: provides credentials and/or settings when authenticating + against a private repository. + * `callbacks::Callbacks=Callbacks()`: user provided callbacks and payloads. +""" +function connect(rmt::GitRemote, direction::Consts.GIT_DIRECTION; + credentials::Creds=nothing, + callbacks::Callbacks=Callbacks()) + cred_payload = reset!(CredentialPayload(credentials)) + if !haskey(callbacks, :credentials) + callbacks[:credentials] = (credentials_cb(), cred_payload) + elseif haskey(callbacks, :credentials) && credentials !== nothing + throw(ArgumentError(string( + "Unable to both use the provided `credentials` as a payload when the ", + "`callbacks` also contain a credentials payload."))) + end + + remote_callbacks = RemoteCallbacks(callbacks) + try + connect(rmt, direction, remote_callbacks) + catch err + if isa(err, GitError) && err.code === Error.EAUTH + reject(cred_payload) + else + Base.shred!(cred_payload) + end + rethrow() + end + approve(cred_payload) + return rmt +end + """ git reset [] [--] ... """ function reset!(repo::GitRepo, committish::AbstractString, pathspecs::AbstractString...) obj = GitObject(repo, isempty(committish) ? Consts.HEAD_FILE : committish) diff --git a/stdlib/LibGit2/src/consts.jl b/stdlib/LibGit2/src/consts.jl index 9db0f19b46ab3..4d5b1306e7077 100644 --- a/stdlib/LibGit2/src/consts.jl +++ b/stdlib/LibGit2/src/consts.jl @@ -507,4 +507,9 @@ end OID_DEFAULT = 0, OID_SHA1 = 1) +# Direction of the connection. +@enum(GIT_DIRECTION, + DIRECTION_FETCH = 0, + DIRECTION_PUSH = 1) + end diff --git a/stdlib/LibGit2/src/remote.jl b/stdlib/LibGit2/src/remote.jl index f5be4499d227e..07afecebfd373 100644 --- a/stdlib/LibGit2/src/remote.jl +++ b/stdlib/LibGit2/src/remote.jl @@ -63,6 +63,19 @@ function GitRemoteAnon(repo::GitRepo, url::AbstractString) return GitRemote(repo, rmt_ptr_ptr[]) end +""" + GitRemoteDetached(url::AbstractString) -> GitRemote + +Create a remote without a connected local repo. +""" +function GitRemoteDetached(url::AbstractString) + ensure_initialized() + rmt_ptr_ptr = Ref{Ptr{Cvoid}}(C_NULL) + @check ccall((:git_remote_create_detached, libgit2), Cint, + (Ptr{Ptr{Cvoid}}, Cstring), rmt_ptr_ptr, url) + return GitRemote(rmt_ptr_ptr[]) +end + """ lookup_remote(repo::GitRepo, remote_name::AbstractString) -> Union{GitRemote, Nothing} @@ -414,3 +427,65 @@ function set_remote_url(path::AbstractString, remote_name::AbstractString, url:: set_remote_url(repo, remote_name, url) end end + +function connect(rmt::GitRemote, direction::Consts.GIT_DIRECTION, + callbacks::RemoteCallbacks) + @check ccall((:git_remote_connect, libgit2), + Cint, (Ptr{Cvoid}, Cint, Ref{RemoteCallbacks}, Ptr{Cvoid}, Ptr{Cvoid}), + rmt.ptr, direction, callbacks, C_NULL, C_NULL) + return rmt +end + +""" + connected(rmt::GitRemote) + +Check whether the remote is connected +""" +function connected(rmt::GitRemote) + return ccall((:git_remote_connected, libgit2), Cint, (Ptr{Cvoid},), rmt.ptr) != 0 +end + +""" + disconnect(rmt::GitRemote) + +Close the connection to the remote. +""" +function disconnect(rmt::GitRemote) + @check ccall((:git_remote_disconnect, libgit2), Cint, (Ptr{Cvoid},), rmt.ptr) + return +end + +""" + default_branch(rmt::GitRemote) + +Retrieve the name of the remote's default branch. + +This function must only be called after connecting (See [`connect`](@ref)). +""" +function default_branch(rmt::GitRemote) + buf_ref = Ref(Buffer()) + @check ccall((:git_remote_default_branch, libgit2), Cint, + (Ptr{Buffer}, Ptr{Cvoid}), buf_ref, rmt.ptr) + buf = buf_ref[] + str = unsafe_string(buf.ptr, buf.size) + free(buf_ref) + return str +end + +""" + ls(rmt::GitRemote) -> Vector{GitRemoteHead} + +Get the remote repository's reference advertisement list. + +This function must only be called after connecting (See [`connect`](@ref)). +""" +function ls(rmt::GitRemote) + nheads = Ref{Csize_t}() + head_refs = Ref{Ptr{Ptr{_GitRemoteHead}}}() + @check ccall((:git_remote_ls, libgit2), Cint, + (Ptr{Ptr{Ptr{_GitRemoteHead}}}, Ptr{Csize_t}, Ptr{Cvoid}), + head_refs, nheads, rmt.ptr) + head_ptr = head_refs[] + return [GitRemoteHead(unsafe_load(unsafe_load(head_ptr, i))) + for i in 1:nheads[]] +end diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index 25163b1db343d..96cea96d013e5 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -1010,7 +1010,7 @@ for (typ, owntyp, sup, cname) in Tuple{Symbol,Any,Symbol,Symbol}[ (:GitRepo, nothing, :AbstractGitObject, :git_repository), (:GitConfig, :(Union{GitRepo, Nothing}), :AbstractGitObject, :git_config), (:GitIndex, :(Union{GitRepo, Nothing}), :AbstractGitObject, :git_index), - (:GitRemote, :GitRepo, :AbstractGitObject, :git_remote), + (:GitRemote, :(Union{GitRepo, Nothing}), :AbstractGitObject, :git_remote), (:GitRevWalker, :GitRepo, :AbstractGitObject, :git_revwalk), (:GitReference, :GitRepo, :AbstractGitObject, :git_reference), (:GitDescribeResult, :GitRepo, :AbstractGitObject, :git_describe_result), @@ -1486,3 +1486,26 @@ end # Useful for functions which can handle various kinds of credentials const Creds = Union{CredentialPayload, AbstractCredential, CachedCredentials, Nothing} + +struct _GitRemoteHead + available_local::Cint + oid::GitHash + loid::GitHash + name::Cstring + symref_target::Cstring +end + +struct GitRemoteHead + available_local::Bool + oid::GitHash + loid::GitHash + name::String + symref_target::Union{Nothing,String} + function GitRemoteHead(head::_GitRemoteHead) + name = unsafe_string(head.name) + symref_target = (head.symref_target != C_NULL ? + unsafe_string(head.symref_target) : nothing) + return new(head.available_local != 0, + head.oid, head.loid, name, symref_target) + end +end diff --git a/stdlib/LibGit2/test/online-tests.jl b/stdlib/LibGit2/test/online-tests.jl index 96b6bf5b22371..4c5f346894b3d 100644 --- a/stdlib/LibGit2/test/online-tests.jl +++ b/stdlib/LibGit2/test/online-tests.jl @@ -90,6 +90,23 @@ mktempdir() do dir end end +@testset "Remote" begin + repo_url = "https://github.com/JuliaLang/Example.jl" + LibGit2.with(LibGit2.GitRemoteDetached(repo_url)) do remote + @test !LibGit2.connected(remote) + c = LibGit2.CredentialPayload(allow_prompt=false, allow_git_helpers=false) + LibGit2.connect(remote, LibGit2.Consts.DIRECTION_FETCH, credentials=c) + @test LibGit2.connected(remote) + remote_heads = LibGit2.ls(remote) + default_branch = LibGit2.default_branch(remote) + @test !isempty(remote_heads) + @test startswith(default_branch, "refs/heads/") + @test any(head.name == default_branch for head in remote_heads) + LibGit2.disconnect(remote) + @test !LibGit2.connected(remote) + end +end + # needs to be run in separate process so it can re-initialize libgit2 # with a useless self-signed certificate authority root certificate file = joinpath(@__DIR__, "bad_ca_roots.jl") From 58970a90c508050dfb1bd16eae192132eb5073d2 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sun, 10 Sep 2023 14:28:20 -0400 Subject: [PATCH 3/5] Add support for getting commit parent Required for walking the commit graph. --- stdlib/LibGit2/src/commit.jl | 42 ++++++++++++++++++++++++++++ stdlib/LibGit2/test/libgit2-tests.jl | 8 ++++++ 2 files changed, 50 insertions(+) diff --git a/stdlib/LibGit2/src/commit.jl b/stdlib/LibGit2/src/commit.jl index 0ec670e16376b..ceb56ee45d3b7 100644 --- a/stdlib/LibGit2/src/commit.jl +++ b/stdlib/LibGit2/src/commit.jl @@ -147,3 +147,45 @@ function commit(repo::GitRepo, msg::AbstractString; end return commit_id end + +""" + parentcount(c::GitCommit) + +Get the number of parents of this commit. + +See also [`parent`](@ref), [`parent_id`](@ref). +""" +parentcount(c::GitCommit) = + Int(ccall((:git_commit_parentcount, libgit2), Cuint, (Ptr{Cvoid},), c)) + +""" + parent(c::GitCommit, n) + +Get the `n`-th (1-based) parent of the commit. + +See also [`parentcount`](@ref), [`parent_id`](@ref). +""" +function parent(c::GitCommit, n) + ptr_ref = Ref{Ptr{Cvoid}}() + @check ccall((:git_commit_parent, libgit2), Cint, + (Ptr{Ptr{Cvoid}}, Ptr{Cvoid}, Cuint), ptr_ref, c, n - 1) + return GitCommit(c.owner, ptr_ref[]) +end + +""" + parent_id(c::GitCommit, n) + +Get the oid of the `n`-th (1-based) parent for a commit. + +See also [`parentcount`](@ref), [`parent`](@ref). +""" +function parent_id(c::GitCommit, n) + oid_ptr = ccall((:git_commit_parent_id, libgit2), Ptr{GitHash}, + (Ptr{Cvoid}, Cuint), c, n - 1) + if oid_ptr == C_NULL + # 0-based indexing mimicking the error message from libgit2 + throw(GitError(Error.Invalid, Error.ENOTFOUND, + "parent $(n - 1) does not exist")) + end + return unsafe_load(oid_ptr) +end diff --git a/stdlib/LibGit2/test/libgit2-tests.jl b/stdlib/LibGit2/test/libgit2-tests.jl index d2f2fc050dcd4..c5abca15ca719 100644 --- a/stdlib/LibGit2/test/libgit2-tests.jl +++ b/stdlib/LibGit2/test/libgit2-tests.jl @@ -929,6 +929,14 @@ mktempdir() do dir @test cmtr.email == test_sig.email @test LibGit2.message(cmt) == commit_msg1 + # test that the parent is correct + @test LibGit2.parentcount(cmt) == 0 + LibGit2.with(LibGit2.GitCommit(repo, commit_oid3)) do cmt3 + @test LibGit2.parentcount(cmt3) == 1 + @test LibGit2.parent_id(cmt3, 1) == commit_oid1 + @test LibGit2.GitHash(LibGit2.parent(cmt3, 1)) == commit_oid1 + end + # test showing the commit showstr = split(sprint(show, cmt), "\n") # the time of the commit will vary so just test the first two parts From a4b5ad3d4c6c56056ac1fd55d012ca2a6d234d35 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Mon, 11 Sep 2023 21:44:46 -0400 Subject: [PATCH 4/5] Update default libgit2 version to 1.7.1 --- deps/checksums/libgit2 | 64 +++++++++++++-------------- deps/libgit2.version | 4 +- stdlib/LibGit2_jll/Project.toml | 2 +- stdlib/LibGit2_jll/src/LibGit2_jll.jl | 4 +- stdlib/LibGit2_jll/test/runtests.jl | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/deps/checksums/libgit2 b/deps/checksums/libgit2 index 1d410349045d7..63d67671b12a4 100644 --- a/deps/checksums/libgit2 +++ b/deps/checksums/libgit2 @@ -1,34 +1,34 @@ -LibGit2.v1.6.4+0.aarch64-apple-darwin.tar.gz/md5/dd001ebe432b91c4043739a0aa14d3bf -LibGit2.v1.6.4+0.aarch64-apple-darwin.tar.gz/sha512/c921c9b7b4cba17c98a7f07e003cb9279ae40346e2977a0c2e257c6f6927726f09d0339e139e3a138ed84e169e00d459502a90724077cb253d52ec39a3766c28 -LibGit2.v1.6.4+0.aarch64-linux-gnu.tar.gz/md5/a044b38cc6396221c4687dc0723b33fd -LibGit2.v1.6.4+0.aarch64-linux-gnu.tar.gz/sha512/dd804c31645873f18f612920d1e4d4d7adfc828f8d96c8f03ce4e4c856608663ccd26ec9bfae30cd499cefd02b3b7ae648b8617b3d3de9364fbfea094777e7e4 -LibGit2.v1.6.4+0.aarch64-linux-musl.tar.gz/md5/8b15c173d188ef2d0bbe1cbd2fe25a0e -LibGit2.v1.6.4+0.aarch64-linux-musl.tar.gz/sha512/a1ddb011a92e8ab0ed6d005d354af23261c5c7949d43b610ba24867bb8065c73820326d14dba069a7d1497758e8c6e1a26a92c7e4c345c75cac2c6d9a7ddfbc0 -LibGit2.v1.6.4+0.armv6l-linux-gnueabihf.tar.gz/md5/8d49bb6c15477fa167519477ba43ccb4 -LibGit2.v1.6.4+0.armv6l-linux-gnueabihf.tar.gz/sha512/720a76aff31986084b4113734d4fc51b0225242fc53f103a2f1ec89c93a85f5c746df7ac0d98502e47b033d3777bd7e44b95b4bbadb2f27be538fb24fea03425 -LibGit2.v1.6.4+0.armv6l-linux-musleabihf.tar.gz/md5/a024f6a4ae55b38ca9c32b6183c75f57 -LibGit2.v1.6.4+0.armv6l-linux-musleabihf.tar.gz/sha512/f5a2d1426a6dafd9af0109782805cfe5b07c186947b83053390ce9930fefa2cdb2fd913c93213ff0cd5e4cd1ed43c1a17357cbfdbfe5428a07a95058bebabd85 -LibGit2.v1.6.4+0.armv7l-linux-gnueabihf.tar.gz/md5/9b33cb013b7126adce97a6f4d0957cd1 -LibGit2.v1.6.4+0.armv7l-linux-gnueabihf.tar.gz/sha512/ec5690027319bf11122b1a5abeb2dd3bc03dd9696b29faa10c543970288ec13f0c462c99d7c4cccff472f26af17525ef475bdd6ccda8de63ae233c7df3b8694d -LibGit2.v1.6.4+0.armv7l-linux-musleabihf.tar.gz/md5/81d1e5c46f1eee85b0ed0f069557ba0f -LibGit2.v1.6.4+0.armv7l-linux-musleabihf.tar.gz/sha512/635c55b08db5eea7e51b09be6236915edc6020831021e3e3fc43a9a7c6ea006a0b83958547898fd990954539b85a059550b60359305fa81ae9b8b514c4039b9e -LibGit2.v1.6.4+0.i686-linux-gnu.tar.gz/md5/7e8edfafd59cec5964ceef7b5a1ff564 -LibGit2.v1.6.4+0.i686-linux-gnu.tar.gz/sha512/7b358260ceac13bd58df8cba3ec11e57b07222c792173715191af15c6d567129c5d3a57f1005ad0f0589a692cf435ca2702e30d487e5d48a37d6d34e9d89c98d -LibGit2.v1.6.4+0.i686-linux-musl.tar.gz/md5/e9e3bcd77942e098147d7abdb8abe87a -LibGit2.v1.6.4+0.i686-linux-musl.tar.gz/sha512/f01e57fea3ba1b703350ebd499456e9d8da65abcfb42ad0fad5df1315de74def962045b52b5efa3d657aced1cdd7ef1c56a473febd3682678e9253fbda462f02 -LibGit2.v1.6.4+0.i686-w64-mingw32.tar.gz/md5/92e003bad6631bb28833a8d0b10a34de -LibGit2.v1.6.4+0.i686-w64-mingw32.tar.gz/sha512/64ba60cacf2fb63bc6e02558fcfbca2d793a8a92ba6ab7200d35368581a674cb64437f209adbbda5cad4921209622addf61485d3f370f9ce540b6487f7967d07 -LibGit2.v1.6.4+0.powerpc64le-linux-gnu.tar.gz/md5/a26f77b89c70edfe386ca75f8b945f65 -LibGit2.v1.6.4+0.powerpc64le-linux-gnu.tar.gz/sha512/7edff494558501245b575fb4d42e2279d98c4ad9ccbc625149db8bbbd379cbe5054b6369149dc1a66f5c91ba21a5609f3971a31cea5f0f7a16e67e991496f8cb -LibGit2.v1.6.4+0.x86_64-apple-darwin.tar.gz/md5/c0b79aad1765e0841d229d62dcf34105 -LibGit2.v1.6.4+0.x86_64-apple-darwin.tar.gz/sha512/1c3d0f696fe3fe5fa3269057c3d1863e84aff002a142f088129efc6e0e9f32df5db609732e4ad6c6ddf7a2c3f0b7ed53a06c9f4d49b518c0aa960ed04c71e6f2 -LibGit2.v1.6.4+0.x86_64-linux-gnu.tar.gz/md5/397c71f23f48eb8395c9e0a605bd3696 -LibGit2.v1.6.4+0.x86_64-linux-gnu.tar.gz/sha512/9b785ff277206988d60fbd105beaaeae49b4fa057e1d52f95f4b7a1eff5eceb4525a7a9015823bada6329d0a6b3be8e8ca94221c3b98b287d077b524aa4a517f -LibGit2.v1.6.4+0.x86_64-linux-musl.tar.gz/md5/e7404be38fa8c10740101c5ca1ed9bfd -LibGit2.v1.6.4+0.x86_64-linux-musl.tar.gz/sha512/a2902d50a17c8f61ec5d38d0d843443be2ce4f51292655961d685203860a8f2d098e4dffb10f46f885cc4df1e9f1a5237be2cb31950d9e4a073a78ca82e39989 -LibGit2.v1.6.4+0.x86_64-unknown-freebsd.tar.gz/md5/5f370e6f38b38e663dc47b59f295b3b1 -LibGit2.v1.6.4+0.x86_64-unknown-freebsd.tar.gz/sha512/2557e8b2dd8925602b2a04c60cf1c49b5b7c395b18ab0045d6bc5287a418463d065335e5e8c4478b70e48a88cae8f9314b348aca560ad7c03191e50eb8c8cf64 -LibGit2.v1.6.4+0.x86_64-w64-mingw32.tar.gz/md5/fdf688b0d3c14015775af60a2716d445 -LibGit2.v1.6.4+0.x86_64-w64-mingw32.tar.gz/sha512/05fc6d0dc15cf887d83ee4d7d9605171df9a74b532429fdd070ebe443eaf52b190deafb3fec8af5748dffaee05c979e2646dfd009998fcaaf6aeb6caa499bf7c +LibGit2.v1.7.1+0.aarch64-apple-darwin.tar.gz/md5/80102fd8cd633a4875a1257bd61d4e17 +LibGit2.v1.7.1+0.aarch64-apple-darwin.tar.gz/sha512/3cc3679923c36e0020e692e79112a8fa71b53c1b83c9bea8d6defda124722a67c2859089d36fddef7be4547539575483db32de8137b43f7fc97843e579a02696 +LibGit2.v1.7.1+0.aarch64-linux-gnu.tar.gz/md5/74be95a3f7886a9804964f024df5311f +LibGit2.v1.7.1+0.aarch64-linux-gnu.tar.gz/sha512/3ad8a3c9ced9be2ab5fefe651f445a26900beae743127dcd1f887d01a7672d5d6c523641ba7d402620f3c44a1cc9557e43e11ad1692726c8cfabecca59a030e9 +LibGit2.v1.7.1+0.aarch64-linux-musl.tar.gz/md5/e63f4351250b4f4ac60d66b0bed2ddf5 +LibGit2.v1.7.1+0.aarch64-linux-musl.tar.gz/sha512/8f2dd17fe55b7cf7cf60504e5b630b22ce27e4e89d75f7e93dba3b112f662470612987e09abd82c2e3df48fc3c0fe1dbf98c690d972edb50c10a5571741cd9e8 +LibGit2.v1.7.1+0.armv6l-linux-gnueabihf.tar.gz/md5/f06611068a36fa575ec8eb219c068723 +LibGit2.v1.7.1+0.armv6l-linux-gnueabihf.tar.gz/sha512/04c554b9617300cea7750d18590e1a5629e70274ef1e1e8fdabbb4347e46fd8a68e82ba21714d7cd3809c3b6de2e254baca35ff60a4be87485643c460b10ac73 +LibGit2.v1.7.1+0.armv6l-linux-musleabihf.tar.gz/md5/7135ca6e52bf63855c5b6aa45d59ad80 +LibGit2.v1.7.1+0.armv6l-linux-musleabihf.tar.gz/sha512/e542180d2d8a0896ec586edac03b91d48d2ece3d22220d09b6e717b1b95a38bc1de2ae0faeed39dd3e99150684441bfb0504b55b3e18e543e00561f91147d405 +LibGit2.v1.7.1+0.armv7l-linux-gnueabihf.tar.gz/md5/7ffc92c821ec99bd76865ece43f5face +LibGit2.v1.7.1+0.armv7l-linux-gnueabihf.tar.gz/sha512/c945a0895be07479fd94c3c127060e58866bc9b9c93e80dc923ecdda6689e43d566896ecf4bfc7d85ca710b9ee51e6d85dec423edc48a3a2066db0fbb118d073 +LibGit2.v1.7.1+0.armv7l-linux-musleabihf.tar.gz/md5/3d00a6223612c23ac6b3c1f44bff8119 +LibGit2.v1.7.1+0.armv7l-linux-musleabihf.tar.gz/sha512/c3ef7783f140b28ad2d10e1c16f5be683d3332a4f9db5d26fdf3f2ac2b750aa0ceaec928740a9bdf7f4d9e83f666aa6e5fdd9c019630bf46f6797000943e1510 +LibGit2.v1.7.1+0.i686-linux-gnu.tar.gz/md5/6ea4e6777f5a8630f9fa98fb6a4a4ac7 +LibGit2.v1.7.1+0.i686-linux-gnu.tar.gz/sha512/d62a46b54dfc491a88fa35d06f3ed9c76ce676473b33acd5382e72ce07e6a313505755476c4732b7a22cd774ddcdf4ea5e8a5b62b93eb48b67363911655ac177 +LibGit2.v1.7.1+0.i686-linux-musl.tar.gz/md5/9f74dc4e93886f011412a4f61dfb487f +LibGit2.v1.7.1+0.i686-linux-musl.tar.gz/sha512/1370cab2ef917aa759dd4986f247a6b4878f12c4b17399fa75c9a2878f86c136e6f2f998a396df0757bf36ac09d5d194e4b7688705d115f09c176f4a5ab22347 +LibGit2.v1.7.1+0.i686-w64-mingw32.tar.gz/md5/ce866e600b2ad8c0fd54ff8c57dc015c +LibGit2.v1.7.1+0.i686-w64-mingw32.tar.gz/sha512/c7848b39f3515452e13fb156ee645f9a8d3917374ba874b10437b417b3c8e9a108e014b3baf30c7ced5fd0034d4f37de7e7d76fb105358d8e953dca30c873dc6 +LibGit2.v1.7.1+0.powerpc64le-linux-gnu.tar.gz/md5/b7c2f120e33f499860cb1e096923e7fe +LibGit2.v1.7.1+0.powerpc64le-linux-gnu.tar.gz/sha512/3df8e54d2086fbedb55b5dc31a2010f2ecd277089293473607e780340882bda5b2f9a2cc1c53c88bd7fcca0791cc2530645ceda17de3f37bb1ff98a19ccb85cf +LibGit2.v1.7.1+0.x86_64-apple-darwin.tar.gz/md5/b5334bd7e44c2c28705bb816fe03b9b7 +LibGit2.v1.7.1+0.x86_64-apple-darwin.tar.gz/sha512/d91cfde393499687cc699d55184c58ee5f543108902bf1f08fde2270dec0f38e0d70cbc7af04ffe46952afad12ce008e745f4aae9084f23df58982c14b48117c +LibGit2.v1.7.1+0.x86_64-linux-gnu.tar.gz/md5/9e2e2fe324a40bb0a5364d218c5ce45e +LibGit2.v1.7.1+0.x86_64-linux-gnu.tar.gz/sha512/da7e28c20c09c5c0731fd5cdff6fa6c319b2c4757d5c4228fc287238cd649f98c689814480119f21cbb938a29f52c895021b44c74eccc2f93ae51766555d9b6a +LibGit2.v1.7.1+0.x86_64-linux-musl.tar.gz/md5/7147480b9520116eb63ee3c30fa60a21 +LibGit2.v1.7.1+0.x86_64-linux-musl.tar.gz/sha512/f3dfb2a416cb786f229fe9eb3ef653a30ba5ebf3b978475f0a10fa79fa68b7bce9b6d99aed19f8dfb5599d988e3c6d4ede9ef1a6ccdbb3c2ea61f76b97d7fb29 +LibGit2.v1.7.1+0.x86_64-unknown-freebsd.tar.gz/md5/39e1a6d463e52ca0b2a1a8e6c3c4a286 +LibGit2.v1.7.1+0.x86_64-unknown-freebsd.tar.gz/sha512/3978ba9923cc8a188aca36d7320d46b2788de27142d11920976c47ad43574ad7056539812cebab62550e656b263c2d277754c341bd83d013de608a91e6a0aad3 +LibGit2.v1.7.1+0.x86_64-w64-mingw32.tar.gz/md5/7d92c546023f460741a8187999b76bbe +LibGit2.v1.7.1+0.x86_64-w64-mingw32.tar.gz/sha512/da00d54f969ce3b70cc95dda281ddfafee72073164c31d7999053ed704a59401d64894ad702306d6e19eb1a60e5e98e5960c9c7e9a0e1645a0f3048422e62eb9 libgit2-e6325351ceee58cf56f58bdce61b38907805544f.tar.gz/md5/08777cc257825f218ceac1a24abafdc9 libgit2-e6325351ceee58cf56f58bdce61b38907805544f.tar.gz/sha512/ebeaf3bb12ce7d58cd6d36e0123168de3af8f083f707dc20df9781537e38188a176667ac51daf8d9006d54f2beed13fbfff6c26fbb48e3228988578ef8fbc9b7 diff --git a/deps/libgit2.version b/deps/libgit2.version index 5233b67754dad..9bd56f1bd0001 100644 --- a/deps/libgit2.version +++ b/deps/libgit2.version @@ -3,8 +3,8 @@ LIBGIT2_JLL_NAME := LibGit2 ## source build -LIBGIT2_BRANCH=v1.6.4 -LIBGIT2_SHA1=e6325351ceee58cf56f58bdce61b38907805544f +LIBGIT2_BRANCH=v1.7.1 +LIBGIT2_SHA1=a2bde63741977ca0f4ef7db2f609df320be67a08 ## Other deps # Specify the version of the Mozilla CA Certificate Store to obtain. diff --git a/stdlib/LibGit2_jll/Project.toml b/stdlib/LibGit2_jll/Project.toml index b917061847fb8..e64d86dc6c9b7 100644 --- a/stdlib/LibGit2_jll/Project.toml +++ b/stdlib/LibGit2_jll/Project.toml @@ -1,6 +1,6 @@ name = "LibGit2_jll" uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.1+0" [deps] MbedTLS_jll = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" diff --git a/stdlib/LibGit2_jll/src/LibGit2_jll.jl b/stdlib/LibGit2_jll/src/LibGit2_jll.jl index f8e814f1f7c30..ff625a6494a26 100644 --- a/stdlib/LibGit2_jll/src/LibGit2_jll.jl +++ b/stdlib/LibGit2_jll/src/LibGit2_jll.jl @@ -21,9 +21,9 @@ libgit2_path::String = "" if Sys.iswindows() const libgit2 = "libgit2.dll" elseif Sys.isapple() - const libgit2 = "@rpath/libgit2.1.6.dylib" + const libgit2 = "@rpath/libgit2.1.7.dylib" else - const libgit2 = "libgit2.so.1.6" + const libgit2 = "libgit2.so.1.7" end function __init__() diff --git a/stdlib/LibGit2_jll/test/runtests.jl b/stdlib/LibGit2_jll/test/runtests.jl index 7deb3b5291f28..86dcf659e7ab2 100644 --- a/stdlib/LibGit2_jll/test/runtests.jl +++ b/stdlib/LibGit2_jll/test/runtests.jl @@ -7,5 +7,5 @@ using Test, Libdl, LibGit2_jll minor = Ref{Cint}(0) patch = Ref{Cint}(0) @test ccall((:git_libgit2_version, libgit2), Cint, (Ref{Cint}, Ref{Cint}, Ref{Cint}), major, minor, patch) == 0 - @test VersionNumber(major[], minor[], patch[]) == v"1.6.4" + @test VersionNumber(major[], minor[], patch[]) == v"1.7.1" end From 7d51502d7845246d6a231fdc4cf19451f42427e1 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Tue, 12 Sep 2023 10:31:56 -0400 Subject: [PATCH 5/5] More missing constants from earlier libgit2 versions --- stdlib/LibGit2/src/consts.jl | 54 ++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/stdlib/LibGit2/src/consts.jl b/stdlib/LibGit2/src/consts.jl index 4d5b1306e7077..1f28a3bdbe887 100644 --- a/stdlib/LibGit2/src/consts.jl +++ b/stdlib/LibGit2/src/consts.jl @@ -10,12 +10,15 @@ const REMOTE_ORIGIN = "origin" # objs @enum(OBJECT, - OBJ_ANY = -2, - OBJ_BAD = -1, - OBJ_COMMIT = 1, - OBJ_TREE = 2, - OBJ_BLOB = 3, - OBJ_TAG = 4) + OBJ_ANY = -2, + OBJ_BAD = -1, + OBJ_COMMIT = 1, + OBJ_TREE = 2, + OBJ_BLOB = 3, + OBJ_TAG = 4, + OBJ_OFS_DELTA = 6, + OBJ_REF_DELTA = 7) +const OBJ_INVALID = OBJ_BAD #revwalk const SORT_NONE = Cint(0) @@ -26,8 +29,10 @@ const SORT_REVERSE = Cint(1 << 2) # refs const REF_INVALID = Cint(0) const REF_OID = Cint(1) +const REF_DIRECT = REF_OID const REF_SYMBOLIC = Cint(2) const REF_LISTALL = REF_OID | REF_SYMBOLIC +const REF_ALL = REF_LISTALL # blame const BLAME_NORMAL = Cuint(0) @@ -36,6 +41,8 @@ const BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = Cuint(1 << 1) const BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = Cuint(1 << 2) const BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = Cuint(1 << 3) const BLAME_FIRST_PARENT = Cuint(1 << 4) +const BLAME_USE_MAILMAP = Cuint(1 << 5) +const BLAME_IGNORE_WHITESPACE = Cuint(1 << 6) # checkout const CHECKOUT_NONE = Cuint(0) @@ -57,6 +64,9 @@ const CHECKOUT_DONT_OVERWRITE_IGNORED = Cuint(1 << 19) const CHECKOUT_CONFLICT_STYLE_MERGE = Cuint(1 << 20) const CHECKOUT_CONFLICT_STYLE_DIFF3 = Cuint(1 << 21) const CHECKOUT_DONT_REMOVE_EXISTING = Cuint(1 << 22) +const CHECKOUT_DONT_WRITE_INDEX = Cuint(1 << 23) +const CHECKOUT_DRY_RUN = Cuint(1 << 24) +const CHECKOUT_CONFLICT_STYLE_ZDIFF3 = Cuint(1 << 25) const CHECKOUT_UPDATE_SUBMODULES = Cuint(1 << 16) const CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = Cuint(1 << 17) @@ -87,6 +97,11 @@ const DIFF_IGNORE_CASE = Cuint(1 << 10) const DIFF_DISABLE_PATHSPEC_MATCH = Cuint(1 << 12) const DIFF_SKIP_BINARY_CHECK = Cuint(1 << 13) const DIFF_ENABLE_FAST_UNTRACKED_DIRS = Cuint(1 << 14) +const DIFF_UPDATE_INDEX = Cuint(1 << 15) +const DIFF_INCLUDE_UNREADABLE = Cuint(1 << 16) +const DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = Cuint(1 << 17) +const DIFF_INDENT_HEURISTIC = Cuint(1 << 18) +const DIFF_IGNORE_BLANK_LINES = Cuint(1 << 19) const DIFF_FORCE_TEXT = Cuint(1 << 20) const DIFF_FORCE_BINARY = Cuint(1 << 21) @@ -97,16 +112,20 @@ const DIFF_SHOW_UNTRACKED_CONTENT = Cuint(1 << 25) const DIFF_SHOW_UNMODIFIED = Cuint(1 << 26) const DIFF_PATIENCE = Cuint(1 << 28) const DIFF_MINIMAL = Cuint(1 << 29) +const DIFF_SHOW_BINARY = Cuint(1 << 30) const DIFF_FLAG_BINARY = Cuint(1 << 0) const DIFF_FLAG_NOT_BINARY = Cuint(1 << 1) const DIFF_FLAG_VALID_OID = Cuint(1 << 2) +const DIFF_FLAG_EXISTS = Cuint(1 << 3) +const DIFF_FLAG_VALID_SIZE = Cuint(1 << 4) const DIFF_FORMAT_PATCH = Cuint(1) const DIFF_FORMAT_PATCH_HEADER = Cuint(2) const DIFF_FORMAT_RAW = Cuint(3) const DIFF_FORMAT_NAME_ONLY = Cuint(4) const DIFF_FORMAT_NAME_STATUS = Cuint(5) +const DIFF_FORMAT_PATCH_ID = Cuint(6) @enum(DELTA_STATUS, DELTA_UNMODIFIED = Cint(0), DELTA_ADDED = Cint(1), @@ -116,7 +135,9 @@ const DIFF_FORMAT_NAME_STATUS = Cuint(5) DELTA_COPIED = Cint(5), DELTA_IGNORED = Cint(6), DELTA_UNTRACKED = Cint(7), - DELTA_TYPECHANGE = Cint(8)) + DELTA_TYPECHANGE = Cint(8), + DELTA_UNREADABLE = Cint(9), + DELTA_CONFLICTED = Cint(10)) # index const IDXENTRY_NAMEMASK = (0x0fff) @@ -165,7 +186,8 @@ const INDEX_STAGE_ANY = Cint(-1) @enum(GIT_MERGE, MERGE_FIND_RENAMES = 1 << 0, MERGE_FAIL_ON_CONFLICT = 1 << 1, MERGE_SKIP_REUC = 1 << 2, - MERGE_NO_RECURSIVE = 1 << 3) + MERGE_NO_RECURSIVE = 1 << 3, + MERGE_VIRTUAL_BASE = 1 << 4) @enum(GIT_MERGE_FILE, MERGE_FILE_DEFAULT = 0, # Defaults MERGE_FILE_STYLE_MERGE = 1 << 0, # Create standard conflicted merge files @@ -175,7 +197,13 @@ const INDEX_STAGE_ANY = Cint(-1) MERGE_FILE_IGNORE_WHITESPACE_CHANGE = 1 << 4, # Ignore changes in amount of whitespace MERGE_FILE_IGNORE_WHITESPACE_EOL = 1 << 5, # Ignore whitespace at end of line MERGE_FILE_DIFF_PATIENCE = 1 << 6, # Use the "patience diff" algorithm - MERGE_FILE_DIFF_MINIMAL = 1 << 7) # Take extra time to find minimal diff + MERGE_FILE_DIFF_MINIMAL = 1 << 7, # Take extra time to find minimal diff + MERGE_FILE_STYLE_ZDIFF3 = 1 << 8, # Create zdiff3 ("zealous diff3")-style files + + # Do not produce file conflicts when common regions have + # changed; keep the conflict markers in the file and accept + # that as the merge result. + MERGE_FILE_ACCEPT_CONFLICTS = 1 << 9) """ Option flags for git merge file favoritism. * `MERGE_FILE_FAVOR_NORMAL`: if both sides of the merge have changes to a section, make a note of the conflict in the index which `git checkout` will use to create @@ -316,6 +344,7 @@ const STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = Cuint(1 << 15) # certificate types from `enum git_cert_t` in `cert.h`. const CERT_TYPE_TLS = 1 # GIT_CERT_X509 const CERT_TYPE_SSH = 2 # GIT_CERT_HOSTKEY_LIBSSH2 +const CERT_TYPE_STRARRAY = 3 # GIT_CERT_STRARRAY # certificate callback return values const PASSTHROUGH = -30 @@ -326,6 +355,7 @@ const CERT_ACCEPT = 0 const CERT_SSH_MD5 = 1 << 0 const CERT_SSH_SHA1 = 1 << 1 const CERT_SSH_SHA256 = 1 << 2 +const CERT_SSH_RAW = 1 << 3 # libssh2 known host constants const LIBSSH2_KNOWNHOST_TYPE_PLAIN = 1 @@ -361,9 +391,11 @@ Option flags for `GitRepo`. @enum(GIT_REPOSITORY_OPEN, REPOSITORY_OPEN_DEFAULT = 0, REPOSITORY_OPEN_NO_SEARCH = 1<<0, REPOSITORY_OPEN_CROSS_FS = 1<<1, - REPOSITORY_OPEN_BARE = 1<<2) + REPOSITORY_OPEN_BARE = 1<<2, + REPOSITORY_OPEN_NO_DOTGIT = 1<<3, + REPOSITORY_OPEN_FROM_ENV = 1<<4) -@enum(GIT_BRANCH, BRANCH_LOCAL = 1, BRANCH_REMOTE = 2) +@enum(GIT_BRANCH, BRANCH_LOCAL = 1, BRANCH_REMOTE = 2, BRANCH_ALL = 1 | 2) @enum(GIT_FILEMODE, FILEMODE_UNREADABLE = 0o000000, FILEMODE_TREE = 0o040000,