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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! What:
//! The complete option table of `git branch` in Git 2.56.0.
//! Why:
//! Whether `git branch <name>` creates a branch depends on which action options were
//! given,
//! and whether a token is a name depends on each option's arity.
//! Rows follow
//! `options[]` in `cmd_branch` (builtin/branch.c:992-1050) in source order.
//!
//! In TS you'd write (pseudocode):
//! ```ts
//! // export const BRANCH_TABLE: readonly OptionSpec[] = [ ... ];
//! ```
/// What:
/// Bring the row type,
/// its builder and the arity names into this file.
/// `UNREAD` is the
/// identifier of rows no branch fact reads.
/// Why:
/// The table is data for the shared tokenizer.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// import { Arity, type OptionSpec, row, UNREAD } from './command_options.ts';
/// ```
use super::command_options::{Arity, OptionSpec, UNREAD, row};
/// `-t`,
/// `--track[=(direct|inherit)]`:
/// writes the tracking mode.
pub const TRACK: u16 = 1;
/// `--set-upstream`:
/// hidden,
/// writes the tracking mode Git refuses when creating.
pub const SET_UPSTREAM: u16 = 2;
/// `-u`,
/// `--set-upstream-to=<upstream>`.
pub const SET_UPSTREAM_TO: u16 = 3;
/// `--unset-upstream`.
pub const UNSET_UPSTREAM: u16 = 4;
/// `-r`/`--remotes` and `-a`/`--all`:
/// both change the listed kind of ref.
pub const KIND: u16 = 5;
/// `--contains`,
/// `--no-contains`,
/// `--with`,
/// `--without`,
/// `--merged`,
/// `--no-merged`,
/// `--forked`.
pub const FILTER: u16 = 6;
/// `-d`,
/// `--delete`.
pub const DELETE: u16 = 7;
/// `-D`.
pub const DELETE_FORCE: u16 = 8;
/// `-m`,
/// `--move`.
pub const MOVE: u16 = 9;
/// `-M`.
pub const MOVE_FORCE: u16 = 10;
/// `-c`,
/// `--copy`.
pub const COPY: u16 = 11;
/// `-C`.
pub const COPY_FORCE: u16 = 12;
/// `-l`,
/// `--list`.
pub const LIST: u16 = 13;
/// `--show-current`.
pub const SHOW_CURRENT: u16 = 14;
/// `--edit-description`.
pub const EDIT_DESCRIPTION: u16 = 15;
/// `--delete-merged=<pattern>`.
pub const DELETE_MERGED: u16 = 16;
/// `--dry-run`,
/// valid only with `--delete-merged`.
pub const DRY_RUN: u16 = 17;
/// `--points-at=<object>`.
pub const POINTS_AT: u16 = 18;
/// `--recurse-submodules`:
/// Git accepts it only when creating a branch.
pub const RECURSE_SUBMODULES: u16 = 19;
/// What:
/// `pub const NAME: &[OptionSpec] = &[...]` is a table baked into the program.
/// Why:
/// `--contains` and its relatives are `PARSE_OPT_LASTARG_DEFAULT`:
/// they take the next
/// token unless they are last.
/// `--color`,
/// `--abbrev`,
/// `--column` and `--track` take
/// an attached value only,
/// so `git branch --color name` creates `name`.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// export const BRANCH_TABLE = [row(UNREAD, 'v', 'verbose', 'none', true), /* ... */] as const;
/// ```
pub const BRANCH_TABLE: &[OptionSpec] = &[
row(UNREAD, Some(b'v'), Some("verbose"), Arity::None, true),
row(UNREAD, Some(b'q'), Some("quiet"), Arity::None, true),
row(TRACK, Some(b't'), Some("track"), Arity::Optional, true),
row(SET_UPSTREAM, None, Some("set-upstream"), Arity::None, true),
row(
SET_UPSTREAM_TO,
Some(b'u'),
Some("set-upstream-to"),
Arity::Required,
true,
),
row(
UNSET_UPSTREAM,
None,
Some("unset-upstream"),
Arity::None,
true,
),
row(UNREAD, None, Some("color"), Arity::Optional, true),
row(KIND, Some(b'r'), Some("remotes"), Arity::None, false),
row(FILTER, None, Some("contains"), Arity::LastArgDefault, false),
row(
FILTER,
None,
Some("no-contains"),
Arity::LastArgDefault,
false,
),
row(FILTER, None, Some("with"), Arity::LastArgDefault, false),
row(FILTER, None, Some("without"), Arity::LastArgDefault, false),
row(UNREAD, None, Some("abbrev"), Arity::Optional, true),
row(KIND, Some(b'a'), Some("all"), Arity::None, false),
row(DELETE, Some(b'd'), Some("delete"), Arity::None, true),
row(DELETE_FORCE, Some(b'D'), None, Arity::None, true),
row(MOVE, Some(b'm'), Some("move"), Arity::None, true),
row(MOVE_FORCE, Some(b'M'), None, Arity::None, true),
row(UNREAD, None, Some("omit-empty"), Arity::None, true),
row(COPY, Some(b'c'), Some("copy"), Arity::None, true),
row(COPY_FORCE, Some(b'C'), None, Arity::None, true),
row(LIST, Some(b'l'), Some("list"), Arity::None, true),
row(SHOW_CURRENT, None, Some("show-current"), Arity::None, true),
row(UNREAD, None, Some("create-reflog"), Arity::None, true),
row(
EDIT_DESCRIPTION,
None,
Some("edit-description"),
Arity::None,
true,
),
row(
DELETE_MERGED,
None,
Some("delete-merged"),
Arity::Required,
false,
),
row(DRY_RUN, None, Some("dry-run"), Arity::None, true),
row(UNREAD, Some(b'f'), Some("force"), Arity::None, true),
row(FILTER, None, Some("merged"), Arity::LastArgDefault, false),
row(
FILTER,
None,
Some("no-merged"),
Arity::LastArgDefault,
false,
),
row(FILTER, None, Some("forked"), Arity::Required, false),
row(UNREAD, None, Some("column"), Arity::Optional, true),
row(UNREAD, None, Some("sort"), Arity::Required, true),
row(POINTS_AT, None, Some("points-at"), Arity::Required, true),
row(UNREAD, Some(b'i'), Some("ignore-case"), Arity::None, true),
row(
RECURSE_SUBMODULES,
None,
Some("recurse-submodules"),
Arity::None,
true,
),
row(UNREAD, None, Some("format"), Arity::Required, true),
];