@@ -327,14 +327,15 @@ static struct commit_graph *load_commit_graph_one(const char *graph_file)
327327 return g ;
328328}
329329
330- static struct commit_graph * load_commit_graph_v1 (struct repository * r , const char * obj_dir )
330+ static struct commit_graph * load_commit_graph_v1 (struct repository * r ,
331+ struct object_directory * odb )
331332{
332- char * graph_name = get_commit_graph_filename (obj_dir );
333+ char * graph_name = get_commit_graph_filename (odb -> path );
333334 struct commit_graph * g = load_commit_graph_one (graph_name );
334335 free (graph_name );
335336
336337 if (g )
337- g -> obj_dir = obj_dir ;
338+ g -> odb = odb ;
338339
339340 return g ;
340341}
@@ -372,14 +373,15 @@ static int add_graph_to_chain(struct commit_graph *g,
372373 return 1 ;
373374}
374375
375- static struct commit_graph * load_commit_graph_chain (struct repository * r , const char * obj_dir )
376+ static struct commit_graph * load_commit_graph_chain (struct repository * r ,
377+ struct object_directory * odb )
376378{
377379 struct commit_graph * graph_chain = NULL ;
378380 struct strbuf line = STRBUF_INIT ;
379381 struct stat st ;
380382 struct object_id * oids ;
381383 int i = 0 , valid = 1 , count ;
382- char * chain_name = get_chain_filename (obj_dir );
384+ char * chain_name = get_chain_filename (odb -> path );
383385 FILE * fp ;
384386 int stat_res ;
385387
@@ -418,7 +420,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
418420 free (graph_name );
419421
420422 if (g ) {
421- g -> obj_dir = odb -> path ;
423+ g -> odb = odb ;
422424
423425 if (add_graph_to_chain (g , graph_chain , oids , i )) {
424426 graph_chain = g ;
@@ -442,23 +444,25 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
442444 return graph_chain ;
443445}
444446
445- struct commit_graph * read_commit_graph_one (struct repository * r , const char * obj_dir )
447+ struct commit_graph * read_commit_graph_one (struct repository * r ,
448+ struct object_directory * odb )
446449{
447- struct commit_graph * g = load_commit_graph_v1 (r , obj_dir );
450+ struct commit_graph * g = load_commit_graph_v1 (r , odb );
448451
449452 if (!g )
450- g = load_commit_graph_chain (r , obj_dir );
453+ g = load_commit_graph_chain (r , odb );
451454
452455 return g ;
453456}
454457
455- static void prepare_commit_graph_one (struct repository * r , const char * obj_dir )
458+ static void prepare_commit_graph_one (struct repository * r ,
459+ struct object_directory * odb )
456460{
457461
458462 if (r -> objects -> commit_graph )
459463 return ;
460464
461- r -> objects -> commit_graph = read_commit_graph_one (r , obj_dir );
465+ r -> objects -> commit_graph = read_commit_graph_one (r , odb );
462466}
463467
464468/*
@@ -505,7 +509,7 @@ static int prepare_commit_graph(struct repository *r)
505509 for (odb = r -> objects -> odb ;
506510 !r -> objects -> commit_graph && odb ;
507511 odb = odb -> next )
508- prepare_commit_graph_one (r , odb -> path );
512+ prepare_commit_graph_one (r , odb );
509513 return !!r -> objects -> commit_graph ;
510514}
511515
@@ -1470,7 +1474,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
14701474
14711475 if (ctx -> split && ctx -> base_graph_name && ctx -> num_commit_graphs_after > 1 ) {
14721476 char * new_base_hash = xstrdup (oid_to_hex (& ctx -> new_base_graph -> oid ));
1473- char * new_base_name = get_split_graph_filename (ctx -> new_base_graph -> obj_dir , new_base_hash );
1477+ char * new_base_name = get_split_graph_filename (ctx -> new_base_graph -> odb -> path , new_base_hash );
14741478
14751479 free (ctx -> commit_graph_filenames_after [ctx -> num_commit_graphs_after - 2 ]);
14761480 free (ctx -> commit_graph_hash_after [ctx -> num_commit_graphs_after - 2 ]);
@@ -1553,7 +1557,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
15531557
15541558 while (g && (g -> num_commits <= size_mult * num_commits ||
15551559 (max_commits && num_commits > max_commits ))) {
1556- if (strcmp (g -> obj_dir , ctx -> odb -> path ))
1560+ if (strcmp (g -> odb -> path , ctx -> odb -> path ))
15571561 break ;
15581562
15591563 num_commits += g -> num_commits ;
@@ -1565,10 +1569,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
15651569 ctx -> new_base_graph = g ;
15661570
15671571 if (ctx -> num_commit_graphs_after == 2 ) {
1568- char * old_graph_name = get_commit_graph_filename (g -> obj_dir );
1572+ char * old_graph_name = get_commit_graph_filename (g -> odb -> path );
15691573
15701574 if (!strcmp (g -> filename , old_graph_name ) &&
1571- strcmp (g -> obj_dir , ctx -> odb -> path )) {
1575+ strcmp (g -> odb -> path , ctx -> odb -> path )) {
15721576 ctx -> num_commit_graphs_after = 1 ;
15731577 ctx -> new_base_graph = NULL ;
15741578 }
@@ -1816,7 +1820,7 @@ int write_commit_graph(struct object_directory *odb,
18161820 ctx -> oids .alloc = split_opts -> max_commits ;
18171821
18181822 if (ctx -> append ) {
1819- prepare_commit_graph_one (ctx -> r , ctx -> odb -> path );
1823+ prepare_commit_graph_one (ctx -> r , ctx -> odb );
18201824 if (ctx -> r -> objects -> commit_graph )
18211825 ctx -> oids .alloc += ctx -> r -> objects -> commit_graph -> num_commits ;
18221826 }
0 commit comments