Skip to content

Conversation

omus
Copy link
Member

@omus omus commented Mar 13, 2018

Spin off of #26387. Support having separate payloads for each callback in RemoteCallbacks. Specifically this change was made to support using the credential callback included in LibGit2.jl and the progress bar proposed in JuliaLang/Pkg.jl#177.

There is a little work yet to do including:

  • Documenting the new interface to RemoteCallbacks where tuples of callbacks/payloads are passed in
  • Tests

@omus omus added the libgit2 The libgit2 library or the LibGit2 stdlib module label Mar 13, 2018
@omus
Copy link
Member Author

omus commented Mar 13, 2018

cc: @KristofferC

@@ -206,6 +206,27 @@ abstract type Payload end
payload::Ptr{Cvoid}
end

@kwdef struct CallbackPayload
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll rename this to RemotePayloads

@@ -275,8 +275,9 @@ function fetch(repo::GitRepo; remote::AbstractString="origin",
GitRemoteAnon(repo, remoteurl)
end
result = try
fo = FetchOptions(callbacks=RemoteCallbacks(credentials=credentials_cb(), payload=p))
fetch(rmt, refspecs, msg="from $(url(rmt))", options = fo)
callbacks = RemoteCallbacks(credentials=(credentials_cb(), pointer_from_objref(p)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointer_from_objref is fishy here since it allows p to be gc'd,
that's why original code uses Ref.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GC.@preserve it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too brittle and error-prone. This code really just needs to avoid using Ptr{Void} and stick with Ref.

push_transfer_progress::Ptr{Cvoid}
push_update_reference::Ptr{Cvoid}
push_negotiation::Ptr{Cvoid}
transport::Ptr{Cvoid}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are Julia handles. They should not be typed as opaque C handles. It looks like the input is a Dict, so RemotePayloads can also just be a Dict{Symbol, Any}.

Copy link
Member Author

@omus omus Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I use Any or Ref{Any}. We could do either.

@omus omus force-pushed the cv/libgit2-remote-callbacks branch from d967cbe to 297d998 Compare March 14, 2018 05:57
@omus
Copy link
Member Author

omus commented Mar 14, 2018

I can't seem to reproduce the CI failures locally. I'll push part of my work to try and sort out what's going wrong.

@KristofferC
Copy link
Member

Any update here?

@omus
Copy link
Member Author

omus commented Mar 24, 2018

Sorry, I've been on a work trip this last week. I'm planning on making this my highest priority when I get back.

omus added 3 commits March 28, 2018 14:10
LibGit2 functions `clone`, `fetch`, and `push` all used a keyword named
`payload` which would only take credential information. The keyword was
renamed to `credentials` to be more accurate and the original keyword
is now deprecated.
Make it easier to support mixing user created callbacks and default
callbacks defined by LibGit2.
@omus omus force-pushed the cv/libgit2-remote-callbacks branch from dfc8548 to 7dba146 Compare March 28, 2018 20:05
@omus omus added the deprecation This change introduces or involves a deprecation label Mar 28, 2018
@omus
Copy link
Member Author

omus commented Mar 28, 2018

I spent some more time with these changes and decided that it would be best to have high-level clone/fetch/push function support user callbacks. To me it makes the most sense to have this interface support having each callback be able to have an independent payload.

@omus
Copy link
Member Author

omus commented Mar 29, 2018

macOS failure on Travis looks to be a DNS issue. I'll have some tests shortly for this PR.

@omus
Copy link
Member Author

omus commented Mar 29, 2018

Wow, I passed the CI gauntlet 😄. The PR should be ready to go now. The tests aren't exhaustive but they should cover the basics.

@StefanKarpinski
Copy link
Member

@KristofferC, do you want to review this or should we just merge?

@KristofferC KristofferC merged commit 359f39a into master Mar 30, 2018
@StefanKarpinski StefanKarpinski deleted the cv/libgit2-remote-callbacks branch March 30, 2018 18:03
@KristofferC KristofferC mentioned this pull request Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants