Expand description
puregit — a pure-Rust implementation of git.
In the spirit of libgit2, but written from scratch in safe Rust and built
on purecrypto for hashing and compcol for zlib, with no foreign code
in the dependency tree. The crate covers the full local object engine, the
packfile format, references, the staging index, and the smart transport
used by git fetch/git push — as both a client and a server, over HTTP
and SSH.
§Layering
The library is deliberately split into a no_std + alloc core and a
std shell:
┌───────────────────────────────────────────────────────────────┐
│ std shell (feature `std`) │
│ vfs::StdFs · Repository · worktree · transport::{http,ssh} │
└───────────────────────────────────────────────────────────────┘
┌───────────────────────────────────────────────────────────────┐
│ no_std + alloc core │
│ oid · hash · object · odb · pack · refs · index · config │
│ protocol (pkt-line, capabilities, fetch/push negotiation) │
└───────────────────────────────────────────────────────────────┘Nothing in the core names std: it transforms byte buffers and is driven by
the caller’s I/O. The vfs trait abstracts the filesystem so the same
repository logic runs over the real disk (vfs::StdFs, feature std), an
in-memory store, or any custom backend.
§Sans-IO transport
Like the sibling puressh/rsurl crates, the wire protocols are sans-IO:
the protocol negotiation drivers consume inbound bytes and produce
outbound frames and events, while the caller owns the socket and the clock.
Two transport frontends drive that one core — transport::http (feature
http, over rsurl) and transport::ssh (feature ssh, over
puressh) — sharing all protocol logic.
§Module map
Core (always built):
error— the crate-wideError/Resulttypes.oid—ObjectId, git’s SHA-1 / SHA-256 content name.hash— compute anObjectIdfrom object bytes.object— the object model: blob,tree,commit,tag; loose-object framing.odb— theObjectDatabasetrait and the loose-object backend.pack— packfile parsing/writing and delta resolution.refs— reference names, the ref store, packed-refs, symrefs.index— the staging index (.git/index).config— the git config (.git/config) parser.protocol— pkt-line framing, capabilities, and the sans-IO fetch/push negotiation state machines.
Shell (feature std):
vfs— the filesystem abstraction and its std backend.repository—Repository, the on-disk repo tying it all together.worktree— working-tree checkout, status, and diff.transport— the HTTP and SSH smart-transport frontends (featureshttp/ssh).server—upload-pack/receive-packrequest handlers (featureserver).
Re-exports§
pub use crate::error::Error;pub use crate::error::Result;pub use crate::object::Object;pub use crate::object::ObjectType;pub use crate::oid::HashAlgo;pub use crate::oid::ObjectId;pub use crate::repository::Repository;
Modules§
- client
- Client porcelain — fetch and clone over a
Transport. - commit_
graph - The commit-graph file (
objects/info/commit-graph). - compress
- zlib (RFC 1950) compression, the on-disk encoding for git data.
- config
- The git configuration format (
.git/config,~/.gitconfig). - diff
- Textual line diffs (unified format).
- error
- The crate-wide error type.
- fsck
- Object-graph integrity checking (
git fsck). - hash
- Computing object ids.
- ignore
- Gitignore matching.
- index
- The staging index (
.git/index). - lfs
- Git LFS (Large File Storage) support.
- merge
- Three-way merge of trees and commits.
- multi_
pack_ index - The multi-pack-index (
objects/pack/multi-pack-index). - object
- The git object model: blobs, trees, commits, and tags.
- object_
filter - Partial-clone object filters (
git clone --filter=…). - odb
- The object database — reading and writing git objects by id.
- oid
- Object identifiers — git’s content-addressed object name.
- pack
- Packfiles — git’s compressed, delta-encoded object container.
- protocol
- The smart transfer protocol: ref advertisement and fetch/push negotiation.
- refs
- References — branches, tags,
HEAD, and the ref store. - remote
- Remotes and refspecs.
- repository
- The on-disk repository — the std-level entry point.
- status
- Working-tree status — comparing
HEAD, the index, and the working tree. - transport
- Transports — moving smart-protocol bytes to and from a remote.
- tree_
builder - Building tree objects from a flat path list (
git write-tree). - vfs
- The filesystem abstraction.
- walk
- Object-graph traversal — reachability and revision walking.
- worktree
- The working tree — materializing trees to disk and reporting status.