Skip to content

Commit

Permalink
libgit2: update enums from v1.8.0 (#56764)
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon authored Dec 10, 2024
1 parent 9d28a06 commit da43f11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions stdlib/LibGit2/src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ end
function user_abort()
ensure_initialized()
# Note: Potentially it could be better to just throw a Julia error.
ccall((:giterr_set_str, libgit2), Cvoid,
ccall((:git_error_set_str, libgit2), Cvoid,
(Cint, Cstring), Cint(Error.Callback),
"Aborting, user cancelled credential request.")
return Cint(Error.EUSER)
end

function prompt_limit()
ensure_initialized()
ccall((:giterr_set_str, libgit2), Cvoid,
ccall((:git_error_set_str, libgit2), Cvoid,
(Cint, Cstring), Cint(Error.Callback),
"Aborting, maximum number of prompts reached.")
return Cint(Error.EAUTH)
end

function exhausted_abort()
ensure_initialized()
ccall((:giterr_set_str, libgit2), Cvoid,
ccall((:git_error_set_str, libgit2), Cvoid,
(Cint, Cstring), Cint(Error.Callback),
"All authentication methods have failed.")
return Cint(Error.EAUTH)
Expand Down Expand Up @@ -339,7 +339,7 @@ function credentials_callback(libgit2credptr::Ptr{Ptr{Cvoid}}, url_ptr::Cstring,
if err == 0
if p.explicit !== nothing
ensure_initialized()
ccall((:giterr_set_str, libgit2), Cvoid, (Cint, Cstring), Cint(Error.Callback),
ccall((:git_error_set_str, libgit2), Cvoid, (Cint, Cstring), Cint(Error.Callback),
"The explicitly provided credential is incompatible with the requested " *
"authentication methods.")
end
Expand Down
15 changes: 12 additions & 3 deletions stdlib/LibGit2/src/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,31 @@ export GitError
EUNMERGED = Cint(-10), # merge in progress prevented op
ENONFASTFORWARD = Cint(-11), # ref not fast-forwardable
EINVALIDSPEC = Cint(-12), # name / ref not in valid format
EMERGECONFLICT = Cint(-13), # merge conflict prevented op
ECONFLICT = Cint(-13), # Checkout conflicts prevented operation
ELOCKED = Cint(-14), # lock file prevented op
EMODIFIED = Cint(-15), # ref value does not match expected
EAUTH = Cint(-16), # authentication error
ECERTIFICATE = Cint(-17), # server certificate is invalid
EAPPLIED = Cint(-18), # patch/merge has already been applied
EPEEL = Cint(-19), # the requested peel operation is not possible
EEOF = Cint(-20), # unexpected EOF
EINVALID = Cint(-21), # Invalid operation or input
EUNCOMMITTED = Cint(-22), # Uncommitted changes in index prevented operation
EDIRECTORY = Cint(-23), # The operation is not valid for a directory
EMERGECONFLICT = Cint(-24), # A merge conflict exists and cannot continue

PASSTHROUGH = Cint(-30), # internal only
ITEROVER = Cint(-31), # signals end of iteration
RETRY = Cint(-32), # internal only
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
TIMEOUT = Cint(-37)) # The operation timed out
TIMEOUT = Cint(-37), # The operation timed out
EUNCHANGED = Cint(-38), # There were no changes
ENOTSUPPORTED = Cint(-39), # An option is not supported
EREADONLY = Cint(-40), # The subject is read-only
)

@enum(Class, None,
NoMemory,
Expand Down Expand Up @@ -88,7 +97,7 @@ Base.show(io::IO, err::GitError) = print(io, "GitError(Code:$(err.code), Class:$

function last_error()
ensure_initialized()
err = ccall((:giterr_last, libgit2), Ptr{ErrorStruct}, ())
err = ccall((:git_error_last, libgit2), Ptr{ErrorStruct}, ())
if err != C_NULL
err_obj = unsafe_load(err)
err_class = Class(err_obj.class)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LibGit2/test/libgit2-tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ mktempdir() do dir

# test workaround for git_tree_walk issue
# https://github.com/libgit2/libgit2/issues/4693
ccall((:giterr_set_str, libgit2), Cvoid, (Cint, Cstring),
ccall((:git_error_set_str, libgit2), Cvoid, (Cint, Cstring),
Cint(LibGit2.Error.Invalid), "previous error")
try
# file needs to exist in tree in order to trigger the stop walk condition
Expand Down

0 comments on commit da43f11

Please sign in to comment.