git

Pure MoonBit Git implementation

git
packfile
protocol
moon add mizchi/git@0.2.0
Download zip
Author
Version
0.2.0
License
Apache-2.0
Last updated
6 months ago
Downloads
42
README

#mizchi/moonbit_template

#
FileSystem

pub(open) trait FileSystem {
mkdir_p(Self, String) -> Unit raise GitError
write_file(Self, String, Bytes) -> Unit raise GitError
write_string(Self, String, String) -> Unit raise GitError
remove_file(Self, String) -> Unit raise GitError
remove_dir(Self, String) -> Unit raise GitError
}

#
HttpClient

pub(open) trait HttpClient {
get(Self, String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError
post(Self, String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError
}

HTTP client trait for abstracting HTTP operations Implementations:
  • Native: Uses @http package (real HTTP)
  • WASM/JS: Uses browser fetch API
  • Test: Mock implementation for testing

#
RepoFileSystem

pub(open) trait RepoFileSystem {
read_file(Self, String) -> Bytes raise GitError
readdir(Self, String) -> Array[String] raise GitError
is_dir(Self, String) -> Bool
is_file(Self, String) -> Bool
}

Read-only filesystem abstraction for loading git objects

#
GitError

pub(all) suberror GitError {
InvalidObject(String)
HashMismatch(String, String)
PackfileError(String)
ProtocolError(String)
IoError(String)
}

Git operation errors
impl Eq for GitError
impl Show for GitError

#
Commit

pub struct Commit {
tree : ObjectId
parents : Array[ObjectId]
author : String
author_time : Int64
author_tz : String
committer : String
commit_time : Int64
committer_tz : String
message : String
}

Git commit object

#
Commit::new

fn Commit::new(tree : ObjectId, parents : Array[ObjectId], author : String, author_time : Int64, author_tz : String, committer : String, commit_time : Int64, committer_tz : String, message : String) -> Commit

#
CommitInfo

pub struct CommitInfo {
tree : ObjectId
parents : Array[ObjectId]
}

#
FilterSpec

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

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

#
HttpResponse

pub struct HttpResponse {
code : Int
headers : Map[String, String]
}

#
HttpResponse::new

fn HttpResponse::new(code : Int) -> HttpResponse

#
HttpResponse::with_headers

fn HttpResponse::with_headers(code : Int, headers : Map[String, String]) -> HttpResponse

#
LsRefsResult

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

#
MockHttpClient

pub struct MockHttpClient {
responses : Map[String, (Int, Bytes)]
}

Mock HTTP client for testing

#
MockHttpClient::add_response

fn MockHttpClient::add_response(self : MockHttpClient, url : String, code : Int, body : Bytes) -> Unit

#
MockHttpClient::new

#
NativeHttpClient

pub struct NativeHttpClient {
dummy : Int
}

#
NativeHttpClient::new

#
ObjectId

pub struct ObjectId {
bytes : FixedArray[Byte]
}

SHA-1 object identifier (20 bytes)
impl Eq for ObjectId
impl Hash for ObjectId
impl Show for ObjectId

#
ObjectId::from_bytes

fn ObjectId::from_bytes(data : Bytes) -> ObjectId raise GitError

Create ObjectId from Bytes (must be exactly 20 bytes)

#
ObjectId::from_bytes_at

fn ObjectId::from_bytes_at(data : Bytes, offset : Int) -> ObjectId

Create ObjectId from Bytes at offset (for parsing packed data)

#
ObjectId::from_hex

fn ObjectId::from_hex(hex : String) -> ObjectId raise GitError

#
ObjectId::new

fn ObjectId::new(bytes : FixedArray[Byte]) -> ObjectId

#
ObjectId::to_bytes

fn ObjectId::to_bytes(self : ObjectId) -> Bytes

Convert ObjectId to Bytes (20 bytes) - zero-copy when possible

#
ObjectId::to_hex

fn ObjectId::to_hex(self : ObjectId) -> String

#
ObjectId::zero

fn ObjectId::zero() -> ObjectId

#
ObjectStore

pub struct ObjectStore {
objects : Map[String, PackObject]
}

#
ObjectStore::add_objects

fn ObjectStore::add_objects(self : ObjectStore, objects : Array[PackObject]) -> Unit

#
ObjectStore::contains

fn ObjectStore::contains(self : ObjectStore, id : ObjectId) -> Bool

#
ObjectStore::from_pack

fn ObjectStore::from_pack(objects : Array[PackObject]) -> ObjectStore

#
ObjectStore::get

fn ObjectStore::get(self : ObjectStore, id : ObjectId) -> PackObject?

#
ObjectStore::new

#
ObjectType

pub(all) enum ObjectType {
Blob
Tree
Commit
Tag
}

Git object types
impl Eq for ObjectType
impl Show for ObjectType

#
ObjectType::to_packfile_type

fn ObjectType::to_packfile_type(self : ObjectType) -> Int

#
ObjectType::to_string

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

#
PackDeltaMode

pub(all) enum PackDeltaMode {
NoDelta
RefDelta
OfsDelta
}

Delta encoding mode for packfile generation

#
PackObject

pub struct PackObject {
obj_type : ObjectType
data : Bytes
id : ObjectId
offset : Int
crc32 : UInt
}

A Git object ready for packing

#
PackObject::new

fn PackObject::new(obj_type : ObjectType, data : Bytes) -> PackObject

#
PackObject::with_metadata

fn PackObject::with_metadata(obj_type : ObjectType, data : Bytes, id : ObjectId, offset : Int, crc32 : UInt) -> PackObject

#
ProtocolVersion

pub(all) enum ProtocolVersion {
V0
V2
}

#
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
}

impl Eq for RemoteKind

#
RemoteSpec

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

#
Sha1State

pub struct Sha1State {
h : FixedArray[Int]
block : FixedArray[Byte]
w : FixedArray[Int]
block_len : Int
total_len : Int64
}

Incremental SHA-1 state

#
Sha1State::finish

fn Sha1State::finish(self : Sha1State) -> ObjectId

#
Sha1State::new

fn Sha1State::new() -> Sha1State

#
Sha1State::reset

fn Sha1State::reset(self : Sha1State) -> Unit

#
Sha1State::update

fn Sha1State::update(self : Sha1State, data : Bytes) -> Unit

#
Sha1State::update_byte

fn Sha1State::update_byte(self : Sha1State, b : Byte) -> Unit

#
Sha1State::update_slice

fn Sha1State::update_slice(self : Sha1State, data : Bytes, offset : Int, len : Int) -> Unit

#
Sha1State::update_string

fn Sha1State::update_string(self : Sha1State, s : String) -> Unit

#
TestFs

pub struct TestFs {
files : Map[String, Bytes]
dirs : Map[String, Bool]
}

#
TestFs::exists

fn TestFs::exists(self : TestFs, path : String) -> Bool

#
TestFs::is_dir

fn TestFs::is_dir(self : TestFs, path : String) -> Bool

#
TestFs::is_file

fn TestFs::is_file(self : TestFs, path : String) -> Bool

#
TestFs::mkdir_p

fn TestFs::mkdir_p(self : TestFs, path : String) -> Unit

#
TestFs::new

fn TestFs::new() -> TestFs

#
TestFs::read_file

fn TestFs::read_file(self : TestFs, path : String) -> Bytes raise GitError

#
TestFs::read_string

fn TestFs::read_string(self : TestFs, path : String) -> String raise GitError

#
TestFs::readdir

fn TestFs::readdir(self : TestFs, path : String) -> Array[String] raise GitError

#
TestFs::remove_dir

fn TestFs::remove_dir(self : TestFs, path : String) -> Unit raise GitError

#
TestFs::remove_file

fn TestFs::remove_file(self : TestFs, path : String) -> Unit raise GitError

#
TestFs::write_file

fn TestFs::write_file(self : TestFs, path : String, content : Bytes) -> Unit

#
TestFs::write_string

fn TestFs::write_string(self : TestFs, path : String, content : String) -> Unit

#
TreeEntry

pub struct TreeEntry {
mode : String
name : String
id : ObjectId
}

Tree entry in a Git tree object

#
TreeEntry::new

fn TreeEntry::new(mode : String, name : String, id : ObjectId) -> TreeEntry

#
apply_delta

fn apply_delta(base : Bytes, delta : Bytes) -> Bytes raise GitError

#
build_fetch_request_v0

fn build_fetch_request_v0(agent : String, wants : Array[ObjectId], advertised : Array[String]) -> Bytes

#
build_fetch_request_v2

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

Build a fetch request for protocol v2.
  • depth > 0: shallow clone with that depth
  • filter: partial clone filter specification

#
build_ls_refs_request

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

#
build_pack_index

fn build_pack_index(pack : Bytes) -> Bytes raise GitError

Build a pack index (v2) from packfile bytes.

#
build_pack_index_from_objects

fn build_pack_index_from_objects(pack : Bytes, objects : Array[PackObject]) -> Bytes raise GitError

Build a pack index (v2) from packfile bytes and parsed objects. Uses cached metadata (id, offset, crc32) from PackObject when available.

#
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)

