Only support `rad://` in the custom proto

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-09-28 13:45:03 +02:00
parent 1da38708fc
commit f85a0426d7
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View File

@ -894,7 +894,7 @@ mod tests {
});
// Register the `rad://` transport.
transport::register("rad").unwrap();
transport::register().unwrap();
// Fetch with the `rad://` transport.
target
.remote_anonymous(&format!("rad://{}", proj))

View File

@ -160,13 +160,14 @@ impl io::Read for Stream {
///
/// Returns an error if called more than once.
///
pub fn register(prefix: &str) -> Result<(), git2::Error> {
pub fn register() -> Result<(), git2::Error> {
static REGISTERED: atomic::AtomicBool = atomic::AtomicBool::new(false);
// Registration is not thread-safe, so make sure we prevent re-entrancy.
if !REGISTERED.swap(true, atomic::Ordering::SeqCst) {
unsafe {
git2::transport::register(prefix, move |remote| {
let prefix = git::url::Scheme::Radicle.to_string();
git2::transport::register(&prefix, move |remote| {
git2::transport::Transport::smart(remote, false, self::smart())
})
}