Object Types
| Type | Class | Description |
|---|---|---|
| blob | Blob | File content |
| tree | Tree | Directory structure |
| commit | Commit | Repository snapshot |
| tag | Tag | Annotated tag |
Blob
A blob stores file content.Properties
| Property | Type | Description |
|---|---|---|
type | 'blob' | Object type |
content | Buffer | Raw file content |
Methods
| Method | Returns | Description |
|---|---|---|
serialize() | Buffer | Serialize for storage |
toString() | string | Content as UTF-8 string |
Tree
A tree represents a directory, containing references to blobs (files) and other trees (subdirectories).TreeEntry
File Modes
| Mode | Description |
|---|---|
100644 | Regular file |
100755 | Executable file |
120000 | Symbolic link |
40000 | Directory (tree) |
160000 | Submodule (commit) |
Methods
| Method | Returns | Description |
|---|---|---|
serialize() | Buffer | Serialize for storage |
static deserialize(data) | Tree | Parse from buffer |
Commit
A commit represents a snapshot of the repository.Properties
| Property | Type | Description |
|---|---|---|
type | 'commit' | Object type |
tree | string | Tree object hash |
parents | string[] | Parent commit hashes |
author | Author | Who wrote the changes |
committer | Author | Who created the commit |
message | string | Commit message |
Author
Methods
| Method | Returns | Description |
|---|---|---|
serialize() | Buffer | Serialize for storage |
static deserialize(data) | Commit | Parse from buffer |
Tag
An annotated tag with message and tagger info.Properties
| Property | Type | Description |
|---|---|---|
type | 'tag' | Object type |
object | string | Tagged object hash |
objectType | string | Tagged object type |
name | string | Tag name |
tagger | Author | Who created the tag |
message | string | Tag message |
Object Store
TheObjectStore class handles reading and writing objects.
Methods
| Method | Returns | Description |
|---|---|---|
writeObject(obj) | string | Write object, return hash |
readObject(hash) | GitObject | Read and parse object |
writeBlob(content) | string | Write content as blob |
hasObject(hash) | boolean | Check if object exists |
readRawObject(hash) | {type, content} | Read without parsing |
readBlob(hash) | Blob | Read as blob |
readTree(hash) | Tree | Read as tree |
readCommit(hash) | Commit | Read as commit |