#
checkout_commit

fn checkout_commit(store : ObjectStore, commit_id : ObjectId) -> Map[String, Bytes] raise GitError

#
checkout_commit_to_fs

fn checkout_commit_to_fs(store : ObjectStore, commit_id : ObjectId, fs : &FileSystem, root : String) -> Unit raise GitError

Materialize commit files into a filesystem under root.

#
clone_http

async fn clone_http(remote : String, prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitError

#
clone_http_to_fs

async fn clone_http_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String, depth? : Int, filter? : FilterSpec) -> Array[(ObjectId, String)] raise GitError

Clone and checkout into filesystem under root.
  • depth > 0: shallow clone with that depth
  • filter: partial clone filter (e.g., FilterSpec::BlobNone)

#
clone_process

async fn clone_process(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitError

#
clone_process_to_fs

async fn clone_process_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String) -> Array[(ObjectId, String)] raise GitError

Clone and checkout into filesystem under root.

#
clone_remote

async fn clone_remote(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitError

#
clone_remote_to_fs

async fn clone_remote_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String) -> Array[(ObjectId, String)] raise GitError

#
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) -> Array[(ObjectId, String)] raise GitError

Clone and checkout into filesystem using provided HTTP client.
  • depth > 0: shallow clone with that depth
  • filter: partial clone filter (if BlobNone, skip checkout)

