@@ -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,70 @@ function set_remote_url(path::AbstractString, remote_name::AbstractString, url::
414427 set_remote_url (repo, remote_name, url)
415428 end
416429end
430+
431+ """
432+ connect(rmt::GitRemote, direction::Consts.GIT_DIRECTION)
433+
434+ Open a connection to a remote. `direction` can be either `DIRECTION_FETCH`
435+ or `DIRECTION_PUSH`.
436+ """
437+ function connect (rmt:: GitRemote , direction:: Consts.GIT_DIRECTION )
438+ @check ccall ((:git_remote_connect , :libgit2 ),
439+ Cint, (Ptr{Cvoid}, Cint, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
440+ rmt. ptr, direction, C_NULL , C_NULL , C_NULL )
441+ return rmt
442+ end
443+
444+ """
445+ connected(rmt::GitRemote)
446+
447+ Check whether the remote is connected
448+ """
449+ function connected (rmt:: GitRemote )
450+ return ccall ((:git_remote_connected , :libgit2 ), Cint, (Ptr{Cvoid},), rmt. ptr) != 0
451+ end
452+
453+ """
454+ disconnect(rmt::GitRemote)
455+
456+ Close the connection to the remote.
457+ """
458+ function disconnect (rmt:: GitRemote )
459+ @check ccall ((:git_remote_disconnect , :libgit2 ), Cint, (Ptr{Cvoid},), rmt. ptr)
460+ return
461+ end
462+
463+ """
464+ default_branch(rmt::GitRemote)
465+
466+ Retrieve the name of the remote's default branch.
467+
468+ This function must only be called after connecting (See [`connect`](@ref)).
469+ """
470+ function default_branch (rmt:: GitRemote )
471+ buf_ref = Ref (Buffer ())
472+ @check ccall ((:git_remote_default_branch , :libgit2 ), Cint,
473+ (Ptr{Buffer}, Ptr{Cvoid}), buf_ref, rmt. ptr)
474+ buf = buf_ref[]
475+ str = unsafe_string (buf. ptr, buf. size)
476+ free (buf_ref)
477+ return str
478+ end
479+
480+ """
481+ ls(rmt::GitRemote) -> Vector{GitRemoteHead}
482+
483+ Get the remote repository's reference advertisement list.
484+
485+ This function must only be called after connecting (See [`connect`](@ref)).
486+ """
487+ function ls (rmt:: GitRemote )
488+ nheads = Ref {Csize_t} ()
489+ head_refs = Ref {Ptr{Ptr{_GitRemoteHead}}} ()
490+ @check ccall ((:git_remote_ls , :libgit2 ), Cint,
491+ (Ptr{Ptr{Ptr{_GitRemoteHead}}}, Ptr{Csize_t}, Ptr{Cvoid}),
492+ head_refs, nheads, rmt. ptr)
493+ head_ptr = head_refs[]
494+ return [GitRemoteHead (unsafe_load (unsafe_load (head_ptr, i)))
495+ for i in 1 : nheads[]]
496+ end
0 commit comments