1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Porcelain operations — user-facing workflows that assemble structured result
//! models from domain modules (e.g. [`diff`](crate::diff), [`revwalk`](crate::revwalk),
//! `status`, `log`, `merge`, `rebase`, `checkout`, and related commands).
//!
//! # The library/CLI contract
//!
//! Each operation follows the same triple:
//!
//! 1. an **options struct** of plain data (translated by the CLI from clap args
//! + config) — no `clap` types here;
//! 2. an **operation function** that computes and returns a **result model**,
//! reporting progress through a caller-supplied
//! [`ProgressSink`](crate::progress::ProgressSink) and never touching the
//! terminal; and
//! 3. a **result model** of plain `struct`/`enum`s that the CLI renders.
//!
//! The library makes no presentation decisions — colour, pager, tty detection,
//! column layout, and exit codes all live in the `grit` binary. New commands add
//! a submodule here and a matching thin handler in `grit-cli`.
//!
//! - [`add::stage`] — stage worktree changes into the index without a full status pass.
//!
//! # Examples
//!
//! ```
//! use grit_lib::porcelain::status::{self, StatusOptions};
//! use grit_lib::progress::{NeverCancel, NullProgress};
//! use grit_lib::repo::{InitOptions, Repository};
//!
//! # fn main() -> grit_lib::error::Result<()> {
//! let dir = tempfile::tempdir()?;
//! let repo = Repository::init(dir.path(), &InitOptions::default())?;
//! let mut progress = NullProgress;
//! let model = status::status(&repo, &StatusOptions::default(), &mut progress)?;
//! assert!(model.staged.is_empty() && model.unstaged.is_empty());
//! # Ok(())
//! # }
//! ```
//!
//! Library guide: [mod](https://grit-scm.com/docs/library/embedding)
//!
//! ```rust
//! use grit_lib::progress::{NeverCancel, NullProgress};
//! use grit_lib::repo::{InitOptions, Repository};
//! # fn main() -> grit_lib::error::Result<()> {
//! let dir = tempfile::tempdir()?;
//! let repo = Repository::init(dir.path(), &InitOptions::default())?;
//! let _sink = NullProgress;
//! let _cancel = NeverCancel;
//! # Ok(())
//! # }
//! ```
pub
pub
pub
/// Terminal capability probes for porcelain output.