Elffuss BraidHub

utopia-ia/elffuss-braid public

main · 2.3 KiBRawPermalink
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 UtopiaIA
3
4//! The git bridge of elffuss-braid: git history in, git history out, bit for
5//! bit.
6//!
7//! - [`import`] reads a git repository and stores every blob, tree, commit and
8//! annotated tag reachable from its branches and tags as braid objects,
9//! recording each mapping in a [`GitMap`]. Every commit is exported again
10//! as it is imported, and the import stops unless its id comes back the
11//! same.
12//! - The [`Exporter`] turns braid objects back into git objects: imported ones
13//! byte for byte, from the raw bytes they keep, and new ones
14//! deterministically. [`write_to_repo`] writes them into a git repository
15//! and points refs at them; [`write_to_repo_recording`] also records in the
16//! [`GitMap`] the objects it generated for changesets made in braid, so
17//! that importing them back gives the same changesets.
18//! - [`verify_round_trip`] imports a repository, exports it into a fresh one,
19//! and checks that every id matches.
20//!
21//! Git access goes through [gitoxide](https://github.com/GitoxideLabs/gitoxide)
22//! (MIT or Apache-2.0). Braid contains no code from git, which is GPLv2: the
23//! few git formats parsed here are written from their documentation.
24//!
25//! Only SHA-1 repositories are supported for now, and every git id is
26//! computed with SHA-1 collision detection.
27
28#![forbid(unsafe_code)]
29
30mod diff;
31mod error;
32mod export;
33mod fetch;
34mod import;
35mod map;
36mod oid;
37mod raw;
38mod repo;
39mod roundtrip;
40
41pub use error::{BoxError, Error};
42pub use export::{
43 Exporter, RefTarget, RefUpdate, WriteReport, export_blob, export_commit, export_object,
44 export_tree, write_to_repo, write_to_repo_recording,
45};
46pub use import::{ImportOptions, ImportReport, ImportedRef, import, import_parallel};
47pub use map::{GitMap, MapCounts, Pairings, TagEntry};
48pub use oid::{GitKind, GitOid, ParseGitOidError};
49pub use repo::is_branch_name;
50pub use roundtrip::{RoundTripReport, verify_round_trip, verify_round_trip_with};
51
52/// The parsers of raw git objects, for the fuzz targets in `fuzz/`. Not part
53/// of the stable API.
54#[cfg(feature = "fuzzing")]
55#[doc(hidden)]
56pub mod fuzzing {
57 pub use crate::raw::{
58 CommitFields, EntryType, RawEntry, encode_commit, parse_commit, parse_signature, parse_tag,
59 parse_tree,
60 };
61}