How ojitoss/git-2005-small-fixed works
Purpose and Build Surface
This is a compiler-modernized snapshot of Git’s April 2005 prototype: a small set of standalone C executables implementing content-addressed storage, an index, trees, and commits. Makefile builds the command binaries; each *.c command has its own main entry point.
Paths: Makefile, README, README.md
Repository Initialization and Storage Layout
init-db establishes the repository-local .dircache database, including .dircache/index and a fan-out .dircache/objects/00..ff loose-object store. Object IDs address compressed objects by SHA-1-derived path split, separating command logic from persistent storage layout.
Paths: init-db.c, cache.h
Shared Object and Index Contract
cache.h is the central cross-command contract: it defines index/cache entry structures, shared globals, SHA-1/object-writing interfaces, and repository path assumptions. The index is the staging boundary between working-tree files and immutable object creation.
Paths: cache.h, read-cache.c
Working Tree to Blob / Index Pipeline
update-cache accepts one path, reads its working-tree content, creates a blob object, and records file metadata plus the blob ID in .dircache/index. It relies on index loading/writing and object persistence rather than a long-running daemon or library process.
Paths: update-cache.c, read-cache.c, cache.h
Index Inspection and Change Detection
show-diff reads staged cache entries and compares them with the current filesystem state to report whether indexed files remain valid. This is an early status/diff-like control point; it does not represent a full patch-generation subsystem.
Paths: show-diff.c, read-cache.c, cache.h
Tree Construction and Traversal
write-tree converts index entries into a root tree object whose records carry mode, filename, and blob SHA-1; it prints the resulting tree ID for downstream commit creation. read-tree resolves a supplied tree ID and renders its entries. The model is root-tree oriented, with no evidence in this file set of recursive directory/tree construction.
Paths: write-tree.c, read-tree.c, read-cache.c
Commit and Object Access Boundary
commit-tree takes a tree ID, optional parent IDs, author/committer environment data, and stdin message to persist a commit object. Parent linkage is caller-managed. cat-file is the raw object retrieval path, resolving an object ID from loose storage and materializing its content into a temporary file rather than streaming it directly.
Paths: commit-tree.c, cat-file.c, cache.h
Runtime and External Dependencies
The system is native C, invoked as separate CLI processes in the current working directory. Its material infrastructure is the local filesystem (.dircache, working files, temporary files); there is no network transport, remote service, server, or database. The README identifies GCC/Make compatibility work and zlib-compressed loose objects.
Paths: Makefile, README.md, README
Main entry points: read-cache.c Index I/O · Makefile Makefile · update-cache.c update-cache · write-tree.c write-tree
Components 15
Build Surface
- Makefile · Builds the standalone C command binaries.
Makefile - README docs · Documents GCC/Make compatibility and zlib loose objects.
README.md
Standalone CLI Commands
- Shared cache contract · Defines index entries, object interfaces, and repository paths.
cache.h - Index I/O · Loads and writes the staging index.
read-cache.c - init-db · Creates the repository-local storage layout.
init-db.c - update-cache · Stages one working-tree file as a blob and index entry.
update-cache.c - show-diff · Checks staged entries against current filesystem state.
show-diff.c - write-tree · Converts index entries into a root tree object.
write-tree.c - read-tree · Renders entries from a supplied tree ID.
read-tree.c - commit-tree · Persists a commit from a tree, parents, environment, and stdin message.
commit-tree.c - cat-file · Retrieves a loose object into a temporary file.
cat-file.c
Repository Data
- Working files
- .dircache/index · Mutable boundary between files and immutable objects.
- .dircache/objects · SHA-1 fan-out paths hold zlib-compressed objects.
- Temporary file · Materialized output of raw object retrieval.
Connections 20
- Makefile → init-db: builds
- Makefile → update-cache: builds
- Makefile → write-tree: builds
- Makefile → commit-tree: builds
- Shared cache contract → Index I/O: defines contract
- init-db → .dircache/index: creates
- init-db → .dircache/objects: creates fan-out store
- update-cache → Working files: reads file
- update-cache → Index I/O: uses
- update-cache → .dircache/objects: writes blob
- Index I/O → .dircache/index: reads and writes
- show-diff → Index I/O: loads staged entries
- show-diff → Working files: compares state
- write-tree → Index I/O: reads entries
- write-tree → .dircache/objects: writes root tree
- read-tree → .dircache/objects: reads tree
- commit-tree → .dircache/objects: writes commit
- cat-file → .dircache/objects: resolves object
- cat-file → Temporary file: materializes content
- write-tree → commit-tree: prints tree ID