@@ -183,24 +183,20 @@ struct commit_graph *load_commit_graph_one(const char *graph_file)
183
183
exit (1 );
184
184
}
185
185
186
- /* global storage */
187
- static struct commit_graph * commit_graph = NULL ;
188
-
189
186
static void prepare_commit_graph_one (const char * obj_dir )
190
187
{
191
188
char * graph_name ;
192
189
193
- if (commit_graph )
190
+ if (the_repository -> objects -> commit_graph )
194
191
return ;
195
192
196
193
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 );
198
196
199
197
FREE_AND_NULL (graph_name );
200
198
}
201
199
202
- static int prepare_commit_graph_run_once = 0 ;
203
-
204
200
/*
205
201
* Return 1 if commit_graph is non-NULL, and 0 otherwise.
206
202
*
@@ -212,9 +208,9 @@ static int prepare_commit_graph(void)
212
208
struct alternate_object_database * alt ;
213
209
char * obj_dir ;
214
210
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 ;
218
214
219
215
if (!core_commit_graph )
220
216
return 0 ;
@@ -223,16 +219,16 @@ static int prepare_commit_graph(void)
223
219
prepare_commit_graph_one (obj_dir );
224
220
prepare_alt_odb (the_repository );
225
221
for (alt = the_repository -> objects -> alt_odb_list ;
226
- !commit_graph && alt ;
222
+ !the_repository -> objects -> commit_graph && alt ;
227
223
alt = alt -> next )
228
224
prepare_commit_graph_one (alt -> path );
229
- return !!commit_graph ;
225
+ return !!the_repository -> objects -> commit_graph ;
230
226
}
231
227
232
228
static void close_commit_graph (void )
233
229
{
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 ;
236
232
}
237
233
238
234
static 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)
342
338
{
343
339
if (!prepare_commit_graph ())
344
340
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 );
346
342
}
347
343
348
344
void load_commit_graph_info (struct commit * item )
349
345
{
350
346
uint32_t pos ;
351
347
if (!prepare_commit_graph ())
352
348
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 );
355
351
}
356
352
357
353
static 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,
379
375
380
376
struct tree * get_commit_tree_in_graph (const struct commit * c )
381
377
{
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 );
383
379
}
384
380
385
381
static void write_graph_chunk_fanout (struct hashfile * f ,
@@ -696,15 +692,17 @@ void write_commit_graph(const char *obj_dir,
696
692
697
693
if (append ) {
698
694
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 ;
701
697
}
702
698
703
699
if (oids .alloc < 1024 )
704
700
oids .alloc = 1024 ;
705
701
ALLOC_ARRAY (oids .list , oids .alloc );
706
702
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 ;
708
706
for (i = 0 ; i < commit_graph -> num_commits ; i ++ ) {
709
707
const unsigned char * hash = commit_graph -> chunk_oid_lookup +
710
708
commit_graph -> hash_len * i ;
0 commit comments