Now every layer runs together. Today you initialise a repository, stage three files including one in a subdirectory, commit, and assert every id, from blobs to the commit, matches real Git exactly.
Drive init, add, and commit end to end and assert every resulting id.
This is the whole stack working as one. init lays down the object database and
HEAD; add hashes each file into a blob and records it in the index (including
src/main.go, which forces a subtree); commit runs write-tree to snapshot the
index into the nested root tree, then commit-tree to wrap it, then advances
main. Every id along the way, the three blobs, the src subtree, the root tree,
and the commit, is exactly what real Git produces from the same inputs.
Seeing f18e98d3... fall out of real file operations, with main pointing at it,
is the moment the pieces stop being separate lessons and become a version control
system. One more commit will grow the history, and then the finale ties it all off
with a full session you can cross-check against git itself.
r.Init(); r.SetHEAD("refs/heads/main")r.Add(ix, "hello.txt"); r.Add(ix, "README.md"); r.Add(ix, "src/main.go")id, _ := r.Commit(ix, ident, "Initial commit\n")// id == "f18e98d326b190d096879422d56d4ac5cf572db1"// ReadRef("refs/heads/main") == id; Resolve("HEAD") == id