1559
stop_progress(&ctx->progress);
1560
}
1561
1562
+static timestamp_t get_generation_from_graph_data(struct commit *c, void *data)
1563
+{
1564
+ return commit_graph_data_at(c)->generation;
1565
+}
1566
+
1567
+static void set_generation_v2(struct commit *c, timestamp_t t, void *data)
1568
+{
1569
+ struct commit_graph_data *g = commit_graph_data_at(c);
1570
+ g->generation = (uint32_t)t;
1571
+}
1572
+
1573
static void compute_generation_numbers(struct write_commit_graph_context *ctx)
1574
{
1575
int i;
1565
- struct commit_list *list = NULL;
1576
+ struct compute_generation_info info = {
1577
+ .r = ctx->r,
1578
+ .commits = &ctx->commits,
1579
+ .get_generation = get_generation_from_graph_data,
1580
+ .set_generation = set_generation_v2,
1581
+ .data = ctx,
1582
+ };
1583
1584
if (ctx->report_progress)
1568
- ctx->progress = start_delayed_progress(
1585
+ info.progress = ctx->progress
1586
+ = start_delayed_progress(
1587
_("Computing commit graph generation numbers"),
1588
ctx->commits.nr);
1589
1595
}
1596
}
1597
1580
- for (i = 0; i < ctx->commits.nr; i++) {
1581
- struct commit *c = ctx->commits.list[i];
1582
- timestamp_t corrected_commit_date;
1583
-
1584
- repo_parse_commit(ctx->r, c);
1585
- corrected_commit_date = commit_graph_data_at(c)->generation;
1586
-
1587
- display_progress(ctx->progress, i + 1);
1588
- if (corrected_commit_date != GENERATION_NUMBER_ZERO)
1589
- continue;
1590
-
1591
- commit_list_insert(c, &list);
1592
- while (list) {
1593
- struct commit *current = list->item;
1594
- struct commit_list *parent;
1595
- int all_parents_computed = 1;
1596
- timestamp_t max_corrected_commit_date = 0;
1597
-
1598
- for (parent = current->parents; parent; parent = parent->next) {
1599
- repo_parse_commit(ctx->r, parent->item);
1600
- corrected_commit_date = commit_graph_data_at(parent->item)->generation;
1601
-
1602
- if (corrected_commit_date == GENERATION_NUMBER_ZERO) {
1603
- all_parents_computed = 0;
1604
- commit_list_insert(parent->item, &list);
1605
- break;
1606
- }
1607
-
1608
- if (corrected_commit_date > max_corrected_commit_date)
1609
- max_corrected_commit_date = corrected_commit_date;
1610
- }
1611
-
1612
- if (all_parents_computed) {
1613
- pop_commit(&list);
1614
-
1615
- if (current->date && current->date > max_corrected_commit_date)
1616
- max_corrected_commit_date = current->date - 1;
1617
- commit_graph_data_at(current)->generation = max_corrected_commit_date + 1;
1618
- }
1619
- }
1620
- }
1598
+ compute_reachable_generation_numbers(&info, 2);
1599
1600
for (i = 0; i < ctx->commits.nr; i++) {
1601
struct commit *c = ctx->commits.list[i];