#
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

Clone using provided HTTP client.
  • depth > 0: shallow clone with that depth
  • filter: partial clone filter

#
crc32_range

fn crc32_range(data : Bytes, start : Int, end : Int) -> UInt raise GitError

#
create_blob

fn create_blob(content : Bytes) -> (ObjectId, Bytes)

Create a blob object from content

#
create_blob_packfile

fn create_blob_packfile(content : Bytes) -> Bytes

Create a packfile containing a single blob

#
create_blob_string

fn create_blob_string(content : String) -> (ObjectId, Bytes)

Create a blob from string content

#
create_commit

fn create_commit(commit : Commit) -> (ObjectId, Bytes)

Create a commit object

#
create_commit_packfile

fn create_commit_packfile(blob_content : Bytes, filename : String, commit : Commit) -> (ObjectId, Bytes)

Create a packfile with blob, tree, and commit

#
create_object

fn create_object(obj_type : ObjectType, content : Bytes) -> (ObjectId, Bytes)

Create a Git object and return its ID and compressed data Format: {type} {size}\0{content} -> SHA-1 -> zlib compress

#
create_packfile

fn create_packfile(objects : Array[PackObject]) -> Bytes

Create a packfile from a list of objects Format: [PACK] 4 bytes magic [version] 4 bytes (big-endian, always 2) [object count] 4 bytes (big-endian) [...objects...] variable [SHA-1 trailer] 20 bytes

#
create_packfile_with_delta

fn create_packfile_with_delta(objects : Array[PackObject], delta_mode : PackDeltaMode) -> Bytes

