@@ -183,24 +183,20 @@ struct commit_graph *load_commit_graph_one(const char *graph_file)
183183 exit (1 );
184184}
185185
186- /* global storage */
187- static struct commit_graph * commit_graph = NULL ;
188-
189186static void prepare_commit_graph_one (const char * obj_dir )
190187{
191188 char * graph_name ;
192189
193- if (commit_graph )
190+ if (the_repository -> objects -> commit_graph )
194191 return ;
195192
196193 graph_name = get_commit_graph_filename (obj_dir );
197- commit_graph = load_commit_graph_one (graph_name );
194+ the_repository -> objects -> commit_graph =
195+ load_commit_graph_one (graph_name );
198196
199197 FREE_AND_NULL (graph_name );
200198}
201199
202- static int prepare_commit_graph_run_once = 0 ;
203-
204200/*
205201 * Return 1 if commit_graph is non-NULL, and 0 otherwise.
206202 *
@@ -212,9 +208,9 @@ static int prepare_commit_graph(void)
212208 struct alternate_object_database * alt ;
213209 char * obj_dir ;
214210
215- if (prepare_commit_graph_run_once )
216- return !!commit_graph ;
217- prepare_commit_graph_run_once = 1 ;
211+ if (the_repository -> objects -> commit_graph_attempted )
212+ return !!the_repository -> objects -> commit_graph ;
213+ the_repository -> objects -> commit_graph_attempted = 1 ;
218214
219215 if (!core_commit_graph )
220216 return 0 ;
@@ -223,16 +219,16 @@ static int prepare_commit_graph(void)
223219 prepare_commit_graph_one (obj_dir );
224220 prepare_alt_odb (the_repository );
225221 for (alt = the_repository -> objects -> alt_odb_list ;
226- !commit_graph && alt ;
222+ !the_repository -> objects -> commit_graph && alt ;
227223 alt = alt -> next )
228224 prepare_commit_graph_one (alt -> path );
229- return !!commit_graph ;
225+ return !!the_repository -> objects -> commit_graph ;
230226}
231227
232228static void close_commit_graph (void )
233229{
234- free_commit_graph (commit_graph );
235- commit_graph = NULL ;
230+ free_commit_graph (the_repository -> objects -> commit_graph );
231+ the_repository -> objects -> commit_graph = NULL ;
236232}
237233
238234static int bsearch_graph (struct commit_graph * g , struct object_id * oid , uint32_t * pos )
@@ -342,16 +338,16 @@ int parse_commit_in_graph(struct commit *item)
342338{
343339 if (!prepare_commit_graph ())
344340 return 0 ;
345- return parse_commit_in_graph_one (commit_graph , item );
341+ return parse_commit_in_graph_one (the_repository -> objects -> commit_graph , item );
346342}
347343
348344void load_commit_graph_info (struct commit * item )
349345{
350346 uint32_t pos ;
351347 if (!prepare_commit_graph ())
352348 return ;
353- if (find_commit_in_graph (item , commit_graph , & pos ))
354- fill_commit_graph_info (item , commit_graph , pos );
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 );
355351}
356352
357353static struct tree * load_tree_for_commit (struct commit_graph * g , struct commit * c )
@@ -379,7 +375,7 @@ static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g,
379375
380376struct tree * get_commit_tree_in_graph (const struct commit * c )
381377{
382- return get_commit_tree_in_graph_one (commit_graph , c );
378+ return get_commit_tree_in_graph_one (the_repository -> objects -> commit_graph , c );
383379}
384380
385381static void write_graph_chunk_fanout (struct hashfile * f ,
@@ -696,15 +692,17 @@ void write_commit_graph(const char *obj_dir,
696692
697693 if (append ) {
698694 prepare_commit_graph_one (obj_dir );
699- if (commit_graph )
700- oids .alloc += commit_graph -> num_commits ;
695+ if (the_repository -> objects -> commit_graph )
696+ oids .alloc += the_repository -> objects -> commit_graph -> num_commits ;
701697 }
702698
703699 if (oids .alloc < 1024 )
704700 oids .alloc = 1024 ;
705701 ALLOC_ARRAY (oids .list , oids .alloc );
706702
707- if (append && commit_graph ) {
703+ if (append && the_repository -> objects -> commit_graph ) {
704+ struct commit_graph * commit_graph =
705+ the_repository -> objects -> commit_graph ;
708706 for (i = 0 ; i < commit_graph -> num_commits ; i ++ ) {
709707 const unsigned char * hash = commit_graph -> chunk_oid_lookup +
710708 commit_graph -> hash_len * i ;
0 commit comments