@@ -327,14 +327,15 @@ static struct commit_graph *load_commit_graph_one(const char *graph_file)
327
327
return g ;
328
328
}
329
329
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 )
331
332
{
332
- char * graph_name = get_commit_graph_filename (obj_dir );
333
+ char * graph_name = get_commit_graph_filename (odb -> path );
333
334
struct commit_graph * g = load_commit_graph_one (graph_name );
334
335
free (graph_name );
335
336
336
337
if (g )
337
- g -> obj_dir = obj_dir ;
338
+ g -> odb = odb ;
338
339
339
340
return g ;
340
341
}
@@ -372,14 +373,15 @@ static int add_graph_to_chain(struct commit_graph *g,
372
373
return 1 ;
373
374
}
374
375
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 )
376
378
{
377
379
struct commit_graph * graph_chain = NULL ;
378
380
struct strbuf line = STRBUF_INIT ;
379
381
struct stat st ;
380
382
struct object_id * oids ;
381
383
int i = 0 , valid = 1 , count ;
382
- char * chain_name = get_chain_filename (obj_dir );
384
+ char * chain_name = get_chain_filename (odb -> path );
383
385
FILE * fp ;
384
386
int stat_res ;
385
387
@@ -418,7 +420,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
418
420
free (graph_name );
419
421
420
422
if (g ) {
421
- g -> obj_dir = odb -> path ;
423
+ g -> odb = odb ;
422
424
423
425
if (add_graph_to_chain (g , graph_chain , oids , i )) {
424
426
graph_chain = g ;
@@ -442,23 +444,25 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
442
444
return graph_chain ;
443
445
}
444
446
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 )
446
449
{
447
- struct commit_graph * g = load_commit_graph_v1 (r , obj_dir );
450
+ struct commit_graph * g = load_commit_graph_v1 (r , odb );
448
451
449
452
if (!g )
450
- g = load_commit_graph_chain (r , obj_dir );
453
+ g = load_commit_graph_chain (r , odb );
451
454
452
455
return g ;
453
456
}
454
457
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 )
456
460
{
457
461
458
462
if (r -> objects -> commit_graph )
459
463
return ;
460
464
461
- r -> objects -> commit_graph = read_commit_graph_one (r , obj_dir );
465
+ r -> objects -> commit_graph = read_commit_graph_one (r , odb );
462
466
}
463
467
464
468
/*
@@ -505,7 +509,7 @@ static int prepare_commit_graph(struct repository *r)
505
509
for (odb = r -> objects -> odb ;
506
510
!r -> objects -> commit_graph && odb ;
507
511
odb = odb -> next )
508
- prepare_commit_graph_one (r , odb -> path );
512
+ prepare_commit_graph_one (r , odb );
509
513
return !!r -> objects -> commit_graph ;
510
514
}
511
515
@@ -1470,7 +1474,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
1470
1474
1471
1475
if (ctx -> split && ctx -> base_graph_name && ctx -> num_commit_graphs_after > 1 ) {
1472
1476
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 );
1474
1478
1475
1479
free (ctx -> commit_graph_filenames_after [ctx -> num_commit_graphs_after - 2 ]);
1476
1480
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)
1553
1557
1554
1558
while (g && (g -> num_commits <= size_mult * num_commits ||
1555
1559
(max_commits && num_commits > max_commits ))) {
1556
- if (strcmp (g -> obj_dir , ctx -> odb -> path ))
1560
+ if (strcmp (g -> odb -> path , ctx -> odb -> path ))
1557
1561
break ;
1558
1562
1559
1563
num_commits += g -> num_commits ;
@@ -1565,10 +1569,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
1565
1569
ctx -> new_base_graph = g ;
1566
1570
1567
1571
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 );
1569
1573
1570
1574
if (!strcmp (g -> filename , old_graph_name ) &&
1571
- strcmp (g -> obj_dir , ctx -> odb -> path )) {
1575
+ strcmp (g -> odb -> path , ctx -> odb -> path )) {
1572
1576
ctx -> num_commit_graphs_after = 1 ;
1573
1577
ctx -> new_base_graph = NULL ;
1574
1578
}
@@ -1816,7 +1820,7 @@ int write_commit_graph(struct object_directory *odb,
1816
1820
ctx -> oids .alloc = split_opts -> max_commits ;
1817
1821
1818
1822
if (ctx -> append ) {
1819
- prepare_commit_graph_one (ctx -> r , ctx -> odb -> path );
1823
+ prepare_commit_graph_one (ctx -> r , ctx -> odb );
1820
1824
if (ctx -> r -> objects -> commit_graph )
1821
1825
ctx -> oids .alloc += ctx -> r -> objects -> commit_graph -> num_commits ;
1822
1826
}
0 commit comments