Sign in

    mizchi/bit/object does not have a README file

    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
    encoding : 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, encoding? : String) -> Commit

    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

    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

    PackCompression

    pub(all) enum PackCompression {
    Default
    Stored
    }

    Compression mode for packfile entries

    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

    Sha1State

    pub struct Sha1State {
    inner :
    Sha1State

    }

    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

    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

    create_blob

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

    Create a blob object from content

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

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

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

    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

    serialize_commit_content

    fn serialize_commit_content(commit : Commit) -> Bytes

    Serialize commit to raw content bytes (without git object header)

    serialize_tree

    fn serialize_tree(entries : Array[TreeEntry]) -> Bytes

    Serialize tree entries to raw content bytes (without git object header)

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