@@ -63,6 +63,19 @@ function GitRemoteAnon(repo::GitRepo, url::AbstractString)
6363 return GitRemote (repo, rmt_ptr_ptr[])
6464end
6565
66+ """
67+ GitRemoteDetached(url::AbstractString) -> GitRemote
68+
69+ Create a remote without a connected local repo.
70+ """
71+ function GitRemoteDetached (url:: AbstractString )
72+ ensure_initialized ()
73+ rmt_ptr_ptr = Ref {Ptr{Cvoid}} (C_NULL )
74+ @check ccall ((:git_remote_create_detached , :libgit2 ), Cint,
75+ (Ptr{Ptr{Cvoid}}, Cstring), rmt_ptr_ptr, url)
76+ return GitRemote (rmt_ptr_ptr[])
77+ end
78+
6679"""
6780 lookup_remote(repo::GitRepo, remote_name::AbstractString) -> Union{GitRemote, Nothing}
6881
@@ -414,3 +427,65 @@ function set_remote_url(path::AbstractString, remote_name::AbstractString, url::
414427 set_remote_url (repo, remote_name, url)
415428 end
416429end
430+
431+ function connect (rmt:: GitRemote , direction:: Consts.GIT_DIRECTION ,
432+ callbacks:: RemoteCallbacks )
433+ @check ccall ((:git_remote_connect , :libgit2 ),
434+ Cint, (Ptr{Cvoid}, Cint, Ref{RemoteCallbacks}, Ptr{Cvoid}, Ptr{Cvoid}),
435+ rmt. ptr, direction, callbacks, C_NULL , C_NULL )
436+ return rmt
437+ end
438+
439+ """
440+ connected(rmt::GitRemote)
441+
442+ Check whether the remote is connected
443+ """
444+ function connected (rmt:: GitRemote )
445+ return ccall ((:git_remote_connected , :libgit2 ), Cint, (Ptr{Cvoid},), rmt. ptr) != 0
446+ end
447+
448+ """
449+ disconnect(rmt::GitRemote)
450+
451+ Close the connection to the remote.
452+ """
453+ function disconnect (rmt:: GitRemote )
454+ @check ccall ((:git_remote_disconnect , :libgit2 ), Cint, (Ptr{Cvoid},), rmt. ptr)
455+ return
456+ end
457+
458+ """
459+ default_branch(rmt::GitRemote)
460+
461+ Retrieve the name of the remote's default branch.
462+
463+ This function must only be called after connecting (See [`connect`](@ref)).
464+ """
465+ function default_branch (rmt:: GitRemote )
466+ buf_ref = Ref (Buffer ())
467+ @check ccall ((:git_remote_default_branch , :libgit2 ), Cint,
468+ (Ptr{Buffer}, Ptr{Cvoid}), buf_ref, rmt. ptr)
469+ buf = buf_ref[]
470+ str = unsafe_string (buf. ptr, buf. size)
471+ free (buf_ref)
472+ return str
473+ end
474+
475+ """
476+ ls(rmt::GitRemote) -> Vector{GitRemoteHead}
477+
478+ Get the remote repository's reference advertisement list.
479+
480+ This function must only be called after connecting (See [`connect`](@ref)).
481+ """
482+ function ls (rmt:: GitRemote )
483+ nheads = Ref {Csize_t} ()
484+ head_refs = Ref {Ptr{Ptr{_GitRemoteHead}}} ()
485+ @check ccall ((:git_remote_ls , :libgit2 ), Cint,
486+ (Ptr{Ptr{Ptr{_GitRemoteHead}}}, Ptr{Csize_t}, Ptr{Cvoid}),
487+ head_refs, nheads, rmt. ptr)
488+ head_ptr = head_refs[]
489+ return [GitRemoteHead (unsafe_load (unsafe_load (head_ptr, i)))
490+ for i in 1 : nheads[]]
491+ end
0 commit comments