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
//! What:
//! Pure decision of the add-explicit policy:
//! `git add` names the paths it stages.
//! Why:
//! `git add .`,
//! `git add -A` and `git add -u` sweep up every changed path,
//! including
//! ones the caller never looked at,
//! so one commit stops describing one change.
//! The
//! policy rejects those forms.
//! This file decides from the arguments alone;
//! it reads
//! no file and starts no process.
//!
//! In TS you'd write (pseudocode):
//! ```ts
//! // decideAddExplicit(['add', '.']) => 'cli-git: git add rejects bulk-staging patterns (.) ...'
//! ```
/// What:
/// `use` brings names from sibling files into this file;
/// `super::` means "the parent
/// module",
/// where every sibling file of this crate is declared.
/// Why:
/// Which tokens stage in bulk comes from Git's own option table of `git add`.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// import { ADD_ESCAPE_HATCH, parseAddRegion } from './command_add.ts';
/// ```
use crate;
use crateOptionError;
use cratecommand_tokens;
/// What:
/// `OsString` is owned operating-system text of raw bytes.
/// Sibling the reader might
/// expect:
/// `String`,
/// which must be valid UTF-8.
/// Why:
/// Arguments are compared as bytes;
/// only the rejection text renders them.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// // string, but byte-preserving.
/// ```
use OsString;
/// What:
/// The finding code of an add-explicit rejection.
/// `&str` is borrowed text baked into
/// the program.
/// Why:
/// Callers identify the finding by this stable code.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// const BULK_ADD_CODE = 'bulk-add-rejected';
/// ```
pub const BULK_ADD_CODE: &str = "bulk-add-rejected";
/// What:
/// Decide from the argument list:
/// the rejection text,
/// or nothing to let the command
/// through.
/// `&[OsString]` borrows the arguments,
/// already free of wrapper controls;
/// `Option<String>` is "owned text or nothing".
/// Why:
/// Only `git add` is judged,
/// and only when Git accepts its options.
/// The text quotes
/// the caller's own tokens,
/// so `-vA` is named as written.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// function decideAddExplicit(args: string[]): string | undefined;
/// ```
/// Bulk forms,
/// explicit forms and the rejection text.