@@ -24,7 +24,7 @@ pub mod write;
24
24
pub struct Editor < ' a > {
25
25
/// A way to lookup trees.
26
26
find : & ' a dyn crate :: FindExt ,
27
- /// The kind of hashes to produce
27
+ /// The kind of hashes to produce>
28
28
object_hash : gix_hash:: Kind ,
29
29
/// All trees we currently hold in memory. Each of these may change while adding and removing entries.
30
30
/// null-object-ids mark tree-entries whose value we don't know yet, they are placeholders that will be
@@ -46,7 +46,7 @@ pub struct Editor<'a> {
46
46
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
47
47
pub struct EntryMode {
48
48
// Represents the value read from Git, except that "040000" is represented with 0o140000 but
49
- // "40000" is represented with 0o40000
49
+ // "40000" is represented with 0o40000.
50
50
internal : u16 ,
51
51
}
52
52
@@ -62,10 +62,10 @@ impl TryFrom<u32> for tree::EntryMode {
62
62
}
63
63
64
64
impl EntryMode {
65
- /// Expose the value as a u16 (lossy, unlike the internal representation that is hidden)
65
+ /// Expose the value as u16 (lossy, unlike the internal representation that is hidden).
66
66
pub const fn value ( self ) -> u16 {
67
67
// Demangle the hack: In the case where the second leftmost octet is 4 (Tree), the leftmost bit is
68
- // there to represent whether the bytes representation should have 5 or 6 octets
68
+ // there to represent whether the bytes representation should have 5 or 6 octets.
69
69
if self . internal & IFMT == 0o140000 {
70
70
0o040000
71
71
} else {
@@ -85,7 +85,7 @@ impl EntryMode {
85
85
let digit = ( self . internal & oct_mask) >> bit_pos;
86
86
* backing_octet = b'0' + digit as u8 ;
87
87
}
88
- // Hack: `0o140000` represents `"040000"`, `0o40000` represents `"40000"`
88
+ // Hack: `0o140000` represents `"040000"`, `0o40000` represents `"40000"`.
89
89
if backing[ 1 ] == b'4' {
90
90
if backing[ 0 ] == b'1' {
91
91
backing[ 0 ] = b'0' ;
@@ -101,43 +101,43 @@ impl EntryMode {
101
101
}
102
102
103
103
/// Construct an EntryMode from bytes represented as in the git internal format
104
- /// Return the mode and the remainder of the bytes
104
+ /// Return the mode and the remainder of the bytes.
105
105
pub ( crate ) fn extract_from_bytes ( i : & [ u8 ] ) -> Option < ( Self , & ' _ [ u8 ] ) > {
106
106
let mut mode = 0 ;
107
107
let mut idx = 0 ;
108
108
let mut space_pos = 0 ;
109
109
if i. is_empty ( ) {
110
110
return None ;
111
111
}
112
- // const fn, this is why we can't have nice things (like `.iter().any()`)
112
+ // const fn, this is why we can't have nice things (like `.iter().any()`).
113
113
while idx < i. len ( ) {
114
114
let b = i[ idx] ;
115
115
// Delimiter, return what we got
116
116
if b == b' ' {
117
117
space_pos = idx;
118
118
break ;
119
119
}
120
- // Not a pure octal input
121
- // Performance matters here, so `!(b'0'..=b'7').contains(&b)` won't do
120
+ // Not a pure octal input.
121
+ // Performance matters here, so `!(b'0'..=b'7').contains(&b)` won't do.
122
122
#[ allow( clippy:: manual_range_contains) ]
123
123
if b < b'0' || b > b'7' {
124
124
return None ;
125
125
}
126
- // More than 6 octal digits we must have hit the delimiter or the input was malformed
126
+ // More than 6 octal digits we must have hit the delimiter or the input was malformed.
127
127
if idx > 6 {
128
128
return None ;
129
129
}
130
130
mode = ( mode << 3 ) + ( b - b'0' ) as u16 ;
131
131
idx += 1 ;
132
132
}
133
- // Hack: `0o140000` represents `"040000"`, `0o40000` represents `"40000"`
133
+ // Hack: `0o140000` represents `"040000"`, `0o40000` represents `"40000"`.
134
134
if mode == 0o040000 && i[ 0 ] == b'0' {
135
135
mode += 0o100000 ;
136
136
}
137
137
Some ( ( Self { internal : mode } , & i[ ( space_pos + 1 ) ..] ) )
138
138
}
139
139
140
- /// Construct an EntryMode from bytes represented as in the git internal format
140
+ /// Construct an EntryMode from bytes represented as in the git internal format.
141
141
pub fn from_bytes ( i : & [ u8 ] ) -> Option < Self > {
142
142
Self :: extract_from_bytes ( i) . map ( |( mode, _rest) | mode)
143
143
}
@@ -158,7 +158,7 @@ impl std::fmt::Octal for EntryMode {
158
158
/// A discretized version of ideal and valid values for entry modes.
159
159
///
160
160
/// Note that even though it can represent every valid [mode](EntryMode), it might
161
- /// loose information due to that as well.
161
+ /// lose information due to that as well.
162
162
#[ derive( Clone , Copy , PartialEq , Eq , Debug , Ord , PartialOrd , Hash ) ]
163
163
#[ repr( u16 ) ]
164
164
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
0 commit comments