Skip to main content

git_xcrypt/util/
exit.rs

1//! Exit codes, in one place.
2//!
3//! Git only distinguishes zero from non-zero, but a person reading a CI log or
4//! scripting around the tool needs to tell "no key" from "bad format" from "this
5//! repository is exposed". The set is frozen in
6//! `context/foundation/zalozenia.md` §Integracja z git.
7
8/// Everything went as asked.
9pub const SUCCESS: u8 = 0;
10
11/// The command line made no sense, or something failed for an unclassified reason.
12pub const USAGE: u8 = 1;
13
14/// Configuration or a state conflict: not a git repository, a clash during
15/// `init`, or a dirty working tree during `lock`.
16///
17/// Since 2026-08-05 it is also what `status` answers when git is not set up to
18/// enforce the declarations — an unregistered filter, a missing catch-all line,
19/// a missing `.git-xcrypt` — and it outranks both [`EXPOSED`] and
20/// [`UNDETERMINED`]. **Configuration comes before data:** without a
21/// configuration that enforces anything the data in the repository is worth
22/// nothing, and `5` was telling repositories that had never run `init` to go and
23/// rotate a secret they had never exposed. No new code was minted for it; this
24/// is the existing meaning, applied.
25pub const CONFIG: u8 = 2;
26
27/// The repository key is missing.
28pub const NO_KEY: u8 = 3;
29
30/// The content is not something this build can read: magic, version, suite, a
31/// reserved flag bit, a foreign key or a failed authentication tag.
32pub const FORMAT: u8 = 4;
33
34/// `status` found an exposure — plaintext where ciphertext was expected.
35///
36/// Distinct from the error codes so a CI gate can tell "the tool broke" from
37/// "the repository has a problem". Since 2026-08-04 it means **only** that:
38/// see [`UNDETERMINED`].
39pub const EXPOSED: u8 = 5;
40
41/// `status` could not answer the question it was asked.
42///
43/// A shallow or partial clone, an index that will not parse, a reference store
44/// that will not enumerate. Nothing was found and nothing is ruled out. (A
45/// missing `.git-xcrypt` was in this list until 2026-08-05 and is now [`CONFIG`]
46/// — it is a configuration that enforces nothing, and it still puts everything
47/// the run then skipped in `undetermined`.)
48///
49/// **Added 2026-08-04, and it widens a table this project had frozen.** The
50/// reason is measured: `5` used to carry both answers, so a perfectly healthy
51/// `git clone --depth 1` — what `actions/checkout` produces unless it is given
52/// `fetch-depth: 0` — failed the gate with the same code as a repository
53/// holding a plaintext secret. A gate that cries wolf on its default setup is a
54/// gate that gets switched off, and the two answers ask different things of
55/// whoever reads them: `5` says fix the repository, `6` says fix the checkout
56/// and ask again. Widening the table costs nothing before the first release —
57/// no consumer exists yet — and after it would cost a breaking change.
58pub const UNDETERMINED: u8 = 6;