@@ -183,15 +183,15 @@ struct commit_graph *load_commit_graph_one(const char *graph_file)
183183 exit (1 );
184184}
185185
186- static void prepare_commit_graph_one (const char * obj_dir )
186+ static void prepare_commit_graph_one (struct repository * r , const char * obj_dir )
187187{
188188 char * graph_name ;
189189
190- if (the_repository -> objects -> commit_graph )
190+ if (r -> objects -> commit_graph )
191191 return ;
192192
193193 graph_name = get_commit_graph_filename (obj_dir );
194- the_repository -> objects -> commit_graph =
194+ r -> objects -> commit_graph =
195195 load_commit_graph_one (graph_name );
196196
197197 FREE_AND_NULL (graph_name );
@@ -203,26 +203,34 @@ static void prepare_commit_graph_one(const char *obj_dir)
203203 * On the first invocation, this function attemps to load the commit
204204 * graph if the_repository is configured to have one.
205205 */
206- static int prepare_commit_graph (void )
206+ static int prepare_commit_graph (struct repository * r )
207207{
208208 struct alternate_object_database * alt ;
209209 char * obj_dir ;
210+ int config_value ;
210211
211- if (the_repository -> objects -> commit_graph_attempted )
212- return !!the_repository -> objects -> commit_graph ;
213- the_repository -> objects -> commit_graph_attempted = 1 ;
212+ if (r -> objects -> commit_graph_attempted )
213+ return !!r -> objects -> commit_graph ;
214+ r -> objects -> commit_graph_attempted = 1 ;
214215
215- if (!core_commit_graph )
216+ if (repo_config_get_bool (r , "core.commitgraph" , & config_value ) ||
217+ !config_value )
218+ /*
219+ * This repository is not configured to use commit graphs, so
220+ * do not load one. (But report commit_graph_attempted anyway
221+ * so that commit graph loading is not attempted again for this
222+ * repository.)
223+ */
216224 return 0 ;
217225
218- obj_dir = get_object_directory () ;
219- prepare_commit_graph_one (obj_dir );
220- prepare_alt_odb (the_repository );
221- for (alt = the_repository -> objects -> alt_odb_list ;
222- !the_repository -> objects -> commit_graph && alt ;
226+ obj_dir = r -> objects -> objectdir ;
227+ prepare_commit_graph_one (r , obj_dir );
228+ prepare_alt_odb (r );
229+ for (alt = r -> objects -> alt_odb_list ;
230+ !r -> objects -> commit_graph && alt ;
223231 alt = alt -> next )
224- prepare_commit_graph_one (alt -> path );
225- return !!the_repository -> objects -> commit_graph ;
232+ prepare_commit_graph_one (r , alt -> path );
233+ return !!r -> objects -> commit_graph ;
226234}
227235
228236static void close_commit_graph (void )
@@ -323,8 +331,6 @@ static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item
323331{
324332 uint32_t pos ;
325333
326- if (!core_commit_graph )
327- return 0 ;
328334 if (item -> object .parsed )
329335 return 1 ;
330336
@@ -334,20 +340,20 @@ static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item
334340 return 0 ;
335341}
336342
337- int parse_commit_in_graph (struct commit * item )
343+ int parse_commit_in_graph (struct repository * r , struct commit * item )
338344{
339- if (!prepare_commit_graph ())
345+ if (!prepare_commit_graph (r ))
340346 return 0 ;
341- return parse_commit_in_graph_one (the_repository -> objects -> commit_graph , item );
347+ return parse_commit_in_graph_one (r -> objects -> commit_graph , item );
342348}
343349
344- void load_commit_graph_info (struct commit * item )
350+ void load_commit_graph_info (struct repository * r , struct commit * item )
345351{
346352 uint32_t pos ;
347- if (!prepare_commit_graph ())
353+ if (!prepare_commit_graph (r ))
348354 return ;
349- if (find_commit_in_graph (item , the_repository -> objects -> commit_graph , & pos ))
350- fill_commit_graph_info (item , the_repository -> objects -> commit_graph , pos );
355+ if (find_commit_in_graph (item , r -> objects -> commit_graph , & pos ))
356+ fill_commit_graph_info (item , r -> objects -> commit_graph , pos );
351357}
352358
353359static struct tree * load_tree_for_commit (struct commit_graph * g , struct commit * c )
@@ -373,9 +379,9 @@ static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g,
373379 return load_tree_for_commit (g , (struct commit * )c );
374380}
375381
376- struct tree * get_commit_tree_in_graph (const struct commit * c )
382+ struct tree * get_commit_tree_in_graph (struct repository * r , const struct commit * c )
377383{
378- return get_commit_tree_in_graph_one (the_repository -> objects -> commit_graph , c );
384+ return get_commit_tree_in_graph_one (r -> objects -> commit_graph , c );
379385}
380386
381387static void write_graph_chunk_fanout (struct hashfile * f ,
@@ -691,7 +697,7 @@ void write_commit_graph(const char *obj_dir,
691697 oids .alloc = approximate_object_count () / 4 ;
692698
693699 if (append ) {
694- prepare_commit_graph_one (obj_dir );
700+ prepare_commit_graph_one (the_repository , obj_dir );
695701 if (the_repository -> objects -> commit_graph )
696702 oids .alloc += the_repository -> objects -> commit_graph -> num_commits ;
697703 }
0 commit comments