Unpacking Git packfiles
codewords.recurse.com
codewords.recurse.com
I decided to write this up to save others the trouble of having to reverse-engineer it from scratch!
"Since 0xFF (256) is the largest value that can fit into a single byte"
0xFF is 255 not 256
Aside from being more terse and (IMHO) more difficult to read than prose with examples and non-ASCII diagrams, that file doesn't explain the context and motivation for packfiles, and it doesn't cover the parsing and application of deltas at all.
- Cross-compilation (trivial in Go, less so in C)
- A chance to learn about the really dark, thorny corners of Git
And for what it's worth, source control is Git's intended use case, but people do use it for other purposes as well (like managing personal media collections across multiple devices[0]). Git has become a protocol or a platform in addition to a VCS[1].
But there aren't very many FOSS clean-room implementations of Git, at least not this far down the chain (packfiles). One of the best ways to discover hidden implementation issues or oversights in a spec or existing documentation is to try and reimplement it, which has the effect of strengthening the platform itself in the long run.
[0] e.g. https://git-annex.branchable.com/
[1] Bitcoin is a bit of a hot-button topic, but it's similar to bitcoin in this regard: the tool itself is intended for financial transactions, but people have already started to use it for all sorts of unrelated use cases.
I know at least of gogit (https://github.com/speedata/gogit), if only a little, because I've contributed once to it. I don't want to belittle your project, but I'd like to know: what are the differences between gitgo and gogit ?
(I see at least one similarity: the name is extraordinarily unimaginative :)
There are issues. And there is the legendary "pack v4" (current pack versions are 2 or 3) but it still a work in progress.
So in the Go ecosystem it is actually preferred to use pure Go libraries not to loose these benefits.
If the internal documentation include any creative elements which are reflected by the git implementation, then the clean-room would be contaminated.
cat .git/objects/c0/fb67ab3fda7909000da003f4b2ce50a53f43e7 \
| zlib-flate -uncompress; echoMore detail than that would require reading the source code..