@@ -128,6 +128,16 @@ timestamp_t commit_graph_generation(const struct commit *c)
128
128
return GENERATION_NUMBER_INFINITY ;
129
129
}
130
130
131
+ static timestamp_t commit_graph_generation_from_graph (const struct commit * c )
132
+ {
133
+ struct commit_graph_data * data =
134
+ commit_graph_data_slab_peek (& commit_graph_data_slab , c );
135
+
136
+ if (!data || data -> graph_pos == COMMIT_NOT_FROM_GRAPH )
137
+ return GENERATION_NUMBER_INFINITY ;
138
+ return data -> generation ;
139
+ }
140
+
131
141
static struct commit_graph_data * commit_graph_data_at (const struct commit * c )
132
142
{
133
143
unsigned int i , nth_slab ;
@@ -2550,9 +2560,6 @@ static void graph_report(const char *fmt, ...)
2550
2560
va_end (ap );
2551
2561
}
2552
2562
2553
- #define GENERATION_ZERO_EXISTS 1
2554
- #define GENERATION_NUMBER_EXISTS 2
2555
-
2556
2563
static int commit_graph_checksum_valid (struct commit_graph * g )
2557
2564
{
2558
2565
return hashfile_checksum_valid (g -> data , g -> data_len );
@@ -2565,7 +2572,8 @@ static int verify_one_commit_graph(struct repository *r,
2565
2572
{
2566
2573
uint32_t i , cur_fanout_pos = 0 ;
2567
2574
struct object_id prev_oid , cur_oid ;
2568
- int generation_zero = 0 ;
2575
+ struct commit * seen_gen_zero = NULL ;
2576
+ struct commit * seen_gen_non_zero = NULL ;
2569
2577
2570
2578
verify_commit_graph_error = verify_commit_graph_lite (g );
2571
2579
if (verify_commit_graph_error )
@@ -2659,7 +2667,7 @@ static int verify_one_commit_graph(struct repository *r,
2659
2667
oid_to_hex (& graph_parents -> item -> object .oid ),
2660
2668
oid_to_hex (& odb_parents -> item -> object .oid ));
2661
2669
2662
- generation = commit_graph_generation (graph_parents -> item );
2670
+ generation = commit_graph_generation_from_graph (graph_parents -> item );
2663
2671
if (generation > max_generation )
2664
2672
max_generation = generation ;
2665
2673
@@ -2671,16 +2679,12 @@ static int verify_one_commit_graph(struct repository *r,
2671
2679
graph_report (_ ("commit-graph parent list for commit %s terminates early" ),
2672
2680
oid_to_hex (& cur_oid ));
2673
2681
2674
- if (!commit_graph_generation (graph_commit )) {
2675
- if (generation_zero == GENERATION_NUMBER_EXISTS )
2676
- graph_report (_ ("commit-graph has generation number zero for commit %s, but non-zero elsewhere" ),
2677
- oid_to_hex (& cur_oid ));
2678
- generation_zero = GENERATION_ZERO_EXISTS ;
2679
- } else if (generation_zero == GENERATION_ZERO_EXISTS )
2680
- graph_report (_ ("commit-graph has non-zero generation number for commit %s, but zero elsewhere" ),
2681
- oid_to_hex (& cur_oid ));
2682
+ if (commit_graph_generation_from_graph (graph_commit ))
2683
+ seen_gen_non_zero = graph_commit ;
2684
+ else
2685
+ seen_gen_zero = graph_commit ;
2682
2686
2683
- if (generation_zero == GENERATION_ZERO_EXISTS )
2687
+ if (seen_gen_zero )
2684
2688
continue ;
2685
2689
2686
2690
/*
@@ -2706,6 +2710,12 @@ static int verify_one_commit_graph(struct repository *r,
2706
2710
odb_commit -> date );
2707
2711
}
2708
2712
2713
+ if (seen_gen_zero && seen_gen_non_zero )
2714
+ graph_report (_ ("commit-graph has both zero and non-zero "
2715
+ "generations (e.g., commits '%s' and '%s')" ),
2716
+ oid_to_hex (& seen_gen_zero -> object .oid ),
2717
+ oid_to_hex (& seen_gen_non_zero -> object .oid ));
2718
+
2709
2719
return verify_commit_graph_error ;
2710
2720
}
2711
2721
0 commit comments