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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! What:
//! The values a commit's preparation and the service's landing share about the repository state they work on: the base,
//! the symbolic head, the private index mode, the sequencer conclusion, the ref storage format and a policy-added path.
//! Why:
//! The records the earlier transaction wrote into its registry (preparing, prepared, ref-updated, landing and index-lock
//! records) are gone with the transaction; only the types the service route still passes between its steps remain
//! (`src/policy-engine/commit-transaction-journal-states.ts` is their incumbent).
//!
//! In TS you'd write (pseudocode):
//! ```ts
//! type Base = { kind: 'unborn' } | { kind: 'commit'; oid: string };
//! ```
/// What:
/// The target at invocation,
/// or the expected old target of a landing.
/// Why:
/// An unborn branch has no commit;
/// compare-and-swap then expects the all-zero OID.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type PreparationBase = { kind: 'unborn' } | { kind: 'commit'; oid: string };
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Base {
/// The target names no commit yet.
Unborn,
/// The target names this commit.
Commit(String),
}
/// What:
/// The symbolic `HEAD` target at invocation.
/// Why:
/// A branch switch between preparation and landing fails the commit.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type SymbolicHeadTarget = { kind: 'branch'; ref: string } | { kind: 'detached' };
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SymbolicHead {
/// `HEAD` is symbolic to this ref.
Branch(String),
/// `HEAD` is detached.
Detached,
}
/// What:
/// How the commit selects its content.
/// Why:
/// Explicit-path commits build the tree from the base plus selected paths;
/// index
/// commits use the captured index.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type TransactionMode = 'explicit-path' | 'index';
/// ```
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TransactionMode {
/// `git commit -- <paths>` with commit-only semantics.
ExplicitPath,
/// A commit of the index.
Index,
}
/// What:
/// The commit kind that decides whether a moved target fails instead of replaying.
/// Why:
/// An amend or a conclusion cannot replay onto a moved branch.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type ConclusionKind = 'none' | 'amend' | 'merge' | 'cherry-pick' | 'revert';
/// ```
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Conclusion {
/// An ordinary commit.
None,
/// `--amend`.
Amend,
/// The conclusion of a merge.
Merge,
/// The conclusion of a cherry-pick.
CherryPick,
/// The conclusion of a revert.
Revert,
}
/// What:
/// The ref storage backend of the real repository.
/// Why:
/// The shadow ref snapshot and the conclusion pseudorefs differ by backend.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type RefStorageFormat = 'files' | 'reftable';
/// ```
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RefFormat {
/// Loose refs and `packed-refs`.
Files,
/// The reftable backend.
Reftable,
}
/// What:
/// One policy-added path,
/// or one selected path whose worktree copy receives settled
/// bytes:
/// its mode,
/// the blob before the commit and the blob the commit lands.
/// Why:
/// After landing,
/// the worktree copy is replaced only while it still holds the original.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// type AddedPathRecord = { path: string; gitMode: '100644' | '100755'; originalOid: string; intendedOid: string };
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AddedPath {
/// Repository-relative path, the exact bytes Git reported.
pub path: Vec<u8>,
/// `100644` or `100755`.
pub git_mode: String,
/// Blob at `HEAD`,
/// in the real index and in the worktree before the commit.
pub original_oid: String,
/// Blob the commit lands and the worktree receives.
pub intended_oid: String,
}