Create a packfile from a list of objects with a chosen delta mode

#
create_packfile_with_delta_stats

fn create_packfile_with_delta_stats(objects : Array[PackObject], delta_mode : PackDeltaMode) -> (Bytes, Int)

Create a packfile with delta statistics (delta object count)

#
create_tree

fn create_tree(entries : Array[TreeEntry]) -> (ObjectId, Bytes)

Create a tree object from entries Entries must be sorted by name

#
decode_type_and_size_at

fn decode_type_and_size_at(data : Bytes, start : Int) -> (Int, Int, Int) raise GitError

Decode packfile object header and return (type_id, size, next_offset).

#
detect_protocol_version

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

#
discover_receive_refs_http

async fn discover_receive_refs_http(remote : Remote) -> Array[(ObjectId, String)] raise GitError

Fetch receive-pack refs via smart HTTP (native)

#
discover_refs

async fn discover_refs(remote : Remote) -> (Array[(ObjectId, String)], Array[String]) raise GitError

Discover refs and capabilities from remote (native)

#
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

async fn discover_upload_refs(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[String], ProtocolVersion, Map[String, String]) raise GitError

#
discover_upload_refs_http

async fn discover_upload_refs_http(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[String], ProtocolVersion, Map[String, String]) raise GitError

#
discover_upload_refs_process

async fn discover_upload_refs_process(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[String], ProtocolVersion, Map[String, String]) raise GitError

#
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

Discover upload refs using provided HTTP client

#
encode_type_and_size

fn encode_type_and_size(obj_type : Int, size : Int, result : Array[Byte]) -> Unit

Encode type and size in Git's variable-length format

#
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

