cgit reimplements git's core plumbing commands in C: init, hash-object, cat-file, ls-tree, write-tree, and commit-tree. It stores and retrieves objects in git's binary format, computes SHA-1 hashes with OpenSSL, and compresses objects with zlib. The object files it produces are byte-identical to those real git writes.
cgit has three layers. main.c owns the dispatch table: it parses argv, matches the command name in a static array of structs, and calls the matching handler. The command layer (commands/) validates arguments, calls into core, and formats output. The core layer (core/) implements object I/O, hashing, compression, tree parsing, and path utilities. Dependencies point only downward; core has no knowledge of which commands exist or which flags they parse.
cmake -B build && cmake --build buildRequires CMake 4.2 or later, OpenSSL, and zlib. On macOS, OpenSSL is detected automatically via Homebrew.
cgit init
cgit hash-object -w <file>
cgit cat-file -p <hash>
cgit cat-file -t <hash>
cgit cat-file -s <hash>
cgit cat-file -e <hash>
cgit ls-tree [--name-only] <hash>
cgit write-tree
cgit commit-tree <tree-hash> [-p <parent-hash>] -m <message>Objects written by cgit can be read with real git and vice versa: git cat-file -p <hash> works on any object cgit produced.
All decision records live in docs/adr/. Each file documents the context, the options considered, and the consequences for the codebase.
init, hash-object, cat-file, ls-tree, write-tree, and commit-tree are implemented and produce output byte-identical to real git. Author and committer identity in commit-tree are compile-time constants; there is no config file parsing. Objects are addressed by full 40-character SHA-1 hex; there is no ref resolution, no HEAD dereferencing, and no branch tracking. The staging area is not implemented: write-tree reads the working directory directly. Only loose objects are supported; pack files are not.