Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
grit-lib
Core library for Grit, a from-scratch reimplementation of Git in Rust.
grit-lib provides the engine for opening repositories, reading and writing
objects and refs, diffing, merging, fetching, pushing, and the other workflows
the grit CLI exposes. It is designed to be linkable: embed it in tools,
agents, or services without shelling out to the git binary.
Crate-level documentation (architecture, features, and a compiling example) lives
in the rustdoc for grit_lib.
Design philosophy
- Correctness first. Behavior is validated with Rust tests cross-checked
against the system
gitbinary (on-disk formats and wire protocols). - Library-first. Typed errors, no printing from the library, no global state, and explicit inputs for time and environment where it matters.
- Performance. Hot paths are benchmarked against stock
git; see the project benchmarks docs on grit-scm.com. - Granular errors. Public APIs return
thiserrorenums so callers can match on failure modes.
Dependencies
Direct dependencies are declared in Cargo.toml (workspace-pinned
where noted). Highlights:
| Area | Crates |
|---|---|
| Hashing | sha1, sha2, crc32fast |
| Compression | flate2 |
| Diff / merge | similar, merge3, imara-diff |
| Text / paths | regex, hex, unicode-width, icu_normalizer, shell-words |
| Time / TZ | time, tzdb, tz |
| I/O helpers | tempfile, memmap2, filetime |
| Errors | thiserror |
Optional HTTP (http-ureq feature) |
ureq, base64 |
| Unix-only | nix, rustix |
| Windows-only | windows-sys |
The workspace default denies unsafe, but this crate sets unsafe_code = allow
in Cargo.toml because several areas use small, reviewed blocks:
Git-compatible date/time (git_date, including libc FFI), memory-mapped pack
files (pack_map), the parallel worker pool, validated UTF-8 object paths
(objects), terminal and color detection, index extensions, and (on Windows)
Credential Manager access in credentials.
Quick start
Add the dependency:
[]
= "0.1"
For smart-HTTP remotes:
= { = "0.1", = ["http-ureq"] }
Open a repository and read HEAD
use ;
use resolve_head;
use RefStorageFormat;
let dir = tempdir?;
let repo = init_repository?;
let head = resolve_head?;
let _again = open?;
# Ok::
Walk the commit graph
use ;
let mut opts = default;
opts.output = OidOnly;
let result = rev_list?;
for oid in &result.oids
Diff two trees
use ;
let entries: = diff_trees?;
for e in &entries
Module map
Prefer the rustdoc domain views (object_store,
references, worktree_index, revision, diffing, merging, configuration)
for navigation. Commonly used flat modules include repo, odb, objects, pack,
index, refs, remote, fetch, push, diff, rev_parse, rev_list,
config, bundle, and error.
License
MIT