Learn Rust by Building Git — cover
Programming · Book

Learn Rust by Building Git

Content addressing to async HTTP

Build a working Git in Rust, from loose objects to packfiles, the wire protocol and async HTTP. By the end of the first chapter your program makes a repository that the real git accepts, reads, and commits to.

Pages
67 so far
Status
Being written

About

Git is a good subject because almost none of it is magic. It is content addressing, four object types and a protocol — and each of those is something you can build, run against the real thing, and check byte for byte. That check is the point: when your output survives `git fsck`, you have demonstrated that you understand the format rather than that you have read about it.

Rust arrives where the project needs it, not in a chapter of its own. Ownership turns up the first time you are holding a buffer you would rather not copy. Error types turn up the first time a path does not exist and the message has to say which path. Learning a language while building something real means the features show up as answers to problems you already have.

Three subjects run through the book — systems concepts, Rust itself, and the Git file format — and each one is marked as you read, so it is always clear which of the three a passage belongs to. The code is printed in full, and the pages are set wide enough for real Rust rather than making listings fit a narrow measure.

Every format is checked against real Git, pinned to version 2.55.0. What your code writes is compared byte for byte with what git itself produces, so the thing you build interoperates with the real tool rather than with a simplified version of it.

Contents

  1. 01Inside .git, and making one yourself
  2. 02Errors that name the file
  3. 03Finding the repository
  4. 04Your first object