Expand description
Worktree → tree-object builder.
Walks a directory, applies .mkitignore, hashes each file as a
Blob, recurses on subdirectories, validates
symlink targets against path-traversal, and writes a single root
Tree into the supplied ObjectStore.
Notes:
- Files at or below
CHUNK_THRESHOLDare stored as a singleBlob. Files above the threshold are chunked withcrate::chunker::FastCdc::v1; each chunk is stored as aBloband the file is represented by aChunkedBlobmanifest whose hash is what lands in the parent tree. - We never follow symlinks while walking. Linux/macOS
read_linkreports the target verbatim and we hash it as a blob.
Enums§
- Worktree
Error - Errors returned by this module.
Constants§
- CHUNK_
THRESHOLD - Files larger than this go through the chunker (1 MiB).
- MAX_
FILE_ BYTES - Hard cap on a single file (1 GiB).
Functions§
- build_
tree - Build a tree object for
dirand its subdirectories. Honours the.gitignore+.mkitignoreignore files loaded fromdir. - build_
tree_ filtered - Like
build_tree, but the caller supplies the authoritative tracked set (index). Callers that seed their index fromHEADwhen no index file exists yet (status, restore safety) MUST pass it here so a tracked file that matches an ignore rule is not dropped right after a checkout.Nonefalls back to the on-disk<dir>/.mkit/index(empty if absent). - build_
tree_ from_ index - Build a tree object from an
Index(the staging area). - hash_
file - Read a file from disk, hash it, store it, and return the content-address of the resulting object.
- read_
blob - Reassemble the full byte content of a
BloborChunkedBlobobject addressed byhash. - read_
regular_ file_ bounded - Read a regular file without following the final path component on
Unix, enforcing
MAX_FILE_BYTESagainst both the opened handle’s metadata and the actual bytes read. - store_
file_ object - Store a regular file’s bytes as the canonical object and return its content-address.
- validate_
symlink_ target - Validate a symlink target: must be relative and contain no
..segments.
Type Aliases§
- Worktree
Result - Result alias used throughout this module.