sley_submodule/lib.rs
1//! `sley-submodule` — shared submodule engine for sley.
2//!
3//! Centralizes two pieces of submodule logic that git keeps in
4//! `submodule-config.c` and `submodule.c`, and that sley previously scattered
5//! across the 1850-line `submodule` CLI command and ~14 ad-hoc `.gitmodules`
6//! walks:
7//!
8//! - [`config`] — typed `.gitmodules` parsing (`submodule-config.c`): a
9//! [`config::SubmoduleConfigSet`] of typed [`config::Submodule`] entries, plus
10//! the `check_submodule_name` / `check_submodule_url` security checks and the
11//! recurse-mode / update-strategy enums.
12//! - [`relative_url`] — the `.gitmodules`-url → concrete-url resolution
13//! (`remote.c::relative_url` + `submodule--helper.c::resolve_relative_url`).
14//! `submodule init` / `sync` / `add` all route their relative-url math through
15//! this one primitive so every git URL form (ssh, scp-style, file://, helper,
16//! relative local path) resolves byte-for-byte the way upstream does.
17//! - [`update_strategy`] — the `submodule update` mode resolver
18//! (`submodule--helper.c::determine_submodule_update_strategy`): picks ONE of
19//! checkout/merge/rebase/command/none from the CLI-flag → `.git/config` →
20//! `.gitmodules` → default-checkout precedence, with the `just_cloned`
21//! downgrade. `submodule update` routes every mode through this one resolver.
22//! - [`move_head`] — the move-head / verify-clean primitives
23//! (`submodule.c::submodule_move_head` dry-run path + the `unpack-trees.c`
24//! wrappers `check_submodule_move_head` / `verify_clean_submodule`). These are
25//! the hooks the tree-switch (unpack-trees) engine calls to decide whether a
26//! HEAD move would lose submodule work.
27//!
28//! The two halves are paired on purpose: a tree-switch needs the typed config
29//! (to know *which* paths are submodules and their bindings) AND the move-head
30//! check (to know whether moving each one is safe).
31
32pub mod config;
33pub mod move_head;
34pub mod relative_url;
35pub mod update_strategy;
36
37pub use config::{
38 ParseWarning, RecurseMode, Submodule, SubmoduleConfigSet, UpdateStrategy, UpdateType,
39 check_submodule_name, check_submodule_url, looks_like_command_line_option, parse_fetch_recurse,
40 parse_update_strategy, parse_update_type, update_type_to_string,
41};
42pub use move_head::{
43 MoveHeadContext, MoveHeadFlags, MoveHeadVerdict, check_move_head, check_submodule_move_head,
44 verify_clean_submodule,
45};
46pub use relative_url::{relative_url, resolve_relative_url};
47pub use update_strategy::determine_update_strategy;