75 lines
4.8 KiB
Markdown
75 lines
4.8 KiB
Markdown
# rit — rust git
|
|
|
|
> rit is a standalone Rust library. It is not the engine that serves rithub.dev.
|
|
|
|
A **library-first** Rust implementation of Git's local object/authoring model.
|
|
rit owns its safety-critical loose-object, index, tree, commit, and ref-transaction
|
|
paths while adopting audited open-source crates for expensive commodity layers.
|
|
It is byte-for-byte compatible with real Git where claimed (interop-tested against `git` 2.50).
|
|
|
|
- Object model: loose blobs/trees/commits/tags (read + write), git-exact SHA-1, canonical framing.
|
|
- ODB (zlib, atomic no-clobber writes, SHA-1 verification on read), refs
|
|
(HEAD/loose/packed/symbolic plus atomic compare-and-swap updates).
|
|
- Checksum-verifying Git index v2/v3 reader, atomic `index.lock` mutation,
|
|
recursive ignore-aware `add`, tracked deletion staging, and symlink/path-safe status.
|
|
- Canonical recursive `write-tree`, Git commit objects, and atomic branch
|
|
compare-and-swap updates.
|
|
- Transactional `checkout-tree` materialization with whole-operation collision
|
|
preflight, symlink/path confinement, atomic file replacement, and matching
|
|
index synchronization. `restore` explicitly replaces selected tracked paths
|
|
from the current index without moving `HEAD` or rewriting the index.
|
|
- Strict binary pkt-line framing (including protocol-v2 delimiter/response-end
|
|
controls), receive-pack command/capability parsing, and report-status encoding.
|
|
- Raw and thin Git pack import through gitoxide with checksum/index/delta
|
|
verification, target-ODB base lookup, and a two-phase scratch/quarantine
|
|
boundary. Decoded objects then pass declared-OID, byte/object/graph bounds,
|
|
strict connectivity/fsck, tree/type validation, fast-forward enforcement,
|
|
immutable object publication, and one atomic ref CAS. Expected-old deletion
|
|
is supported for loose refs and refuses packed backing values. Failed receives
|
|
never move a ref; disconnected objects are not published.
|
|
- `rit` CLI: `hash-object`, `cat-file`, `ls-tree`, `log`, `status`, `add`,
|
|
`write-tree`, `commit`, `checkout-tree`, `restore`, plus a stateful
|
|
stdin/stdout `receive-pack` process server for local/SSH adapters and an
|
|
argument-safe `upload-pack` bridge to the installed open-source Git backend.
|
|
- Real-git interop proves our OIDs match `git hash-object`, `git fsck` accepts
|
|
objects we write, and real Git can read/write-tree from an index authored by
|
|
rit. Checkout/restore interop also covers modified/untracked collision refusal
|
|
and symlink-parent escape attempts.
|
|
- Full and genuinely thin packs generated by stock Git can be staged through
|
|
receive quarantine into a bare target and pass `git fsck --strict` after
|
|
promotion. Corrupt/truncated packs and thin packs with missing bases publish
|
|
neither objects nor refs.
|
|
- Stock `git push --receive-pack='<rit> receive-pack'` creates and fast-forwards
|
|
a bare repository through the process server and deletes loose refs. A client
|
|
`--force` does not bypass the server's non-fast-forward policy; deleting a
|
|
packed ref fails without exposing or changing its old value.
|
|
- **Native upload-pack** (`rit::upload_pack`): protocol-v0 ref advertisement,
|
|
want/have negotiation, and rit-generated packfiles. This is what `rit
|
|
serve-http` and the rithub forge serve to stock `git clone`/`git fetch` over
|
|
smart HTTP and SSH. (The older `rit upload-pack` stdin/stdout subcommand is a
|
|
compatibility bridge to an installed Git and is only used for local process
|
|
transports.)
|
|
- **Client transport** (`rit::remote`): `rit clone`, `rit remote add|remove|list`,
|
|
`rit fetch`, `rit pull` (fast-forward only), and `rit push [--force]` against
|
|
any rithub / smart-HTTP URL or a local repository path. Fetched packs pass
|
|
through the same quarantined, fsck'd receive transaction as server pushes.
|
|
HTTP(S) uses the system `curl`; credentials come from the URL or
|
|
`RIT_USERNAME` + `RIT_TOKEN` (a rithub personal access token) and are passed
|
|
to curl on stdin, never on the command line.
|
|
|
|
The collaboration **forge** built on this core lives in [`../rithub`](../rithub) (the GitHub equivalent).
|
|
|
|
Open-source foundations: packed-object reads and received pack/index/delta
|
|
verification use gitoxide; ignore patterns use globset. rit does not pretend
|
|
these costly primitives were written from scratch.
|
|
|
|
The protocol boundary follows Git's official
|
|
[`gitprotocol-common`](https://git-scm.com/docs/gitprotocol-common),
|
|
[`gitprotocol-v2`](https://git-scm.com/docs/gitprotocol-v2), and
|
|
[`gitprotocol-pack`](https://git-scm.com/docs/gitprotocol-pack) specifications.
|
|
Pkt-line, raw/thin pack ingestion, decoded receive safety, the receive-pack
|
|
process contract, native upload-pack, and the clone/fetch/push client are
|
|
Rit-native. Still deferred: protocol v2, side-band progress, shallow clones,
|
|
packed-refs rewrite/deletion, interrupted-ingest recovery, and SHA-256
|
|
repositories.
|