@@ -12,6 +12,8 @@ pub enum Error {
12
12
AncestorIter ( #[ from] gix_traverse:: commit:: ancestors:: Error ) ,
13
13
#[ error( transparent) ]
14
14
ShallowCommits ( #[ from] crate :: shallow:: open:: Error ) ,
15
+ #[ error( transparent) ]
16
+ ConfigBoolean ( #[ from] crate :: config:: boolean:: Error ) ,
15
17
}
16
18
17
19
/// Information about a commit that we obtained naturally as part of the iteration.
@@ -92,7 +94,7 @@ pub struct Platform<'repo> {
92
94
pub ( crate ) tips : Vec < ObjectId > ,
93
95
pub ( crate ) sorting : gix_traverse:: commit:: Sorting ,
94
96
pub ( crate ) parents : gix_traverse:: commit:: Parents ,
95
- pub ( crate ) use_commit_graph : bool ,
97
+ pub ( crate ) use_commit_graph : Option < bool > ,
96
98
pub ( crate ) commit_graph : Option < gix_commitgraph:: Graph > ,
97
99
}
98
100
@@ -103,7 +105,7 @@ impl<'repo> Platform<'repo> {
103
105
tips : tips. into_iter ( ) . map ( Into :: into) . collect ( ) ,
104
106
sorting : Default :: default ( ) ,
105
107
parents : Default :: default ( ) ,
106
- use_commit_graph : true ,
108
+ use_commit_graph : None ,
107
109
commit_graph : None ,
108
110
}
109
111
}
@@ -123,12 +125,12 @@ impl<'repo> Platform<'repo> {
123
125
self
124
126
}
125
127
126
- /// Allow using the commitgraph, if present, if `toggle` is `true`, or disallow it with `false`.
128
+ /// Allow using the commitgraph, if present, if `toggle` is `true`, or disallow it with `false`. Set it to `None` to leave
129
+ /// control over this to the configuration of `core.commitGraph` (the default).
127
130
///
128
- /// Note that the commitgraph will be used by default, and that errors just lead to falling back to the object database,
129
- /// it's treated as a cache.
130
- pub fn use_commit_graph ( mut self , toggle : bool ) -> Self {
131
- self . use_commit_graph = toggle;
131
+ /// Errors when loading the graph lead to falling back to the object database, it's treated as optional cache.
132
+ pub fn use_commit_graph ( mut self , toggle : impl Into < Option < bool > > ) -> Self {
133
+ self . use_commit_graph = toggle. into ( ) ;
132
134
self
133
135
}
134
136
@@ -201,7 +203,12 @@ impl<'repo> Platform<'repo> {
201
203
)
202
204
. sorting ( sorting) ?
203
205
. parents ( parents)
204
- . commit_graph ( commit_graph. or ( use_commit_graph. then ( || self . repo . commit_graph ( ) . ok ( ) ) . flatten ( ) ) ) ,
206
+ . commit_graph (
207
+ commit_graph. or ( use_commit_graph
208
+ . map_or_else ( || self . repo . config . may_use_commit_graph ( ) , Ok ) ?
209
+ . then ( || self . repo . commit_graph ( ) . ok ( ) )
210
+ . flatten ( ) ) ,
211
+ ) ,
205
212
) ,
206
213
} )
207
214
}
0 commit comments