You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// A module with specialized value types as they exist within git config files.
36
+
pubmod value {
32
37
pubenumColor{
33
38
Red,
34
39
BrightRed,
@@ -48,39 +53,68 @@ mod value {
48
53
}
49
54
}
50
55
}
56
+
/// Git-config paths can contain `~` and more, see [the git documentation](https://github.com/git/git/blob/e67fbf927dfdf13d0b21dc6ea15dc3c7ef448ea0/Documentation/config.txt#L295:L295)
57
+
/// on what needs to be supported.
51
58
pubfnpath(_value:&BStr) -> Result<PathBuf,Error>{
52
-
unimplemented!("path_resolve")
59
+
unimplemented!("resolve::path")
53
60
}
54
61
}
55
62
}
56
63
64
+
/// Spanned items refer to their content using [`Span`]s, thus they act like a pointer into a byte buffer representing the config file.
65
+
///
66
+
/// These are inherently read-only, as they do not own any data but rather point to a buffer they don't even know.
57
67
mod spanned {
58
68
usecrate::Span;
59
69
// we parse leading and trailing whitespace into comments, avoiding the notion of whitespace.
60
70
// This means we auto-trim whitespace otherwise, which I consider a feature
61
71
pub(crate)typeComment = Span;
62
72
73
+
/// A section or sub-section (in case `sub_name` is `Some()`), i.e.
74
+
///
75
+
/// ```text
76
+
/// [hello]
77
+
///
78
+
/// [hello.world]
79
+
/// ```
63
80
pub(crate)structSection{
64
81
pub(crate)name:Span,
65
82
pub(crate)sub_name:Option<Span>,
66
83
}
67
84
85
+
/// A key-value entry of a git-config file, like `name = value`
68
86
pub(crate)structEntry{
69
87
pub(crate)name:Span,
70
88
pub(crate)value:Option<Span>,
71
89
}
72
90
}
73
91
92
+
/// Owned versions of what can be found in `spanned`, which allows these items to be altered.
93
+
///
94
+
/// All of these will *may* remember their originating `span` as `Some(…)`, which is the entire region in the config file they point to. This is important
95
+
/// in case of updates. New owned items thus don't have a `span`, represented by `None`.
74
96
mod owned {
75
97
usecrate::Span;
76
98
use bstr::BString;
77
99
100
+
/// A key-value entry of a git-config file, like `name = value`
78
101
pubstructEntry{
79
102
pubname:BString,
80
103
pubvalue:Option<BString>,
81
104
pub(crate)span:Option<Span>,
82
105
}
83
106
107
+
/// A section or sub-section (in case `sub_name` is `Some()`), with all their entries.
108
+
///
109
+
/// For example
110
+
/// ```text
111
+
/// [hello]
112
+
/// a = 2
113
+
///
114
+
/// [hello.world]
115
+
/// b = c
116
+
/// x = y
117
+
/// ```
84
118
pubstructSection{
85
119
pubname:BString,
86
120
pubsub_name:Option<BString>,
@@ -128,6 +162,7 @@ mod owned {
128
162
}
129
163
}
130
164
165
+
/// Borrowed items are nothing more than a fancy 'handle' to an item stored in a file, which can be made editable to make updates.
131
166
mod borrowed {
132
167
usecrate::{file::File, owned};
133
168
@@ -183,6 +218,7 @@ mod decode {
183
218
}
184
219
}
185
220
221
+
/// Decode an entry value - it can be [encoded as described in the git config documentation](https://github.com/git/git/blob/e67fbf927dfdf13d0b21dc6ea15dc3c7ef448ea0/Documentation/config.txt#L74:L80)
0 commit comments