Skip to content

Commit

Permalink
Merge pull request #23036 from JuliaLang/cv/remote-callbacks
Browse files Browse the repository at this point in the history
LibGit2 RemoteCallback refactoring
  • Loading branch information
omus authored Aug 2, 2017
2 parents 68b0e40 + 0839b54 commit 51fbb0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 0 additions & 7 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ function is_ancestor_of(a::AbstractString, b::AbstractString, repo::GitRepo)
merge_base(repo, a, b) == A
end

function make_payload(payload::Nullable{<:AbstractCredentials})
Ref{Nullable{AbstractCredentials}}(payload)
end

"""
fetch(repo::GitRepo; kwargs...)
Expand Down Expand Up @@ -269,7 +265,6 @@ function fetch(repo::GitRepo; remote::AbstractString="origin",
GitRemoteAnon(repo, remoteurl)
end
try
payload = make_payload(payload)
fo = FetchOptions(callbacks=RemoteCallbacks(credentials_cb(), payload))
fetch(rmt, refspecs, msg="from $(url(rmt))", options = fo)
finally
Expand Down Expand Up @@ -304,7 +299,6 @@ function push(repo::GitRepo; remote::AbstractString="origin",
GitRemoteAnon(repo, remoteurl)
end
try
payload = make_payload(payload)
push_opts=PushOptions(callbacks=RemoteCallbacks(credentials_cb(), payload))
push(rmt, refspecs, force=force, options=push_opts)
finally
Expand Down Expand Up @@ -510,7 +504,6 @@ function clone(repo_url::AbstractString, repo_path::AbstractString;
payload::Nullable{<:AbstractCredentials}=Nullable{AbstractCredentials}())
# setup clone options
lbranch = Base.cconvert(Cstring, branch)
payload = make_payload(payload)
fetch_opts=FetchOptions(callbacks = RemoteCallbacks(credentials_cb(), payload))
clone_opts = CloneOptions(
bare = Cint(isbare),
Expand Down
6 changes: 5 additions & 1 deletion base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ Matches the [`git_remote_callbacks`](https://libgit2.github.com/libgit2/#HEAD/ty
end

function RemoteCallbacks(credentials::Ptr{Void}, payload::Ref{Nullable{AbstractCredentials}})
RemoteCallbacks(credentials=credentials_cb(), payload=pointer_from_objref(payload))
RemoteCallbacks(credentials=credentials, payload=pointer_from_objref(payload))
end

function RemoteCallbacks(credentials::Ptr{Void}, payload::Nullable{<:AbstractCredentials})
RemoteCallbacks(credentials, Ref{Nullable{AbstractCredentials}}(payload))
end

"""
Expand Down

0 comments on commit 51fbb0c

Please sign in to comment.