Rust · content-addressed · git-shaped

See the whole
object model.

Timelace is a tiny content-addressed version control system in Rust, small enough to read in one sitting. Blobs, trees, and commits, each one addressed by the SHA-256 hash of its own bytes. Here is the real object model, running in your browser.

View on GitHub Read the docs

Working files

Add a file, then add another with identical content and compare blob ids below.

NameContentBlob id

Commit

A commit hashes a tree of the working files above, plus the current HEAD as its parent.

HEAD

(no commits yet)

Commit log

Walked from HEAD by following each commit's parent link. Check out an earlier commit to restore its snapshot into the working files above.

Object store

Every blob, tree, and commit ever created in this session, addressed only by the hash of its own bytes. Identical blob content always lands on the same id, so it is stored once.

real SHA-256 hashing, in your browser, nothing touches a network

Three objects, one idea

Every object's name is a hash of its own content. That single rule is what makes content addressing work, and it is the entire idea Timelace is built to make visible.

Blob

Raw file content

The bytes of one file, nothing else. Two files with identical content share one blob, automatically.

Tree

A directory snapshot

Names mapped to blob or tree ids, sorted before hashing so identical contents always produce the same id.

Commit

A point in history

A tree id, an optional parent, a message, and a timestamp. Follow parent links to walk the whole history.

A five-minute walkthrough

The full workflow, initialize a repository, stage a file, commit it, and check it back out.

$ timelace init
initialized empty timelace repository in ./.timelace

$ echo "hello" > notes.txt
$ timelace add notes.txt
$ timelace commit -m "first commit"
committed 4b7b6338afbc1a9b9b0fbaae5866a8483f70ec56f0d0b2630e4955788624edc9

$ timelace log
commit 4b7b6338afbc1a9b9b0fbaae5866a8483f70ec56f0d0b2630e4955788624edc9
timestamp 1787349600

    first commit

$ timelace checkout 4b7b6338afbc1a9b9b0fbaae5866a8483f70ec56f0d0b2630e4955788624edc9

On-disk layout

Objects live in a two-level directory split by the first two characters of their id, the same trick git uses to keep any one directory small.

.timelace/ objects/<id[0..2]>/<id[2..]> one file per object HEAD latest commit id index paths staged for the next commit

Why use it

Not a git replacement. A way to actually see how content-addressed version control works, with no packfiles, no plumbing and porcelain split, no thousands of files standing between you and the idea. Read src/objects.rs and you have read the whole model.

Source, tests, and design notes are public on GitHub. The object model, the on-disk layout, and the commit and checkout algorithms are documented in DESIGN.md.

github.com/pavanchow/timelace