Skip to main content

grit_lib/objects/
mod.rs

1//! Git objects: ids, kinds, in-memory representations, and the object database stack.
2//!
3//! Canonical layout groups loose/packed storage, hashing, deltas, and reachability
4//! bitmaps under this module.
5//!
6//! Library guide: [mod](https://grit-scm.com/docs/library/objects)
7//!
8//! ```rust
9//! use grit_lib::repo::{InitOptions, Repository};
10//! # fn main() -> grit_lib::error::Result<()> {
11//! let dir = tempfile::tempdir()?;
12//! let (_repo, _) = Repository::init(dir.path(), &InitOptions::default())?;
13//! let _odb = _repo.odb();
14//!
15//! # Ok(())
16//! # }
17//! ```
18
19mod commit_ref;
20mod core;
21mod extra_headers;
22pub(crate) mod handle;
23mod oid_hashtable;
24mod write;
25
26pub(crate) use commit_ref::commit_author_and_message_lenient;
27pub use commit_ref::CommitRef;
28pub use core::*;
29pub use extra_headers::{
30    extra_header_values, insert_header_before_signature, iter_extra_headers, next_header_block,
31    remove_header_lines, set_extra_header, ExtraHeaderIter,
32};
33pub use handle::Objects;
34pub use oid_hashtable::{
35    empty_object_id_hash_set, empty_oid_byte_filter_map, empty_oid_set, oid_hash_map,
36    oid_hash_map_from, oid_hash_set, oid_hash_set_from, OidBuildHasher, OidHashMap, OidHashSet,
37    OidHasher,
38};
39pub(crate) use oid_hashtable::{oid_hash_map_with_capacity, oid_hash_set_with_capacity};
40pub use write::{NewCommit, TreeEntryError, WriteTreeOptions};
41
42pub mod odb {
43    //! Object database backends and loose/packed storage.
44    pub use crate::odb::builder::OdbBuilder;
45    pub use crate::odb::store;
46    pub use crate::odb::store::{ObjectStore, WritableObjectStore};
47    pub use crate::odb::{
48        ObjectStream, Odb, WriteOptions, BULK_NEW_LOOSE_WRITE, BULK_TRACKED_RESTAGE_LOOSE_WRITE,
49    };
50}
51
52pub mod pack {
53    //! Pack files, indexes, and packfile I/O.
54    pub use crate::pack::{
55        clear_pack_cache, hash_object_bytes, oid_bytes_to_hex, read_alternates_recursive,
56        read_idx_object_ids, read_local_pack_indexes, read_object_from_pack_at_offset,
57        read_object_from_packs, read_pack_index, read_pack_index_cached,
58        read_packed_delta_dependency, skip_one_pack_object, write_v2_pack_index,
59        write_v2_pack_index_from_trailer, PackIndex, PackIndexEntryRef, SingleLocalPackReader,
60        DEFAULT_PACK_DEPTH,
61    };
62    pub use crate::pack_reuse_root::*;
63}
64
65pub(crate) mod pack_reuse {
66    pub use crate::pack_reuse_root::*;
67}
68
69#[allow(unused_imports)]
70pub(crate) mod pack_write {
71    pub use crate::pack_write_root::*;
72}
73
74pub mod midx {
75    //! Multi-pack-index (MIDX) read and write.
76    pub use crate::midx::{
77        clear_pack_midx_state, midx_lookup_pack_and_offset, read_midx_btmp_ranges,
78        read_midx_objects, try_read_info_via_midx, try_read_object_via_midx,
79        write_multi_pack_index, MidxBitmapWriteOutcome, WriteMultiPackIndexOptions,
80    };
81}
82
83pub mod hash {
84    //! Object-id hashing, file checksums, and hash algorithm selection.
85    pub use crate::hash::{
86        backend, hash_object, hash_objects_parallel, par_hash_with, parallel_hash_worthwhile,
87        try_par_hash_forced, try_par_hash_with, verify_trailer, Backend, ChecksumHasher,
88        HashingWriter, ObjectHasher, ParallelHashError, Parallelism, PAR_HASH_MIN_ITEMS,
89        PAR_HASH_MIN_TOTAL_BYTES,
90    };
91}
92
93pub mod commit_graph {
94    //! Commit-graph files for reachability and generation numbers.
95    pub use crate::commit_graph_file::BloomWalkStatsHandle;
96}
97
98pub mod bitmap {
99    //! Pack and commit reachability bitmaps.
100    pub use crate::bitmap_walk::{
101        BitmapWalkError, BitmapWalkUnsupported, ReachabilityQuery, ReachableSet,
102    };
103    pub use crate::pack_bitmap::{
104        BitmapError, BitmapIndex, BitmapIndexCache, CommitReachabilityBitmap, MidxBitmapWriter,
105        PackBitmapWriteError, PackBitmapWriteOptions, PackBitmapWriter, TypeBitmap,
106    };
107}
108
109pub mod delta_encode {
110    //! Delta compression encoding for pack streams.
111    pub use crate::delta_encode::{encode_delta, encode_lcp_delta, DeltaIndex};
112}
113
114pub(crate) mod delta_islands {}
115
116pub mod index_pack {
117    //! Index-pack and thin-pack handling.
118    pub use crate::index_pack::{
119        build_pack_index_records, ingest_received_pack, ingest_received_pack_path,
120        install_pack_bytes, install_pack_path, IngestPackOptions, IngestedPack, ObjectKindCounts,
121    };
122}
123
124pub(crate) mod pack_name_hash {}
125
126pub(crate) mod pack_rev {}
127
128pub mod pack_store {
129    //! Pack-backed object store implementation.
130    pub use crate::pack_store::PackStore;
131}
132
133pub mod unpack_objects {
134    //! Unpack loose objects from pack streams.
135    pub use crate::unpack_objects::{
136        apply_delta, apply_delta_into, ingest_pack_into, pack_index_records, UnpackOptions,
137    };
138}
139
140pub(crate) mod prune_packed {}
141
142pub mod promisor {
143    //! promisor API (re-exported at this path).
144    pub use crate::promisor::{repo_treats_promisor_packs, PROMISOR_MISSING_FILE};
145    pub use crate::promisor_fetch::{
146        DefaultPromisorFetcher, PromisorFetcher, PROMISOR_LAZY_FETCH_CONFIG,
147    };
148}
149
150pub mod promisor_remote {
151    //! Promisor remote configuration for partial clones.
152    pub use crate::promisor_remote::{
153        configured_promisor_remotes, lazy_fetch_order, PromisorAcceptPolicy, PromisorAdvertisement,
154        PromisorConfigWarning, PromisorDecision, PromisorField, PromisorHandshake,
155        PromisorHandshakeOptions, PromisorRejection, PromisorReplyError,
156    };
157}
158
159pub mod pack_objects {
160    //! Pack-objects negotiation and encoding.
161    pub use crate::pack_objects::{
162        build_pack, build_pack_from_send_list, write_pack_for_push, PackBuildOptions, PackObjects,
163        PackObjectsOptions, PackStats, UploadPackStream, SERVE_WINDOW_MEMORY,
164    };
165}
166
167pub mod pack_object_select {
168    //! Object selection heuristics for packing.
169    pub use crate::pack_object_select::{
170        enumerate_pack_objects, HaveBoundary, PackEnumerateOptions,
171    };
172}
173
174#[allow(unused_imports)]
175pub(crate) mod pack_receive {
176    pub use crate::pack_receive::*;
177}
178
179pub(crate) mod pack_stream_scan {
180    pub use crate::pack_stream_scan::*;
181}