async fn fetch_objects(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Array[PackObject] raise GitError

#
fetch_objects_http

async fn fetch_objects_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> Array[PackObject] raise GitError

#
fetch_objects_process

async fn fetch_objects_process(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Array[PackObject] 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) -> Array[PackObject] raise GitError

Fetch objects using provided HTTP client.
  • depth > 0: shallow clone with that depth
  • filter: partial clone filter

#
fetch_pack

async fn fetch_pack(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Bytes raise GitError

#
fetch_pack_http

async fn fetch_pack_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> Bytes raise GitError

#
fetch_pack_process

async fn fetch_pack_process(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Bytes 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) -> Bytes raise GitError

Fetch pack using provided HTTP client.
  • depth > 0: shallow clone with that depth (v2 only)
  • filter: partial clone filter (v2 only)

#
generate_commit_packfile

fn generate_commit_packfile() -> (ObjectId, Bytes)

#
generate_test_packfile

fn generate_test_packfile() -> Bytes

#
hash_blob

fn hash_blob(content : Bytes) -> ObjectId

Hash a blob without creating the compressed object - optimized with incremental SHA1

#
hash_blob_string

fn hash_blob_string(content : String) -> ObjectId

Hash a blob from string - optimized with incremental SHA1

#
hash_object_content

fn hash_object_content(obj_type : ObjectType, content : Bytes) -> ObjectId

Hash object content (without compression) - optimized with incremental SHA1

#
hex_dump

fn hex_dump(data : Bytes) -> String

Print packfile as hex dump for debugging

#
materialize_clone_to_fs

fn materialize_clone_to_fs(store : ObjectStore, commit_id : ObjectId, refname : String, remote_url : String, fs : &FileSystem, root : String) -> Unit raise GitError

#
native_http_get

async fn native_http_get(url : String, headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitError

#
native_http_post

async fn native_http_post(url : String, body : Bytes, headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitError

#
packfile_type_to_object_type

fn packfile_type_to_object_type(type_id : Int) -> ObjectType raise GitError

Convert packfile type id to ObjectType.

#
parse_commit

fn parse_commit(content : Bytes) -> CommitInfo raise GitError

#
parse_ls_refs_response

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

#
parse_packfile

fn parse_packfile(data : Bytes) -> Array[PackObject] raise GitError

Parse a packfile into objects.

#
parse_packfile_stream

fn parse_packfile_stream(data : Bytes, emit : (PackObject) -> Unit) -> Unit raise GitError

Parse a packfile and emit resolved objects (order not guaranteed).

#
parse_packfile_stream_with_bases

fn parse_packfile_stream_with_bases(data : Bytes, bases : Array[PackObject], emit : (PackObject) -> Unit) -> Unit raise GitError

Parse a packfile with base objects and emit resolved objects.

#
parse_packfile_with_bases

fn parse_packfile_with_bases(data : Bytes, bases : Array[PackObject]) -> Array[PackObject] raise GitError

Parse a packfile with preloaded base objects (for thin packs).

#
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_tree

fn parse_tree(content : Bytes) -> Array[TreeEntry] raise GitError

#
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

async fn push(remote : Remote, req : PushRequest) -> String raise GitError

Push a packfile to remote repository (native)

#
push_file

async fn push_file(remote : Remote, content : Bytes, filename : String, message : String, author : String, timestamp : Int64, parent : ObjectId?) -> ObjectId raise GitError

Push a single file as a new commit (native)

#
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

#
read_ofs_delta_offset

fn read_ofs_delta_offset(data : Bytes, start : Int) -> (Int, Int) raise GitError

#
read_ref_delta_id

fn read_ref_delta_id(data : Bytes, start : Int) -> (String, Int) raise GitError

#
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]

#
sha1

fn sha1(data : Bytes) -> ObjectId

Compute SHA-1 hash of data

#
sha1_array

fn sha1_array(data : Array[Byte]) -> ObjectId

Compute SHA-1 hash of data from Array

#
sha1_array_prefix

fn sha1_array_prefix(data : Array[Byte], len : Int) -> ObjectId

Compute SHA-1 hash of Array prefix (first len bytes).

#
sha1_prefix

fn sha1_prefix(data : Bytes, len : Int) -> ObjectId

Compute SHA-1 hash of data prefix (first len bytes).

#
upload_pack_info_refs

async fn upload_pack_info_refs(remote : String, prefer_v2 : Bool) -> Bytes raise GitError

#
upload_pack_info_refs_http

async fn upload_pack_info_refs_http(remote : String, prefer_v2 : Bool) -> Bytes raise GitError

#
upload_pack_info_refs_process

async fn upload_pack_info_refs_process(remote : String, prefer_v2 : Bool) -> Bytes raise GitError

#
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

Fetch info/refs using provided HTTP client

#
upload_pack_request

async fn upload_pack_request(remote : String, body : Bytes, prefer_v2 : Bool) -> Bytes raise GitError

#
upload_pack_request_http

async fn upload_pack_request_http(remote : String, body : Bytes, prefer_v2 : Bool) -> Bytes raise GitError

#
upload_pack_request_process

async fn upload_pack_request_process(remote : String, body : Bytes, prefer_v2 : Bool) -> 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

Send upload-pack request using provided HTTP client

#
write_git_metadata

fn write_git_metadata(store : ObjectStore, commit_id : ObjectId, refname : String, remote_url : String, fs : &FileSystem, root : String) -> Unit raise GitError

#
write_pack_index

fn write_pack_index(fs : &FileSystem, idx_path : String, pack : Bytes) -> Unit raise GitError

Write a pack index to the filesystem.

#
write_pack_index_from_objects

fn write_pack_index_from_objects(fs : &FileSystem, idx_path : String, pack : Bytes, objects : Array[PackObject]) -> Unit raise GitError

Write a pack index using pre-parsed objects.

#
write_pack_index_from_objects_versioned

fn write_pack_index_from_objects_versioned(fs : &FileSystem, idx_path : String, pack : Bytes, objects : Array[PackObject], version : Int) -> Unit raise GitError

Write a pack index using pre-parsed objects with specific version.

#
write_packfile_with_index

fn write_packfile_with_index(fs : &FileSystem, git_dir : String, pack : Bytes, objects : Array[PackObject]) -> Unit raise GitError

Write a packfile and its index under .git/objects/pack.