How do I pass an authentication callback to git2::Repository::clone()
? (set_remote_callbacks
sets up the callbacks).
I have some code like the following:
let mut cb = git2::RemoteCallbacks::new();
Self::set_remote_callbacks(&mut cb);
let rr = Repository::clone(url, path.to_str().ok_or("bad string".to_string())?);
What I want is like, as an example, when I do I fetch, I do this, which passes my callbacks to the fetch
:
let mut fetchOptions = FetchOptions::new();
let mut cb = git2::RemoteCallbacks::new();
Self::set_remote_callbacks(&mut cb);
fetchOptions.remote_callbacks(cb);
let mut remote = self.repo.find_remote(remote)?;
remote.fetch(&[branch], Some(&mut fetchOptions), None)?;
Use git2::build::RepoBuilder
.
Credit goes to issue 329 on the git2 issue tracker.