Skip to main content

grit_lib/
lib.rs

1//! Gust library — core Git-compatible engine.
2//!
3//! # Architecture
4//!
5//! All Git-compatible logic lives here; the `grit` binary is a thin CLI shim
6//! that parses arguments and delegates to types exposed from this crate.
7//!
8//! ## Where to start
9//!
10//! - [`Repository`](repo::Repository) is the central handle — open or discover
11//!   one, then reach the object store, index, refs, and config through it.
12//! - [`prelude`] re-exports the handful of types most call sites need.
13//! - [`porcelain`] holds user-facing operations that return structured result
14//!   *models* (the CLI renders them); [`plumbing`] holds the low-level,
15//!   machine-stable building blocks. The flat module list below remains the
16//!   low-level escape hatch and keeps every existing path valid.
17//! - Browse the engine by subsystem via the domain views: [`object_store`],
18//!   [`references`], [`worktree_index`], [`revision`], [`diffing`], [`merging`],
19//!   and [`configuration`].
20//! - [`progress`] defines how long-running operations report progress and
21//!   observe cancellation without touching the terminal.
22//!
23//! ## Core modules
24//!
25//! - [`error`] — shared error types using `thiserror`
26//! - [`objects`] — object ID, object kinds, and in-memory representations
27//! - [`odb`] — loose object store (read/write zlib-compressed objects)
28//! - [`repo`] — repository discovery and handle
29//! - [`index`] — Git index (staging area) read/write
30//! - [`ignore`] — ignore/exclude pattern matching for check-ignore
31//! - [`refs`] — reference storage (files backend)
32
33// --- Curated public API (additive; the flat `pub mod` list below is unchanged
34// so every existing `grit_lib::<module>::…` path keeps resolving) ---
35pub mod plumbing;
36pub mod porcelain;
37pub mod progress;
38
39/// The types most callers need, re-exported for `use grit_lib::prelude::*;`.
40pub mod prelude {
41    pub use crate::config::ConfigSet;
42    pub use crate::error::{Error, Result};
43    pub use crate::index::Index;
44    pub use crate::objects::{Object, ObjectId, ObjectKind};
45    pub use crate::odb::Odb;
46    pub use crate::repo::Repository;
47}
48
49// Domain-grouped views of the engine. Each is a curated table of contents over
50// the flat module list below — pure module re-exports, so `object_store::objects`
51// and the original `objects` path both resolve. A module appears in at most one
52// domain; cross-cutting and operation-level modules stay in the flat list.
53
54/// Object storage: ids/kinds, the object database, packs, multi-pack index, deltas.
55pub mod object_store {
56    pub use crate::{
57        delta_encode, delta_islands, midx, objects, odb, pack, pack_geometry, pack_name_hash,
58        pack_rev, promisor, promisor_remote, prune_packed, unpack_objects,
59    };
60}
61
62/// References: the refs backends, reflog, refspecs, name validation, namespaces.
63pub mod references {
64    pub use crate::{
65        branch_ref_format, branch_tracking, check_ref_format, hide_refs, ref_exclusions,
66        ref_namespace, reflog, refs, refspec, reftable,
67    };
68}
69
70/// Index and working tree: the index, sparse checkout, attributes, ignore, CRLF.
71pub mod worktree_index {
72    pub use crate::{
73        attributes, crlf, ignore, index, index_name_hash_lazy, path_walk, resolve_undo,
74        sparse_checkout, split_index, untracked_cache, worktree, worktree_cwd, worktree_ref,
75        write_tree,
76    };
77}
78
79/// Revision machinery: rev-parse, rev-list, name-rev, commit-graph.
80pub mod revision {
81    pub use crate::{commit_graph_file, commit_graph_write, name_rev, rev_list, rev_parse};
82}
83
84/// Diffing: tree/content diff, rename detection, diffstat, line-log, pickaxe bloom.
85pub mod diffing {
86    pub use crate::{
87        bloom, combined_diff_patch, combined_tree_diff, diff, diff_indent_heuristic, diff_moved,
88        diffstat, difftool, line_log, patch_ids, userdiff,
89    };
90}
91
92/// Merging: merge-base, tree/file merges, rerere, merge-message formatting.
93pub mod merging {
94    pub use crate::{
95        fmt_merge_msg, merge_base, merge_diff, merge_file, merge_tree_trivial, merge_trees,
96        mergetool_vimdiff, rerere,
97    };
98}
99
100/// Configuration and identity: config cascade, .gitmodules, author/committer idents.
101pub mod configuration {
102    pub use crate::{
103        config, dotfile, gitmodules, ident, ident_config, ident_resolve, precompose_config,
104        url_rewrite,
105    };
106}
107
108pub mod am;
109pub mod apply;
110pub mod attributes;
111pub mod blame;
112pub mod bloom;
113pub mod branch_ref_format;
114pub mod branch_tracking;
115pub mod check_ref_format;
116pub mod combined_diff_patch;
117pub mod combined_tree_diff;
118pub mod commit;
119pub mod commit_encoding;
120pub mod commit_graph_file;
121pub mod commit_graph_write;
122pub mod commit_pretty;
123pub mod commit_trailers;
124pub mod config;
125pub mod connectivity;
126pub mod crlf;
127pub mod delta_encode;
128pub mod delta_islands;
129pub mod diff;
130pub mod diff_indent_heuristic;
131pub mod diff_moved;
132pub mod diffstat;
133pub mod difftool;
134pub mod dotfile;
135pub mod error;
136mod ewah_bitmap;
137pub mod fast_export;
138pub mod fast_import;
139pub mod fetch_head;
140pub mod fetch_negotiator;
141pub mod fetch_submodules;
142pub mod filter_process;
143pub mod fmt_merge_msg;
144pub mod fsck_standalone;
145pub mod git_binary_base85;
146pub mod git_column;
147pub mod git_date;
148pub mod git_path;
149pub mod gitmodules;
150pub mod hide_refs;
151pub mod hooks;
152pub mod ident;
153pub mod ident_config;
154pub mod ident_resolve;
155pub mod ignore;
156pub mod index;
157pub mod index_name_hash_lazy;
158pub mod interpret_trailers;
159pub mod line_log;
160pub mod ls_remote;
161pub mod mailinfo;
162pub mod mailmap;
163pub mod merge_base;
164pub mod merge_diff;
165pub mod merge_file;
166pub mod merge_tree_trivial;
167pub mod merge_trees;
168pub mod mergetool_vimdiff;
169pub mod midx;
170pub mod name_rev;
171pub mod notes;
172pub mod objects;
173pub mod odb;
174pub mod pack;
175pub mod pack_geometry;
176pub mod pack_name_hash;
177pub mod pack_rev;
178#[cfg(feature = "test-tools")]
179pub mod parse_options_test_tool;
180pub mod patch_ids;
181pub mod path_walk;
182pub mod pathspec;
183pub mod pkt_line;
184pub mod precompose_config;
185pub mod promisor;
186pub mod promisor_remote;
187pub mod protocol;
188pub mod protocol_v2;
189pub mod prune_packed;
190pub mod push_cert;
191pub mod push_report;
192pub mod push_submodules;
193pub mod quote_path;
194pub mod receive_pack;
195pub mod ref_exclusions;
196pub mod ref_namespace;
197pub mod reflog;
198pub mod refs;
199pub mod refs_fsck;
200pub mod refspec;
201pub mod reftable;
202pub mod repo;
203pub mod rerere;
204pub mod resolve_undo;
205pub mod rev_list;
206pub mod rev_parse;
207pub mod shallow;
208pub mod shared_repo;
209pub mod signing;
210#[cfg(unix)]
211pub mod simple_ipc;
212pub mod sparse_checkout;
213pub mod split_index;
214pub mod unicode_normalization;
215pub mod untracked_cache;
216pub mod upload_filter;
217#[cfg(not(unix))]
218pub mod simple_ipc {
219    /// Whether simple IPC is supported on this platform.
220    #[must_use]
221    pub fn supports_simple_ipc() -> bool {
222        false
223    }
224
225    /// Stub for non-Unix targets.
226    pub fn run_simple_ipc_tool(_args: &[String]) -> i32 {
227        eprintln!("simple IPC not available on this platform");
228        1
229    }
230}
231pub mod state;
232pub mod stripspace;
233pub mod submodule_active;
234pub mod submodule_config;
235pub mod submodule_config_cache;
236pub mod submodule_gitdir;
237pub mod tab_expand;
238#[cfg(feature = "test-tools")]
239pub mod test_tool_progress;
240pub mod textconv_cache;
241pub mod transport_path;
242pub mod tree_path_follow;
243#[cfg(unix)]
244pub mod unix_process;
245pub mod unpack_objects;
246pub mod url_rewrite;
247pub mod userdiff;
248pub mod whitespace_rule;
249pub mod wildmatch;
250pub mod worktree;
251pub mod worktree_cwd;
252pub mod worktree_ref;
253pub mod write_tree;
254pub mod ws;