1
- use std:: path:: PathBuf ;
2
-
3
1
use bstr:: { BString , ByteSlice } ;
4
2
use gix_glob:: pattern:: Case ;
5
3
6
4
use crate :: { stack:: State , PathIdMapping } ;
7
5
6
+ #[ cfg( feature = "attributes" ) ]
8
7
type AttributeMatchGroup = gix_attributes:: Search ;
9
8
type IgnoreMatchGroup = gix_ignore:: Search ;
10
9
11
10
/// State related to attributes associated with files in the repository.
12
11
#[ derive( Default , Clone ) ]
12
+ #[ cfg( feature = "attributes" ) ]
13
13
pub struct Attributes {
14
14
/// Attribute patterns which aren't tied to the repository root, hence are global, they contribute first.
15
15
globals : AttributeMatchGroup ,
@@ -20,7 +20,7 @@ pub struct Attributes {
20
20
stack : AttributeMatchGroup ,
21
21
/// The first time we push the root, we have to load additional information from this file if it exists along with the root attributes
22
22
/// file if possible, and keep them there throughout.
23
- info_attributes : Option < PathBuf > ,
23
+ info_attributes : Option < std :: path :: PathBuf > ,
24
24
/// A lookup table to accelerate searches.
25
25
collection : gix_attributes:: search:: MetadataCollection ,
26
26
/// Where to read `.gitattributes` data from.
@@ -50,13 +50,15 @@ pub struct Ignore {
50
50
}
51
51
52
52
///
53
+ #[ cfg( feature = "attributes" ) ]
53
54
pub mod attributes;
54
55
///
55
56
pub mod ignore;
56
57
57
58
/// Initialization
58
59
impl State {
59
60
/// Configure a state to be suitable for checking out files, which only needs access to attribute files read from the index.
61
+ #[ cfg( feature = "attributes" ) ]
60
62
pub fn for_checkout ( unlink_on_collision : bool , attributes : Attributes ) -> Self {
61
63
State :: CreateDirectoryAndAttributesStack {
62
64
unlink_on_collision,
@@ -65,6 +67,7 @@ impl State {
65
67
}
66
68
67
69
/// Configure a state for adding files, with support for ignore files and attribute files.
70
+ #[ cfg( feature = "attributes" ) ]
68
71
pub fn for_add ( attributes : Attributes , ignore : Ignore ) -> Self {
69
72
State :: AttributesAndIgnoreStack { attributes, ignore }
70
73
}
@@ -96,6 +99,7 @@ impl State {
96
99
case : Case ,
97
100
) -> Vec < PathIdMapping > {
98
101
let a1_backing;
102
+ #[ cfg( feature = "attributes" ) ]
99
103
let a2_backing;
100
104
let names = match self {
101
105
State :: IgnoreStack ( ignore) => {
@@ -105,6 +109,7 @@ impl State {
105
109
) ] ;
106
110
a1_backing. as_ref ( )
107
111
}
112
+ #[ cfg( feature = "attributes" ) ]
108
113
State :: AttributesAndIgnoreStack { ignore, .. } => {
109
114
a2_backing = [
110
115
(
@@ -115,6 +120,7 @@ impl State {
115
120
] ;
116
121
a2_backing. as_ref ( )
117
122
}
123
+ #[ cfg( feature = "attributes" ) ]
118
124
State :: CreateDirectoryAndAttributesStack { .. } | State :: AttributesStack ( _) => {
119
125
a1_backing = [ ( ".gitattributes" . into ( ) , None ) ] ;
120
126
a1_backing. as_ref ( )
@@ -160,13 +166,16 @@ impl State {
160
166
pub ( crate ) fn ignore_or_panic ( & self ) -> & Ignore {
161
167
match self {
162
168
State :: IgnoreStack ( v) => v,
169
+ #[ cfg( feature = "attributes" ) ]
163
170
State :: AttributesAndIgnoreStack { ignore, .. } => ignore,
171
+ #[ cfg( feature = "attributes" ) ]
164
172
State :: AttributesStack ( _) | State :: CreateDirectoryAndAttributesStack { .. } => {
165
173
unreachable ! ( "BUG: must not try to check excludes without it being setup" )
166
174
}
167
175
}
168
176
}
169
177
178
+ #[ cfg( feature = "attributes" ) ]
170
179
pub ( crate ) fn attributes_or_panic ( & self ) -> & Attributes {
171
180
match self {
172
181
State :: AttributesStack ( attributes)
0 commit comments