bit_protocol

    Git wire protocol + transport (gix-protocol + gix-transport)

    git
    protocol
    transport
    Download zip
    Author
    Version
    0.48.0
    License
    Apache-2.0
    Last updated
    9 days ago
    Downloads
    1K

    FetchPackResult

    pub struct FetchPackResult {
    pack : Bytes
    shallow : Array[
    ObjectId
    ]
    unshallow : Array[
    ObjectId
    ]
    }

    FilterSpec

    pub(all) enum FilterSpec {
    NoFilter
    BlobNone
    BlobLimit(Int64)
    TreeDepth(Int)
    SparseOid(String)
    SparsePathUnsupported
    }

    Filter specification for partial clone

    FilterSpec::is_partial

    fn FilterSpec::is_partial(self : FilterSpec) -> Bool

    FilterSpec::to_string

    fn FilterSpec::to_string(self : FilterSpec) -> String

    LsRefsResult

    pub struct LsRefsResult {
    refs : Array[(
    ObjectId
    , String)]
    symrefs : Map[String, String]
    }

    ProtocolVersion

    pub(all) enum ProtocolVersion {
    V0
    V2
    } derive(Eq)

    PushRequest

    pub struct PushRequest {
    old_id :
    ObjectId

    new_id :
    ObjectId

    refname : String
    packfile : Bytes
    }

    Git push request data

    PushRequest::new

    fn PushRequest::new(old_id :
    ObjectId
    , new_id :
    ObjectId
    , refname : String, packfile : Bytes) -> PushRequest

    Remote

    pub struct Remote {
    url : String
    }

    Remote repository URL

    Remote::info_refs_url

    fn Remote::info_refs_url(self : Remote) -> String

    Build URL for git-receive-pack info/refs

    Remote::new

    fn Remote::new(url : String) -> Remote

    Remote::receive_pack_url

    fn Remote::receive_pack_url(self : Remote) -> String

    Build URL for git-receive-pack

    RemoteKind

    pub(all) enum RemoteKind {
    Http
    Ssh
    File
    } derive(Eq)

    RemoteSpec

    pub struct RemoteSpec {
    kind : RemoteKind
    raw : String
    host : String?
    path : String
    base_url : String?
    }

    build_fetch_request_v0

    fn build_fetch_request_v0(agent : String, wants : Array[
    ObjectId
    ], advertised : Array[String], depth? : Int, filter? : FilterSpec, haves? : Array[
    ObjectId
    ], shallow? : Array[
    ObjectId
    ]) -> Bytes

    Build the shared protocol v0/v1 fetch negotiation request.

    Protocol v1 changes reference advertisement, but uses the v0 request grammar. Capabilities and extension lines are emitted only when advertised.

    build_fetch_request_v2

    fn build_fetch_request_v2(agent : String, wants : Array[
    ObjectId
    ], depth : Int, filter? : FilterSpec, haves? : Array[
    ObjectId
    ], shallow? : Array[
    ObjectId
    ]) -> Bytes

    Build a fetch request for protocol v2.
    • depth > 0: shallow clone with that depth
    • filter: partial clone filter specification
    • haves: commit tips already present locally
    • shallow: local commits whose parents are not present

    build_ls_refs_request

    fn build_ls_refs_request(agent : String, prefixes : Array[String]) -> Bytes

    build_receive_pack_body

    fn build_receive_pack_body(req : PushRequest) -> Bytes

    Build the request body for git-receive-pack

    build_ref_update

    fn build_ref_update(old_id :
    ObjectId
    , new_id :
    ObjectId
    , refname : String, capabilities : String) -> String

    Build a ref update command for git-receive-pack Format: {old_sha} {new_sha} {refname}\0{capabilities}\n

    build_ref_update_simple

    fn build_ref_update_simple(old_id :
    ObjectId
    , new_id :
    ObjectId
    , refname : String) -> String

    Build a ref update command (without capabilities)

    clone_to_async_fs_with_http

    async fn[FS :
    AsyncFileSystem
    +
    AsyncRepoFileSystem
    , Client :
    AsyncHttpClient
    ] clone_to_async_fs_with_http(remote : String, prefer_v2 : Bool, depth : Int, filter : FilterSpec, fs : FS, root : String, client : Client, no_checkout? : Bool) -> Array[(
    ObjectId
    , String)] raise
    GitError

    Clone through asynchronous HTTP and filesystem implementations.

    clone_to_fs_with_http

    async fn clone_to_fs_with_http(remote : String, prefer_v2 : Bool, depth : Int, filter : FilterSpec, fs : &
    FileSystem
    , root : String, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , rfs : &
    RepoFileSystem
    , no_checkout? : Bool) -> Array[(
    ObjectId
    , String)] raise
    GitError

    clone_with_http

    async fn clone_with_http(remote : String, prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> (Array[(
    ObjectId
    , String)], Array[
    PackObject
    ]) raise
    GitError

    detect_protocol_version

    fn detect_protocol_version(data : Bytes) -> ProtocolVersion raise
    GitError

    discover_refs_with_http

    async fn discover_refs_with_http(remote : Remote, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> (Array[(
    ObjectId
    , String)], Array[String]) raise
    GitError

    Discover refs using provided HTTP client functions

    discover_upload_refs_with_http

    async fn discover_upload_refs_with_http(remote : String, prefer_v2 : Bool, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> (Array[(
    ObjectId
    , String)], Array[String], ProtocolVersion, Map[String, String]) raise
    GitError

    extract_capabilities

    fn extract_capabilities(data : Bytes) -> Array[String]

    Extract capabilities from refs response

    extract_pack_from_v0_response

    fn extract_pack_from_v0_response(data : Bytes) -> Bytes raise
    GitError

    extract_pack_from_v2_response

    fn extract_pack_from_v2_response(data : Bytes) -> Bytes raise
    GitError

    fetch_objects_with_http

    async fn fetch_objects_with_http(remote : String, wants : Array[
    ObjectId
    ], prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , haves? : Array[
    ObjectId
    ], shallow? : Array[
    ObjectId
    ]) -> Array[
    PackObject
    ] raise
    GitError

    fetch_pack_with_http

    async fn fetch_pack_with_http(remote : String, wants : Array[
    ObjectId
    ], prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , haves? : Array[
    ObjectId
    ], shallow? : Array[
    ObjectId
    ]) -> Bytes raise
    GitError

    fetch_pack_with_http_result

    async fn fetch_pack_with_http_result(remote : String, wants : Array[
    ObjectId
    ], prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , haves? : Array[
    ObjectId
    ], shallow? : Array[
    ObjectId
    ]) -> FetchPackResult raise
    GitError

    parse_fetch_response_v0

    fn parse_fetch_response_v0(data : Bytes) -> FetchPackResult raise
    GitError

    parse_fetch_response_v2

    fn parse_fetch_response_v2(data : Bytes) -> FetchPackResult raise
    GitError

    parse_ls_refs_response

    fn parse_ls_refs_response(data : Bytes) -> LsRefsResult raise
    GitError

    parse_receive_pack_response

    fn parse_receive_pack_response(data : Bytes) -> Result[String,
    GitError
    ]

    Parse receive-pack response

    parse_refs

    fn parse_refs(data : Bytes) -> Array[(
    ObjectId
    , String)] raise
    GitError

    Parse refs from git-receive-pack response Format: {sha} {refname}\0{capabilities}\n (for first line) {sha} {refname}\n (for subsequent lines)

    parse_remote

    fn parse_remote(remote : String) -> RemoteSpec

    parse_sideband

    fn parse_sideband(data : Bytes) -> (Int, Bytes)

    Parse side-band data

    parse_symrefs_from_capabilities

    fn parse_symrefs_from_capabilities(caps : Array[String]) -> Map[String, String]

    parse_v0_advertised_caps

    fn parse_v0_advertised_caps(data : Bytes) -> Array[String] raise
    GitError

    parse_v2_advertised_caps

    fn parse_v2_advertised_caps(data : Bytes) -> Array[String] raise
    GitError

    pktline_decode

    fn pktline_decode(data : Bytes) -> Array[(Bytes, Bool)] raise
    GitError

    Decode pkt-lines from bytes Returns array of (data, is_flush)

    pktline_delim

    fn pktline_delim() -> Bytes

    Delimiter packet (0001)

    pktline_encode

    fn pktline_encode(data : String) -> Bytes

    Encode a single pkt-line Format: {4-hex-length}{payload} Length includes the 4-byte header

    pktline_encode_bytes

    fn pktline_encode_bytes(data : Bytes) -> Bytes

    Encode pkt-line from bytes

    pktline_flush

    fn pktline_flush() -> Bytes

    Flush packet (0000)

    push_with_http

    async fn push_with_http(remote : Remote, req : PushRequest, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    , http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> String raise
    GitError

    Push using provided HTTP client functions

    sanitize_sideband_text

    fn sanitize_sideband_text(data : Bytes) -> Bytes

    Strip terminal control sequences from sideband payload before it reaches the user's terminal. Mirrors git 2.55's sideband.allowControlCharacters=color default: line feeds, tabs and ANSI color (CSI ... m) pass through; every other C0/C1 byte and every non-color CSI sequence is replaced with ?.

    A hostile remote can otherwise push CSI sequences via band 2 (progress) or band 3 (error). Bit's band 3 handling turns the payload into a GitError message that flows to stderr, so an attacker could clear the screen, hide their output, or fake a password prompt.

    select_default_ref

    fn select_default_ref(refs : Array[(
    ObjectId
    , String)], symrefs : Map[String, String]) -> (String,
    ObjectId
    )?

    select_default_wants

    fn select_default_wants(refs : Array[(
    ObjectId
    , String)], symrefs : Map[String, String]) -> Array[
    ObjectId
    ]

    ssh_remote_to_https

    fn ssh_remote_to_https(remote : String) -> String?

    Convert SSH-style remote URL into HTTPS smart transport URL. Returns None for non-SSH remotes.

    upload_pack_info_refs_with_http

    async fn upload_pack_info_refs_with_http(remote : String, prefer_v2 : Bool, http_get : async (String, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> Bytes raise
    GitError

    upload_pack_request_with_http

    async fn upload_pack_request_with_http(remote : String, body : Bytes, prefer_v2 : Bool, http_post : async (String, Bytes, Map[String, String]) -> (
    HttpResponse
    , Bytes) raise
    GitError
    ) -> Bytes raise
    GitError

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io