Add bindings for push_negotiation callback#926
Conversation
samueltardieu
left a comment
There was a problem hiding this comment.
I think this is a great addition to git2-rs, I hope it can be merged soon.
ehuss
left a comment
There was a problem hiding this comment.
Thanks, sorry for the long delay.
| /// commands to the destination. | ||
| /// | ||
| /// The return value indicates whether the push should continue. | ||
| pub type PushNegotiation<'a> = dyn FnMut(&[PushUpdate<'_>]) -> bool + 'a; |
There was a problem hiding this comment.
Is there any particular reason this returns a bool? I was thinking it could return a Result<(), Error>, similar to other callbacks so that it is clear that it is triggering an error. A bool seems more innocuous, and not a typical way to do error handling in Rust.
There was a problem hiding this comment.
Thanks for the review! I've made the changes. I might have been emulating sideband_progress, where the callback also returns a bool to decide whether to cancel the operation, but using a Result is indeed more idiomatic here.
ehuss
left a comment
There was a problem hiding this comment.
Thanks!
Yea, after looking more closely I realized that the callbacks aren't very consistent if they use bools or Results.
Also, thanks for adding the detailed test!
This fixes #733 .
This PR adds
RemoteCallbacks::push_negotiation,PushNegotiationandPushUpdateto expose thepush_negotiationcallback. A test is added at the end ofsrc/remote.rs.