Commit 9ee9954
committed
commit-graph: use timestamp_t for max parent generation accumulator
compute_reachable_generation_numbers() computes each commit's
generation as
max(c->date, max(parent.generation)) + 1
by walking its parents and accumulating their generations into a
local
uint32_t max_gen = 0;
while info->get_generation() returns timestamp_t and
compute_generation_from_max() already takes its max_gen parameter
as timestamp_t. For v1 (topological levels) the narrowing is
harmless because GENERATION_NUMBER_V1_MAX is less than 2^30, but
for v2 (corrected committer dates) it silently truncates any
parent generation that does not fit in 32 bits, i.e. any parent
whose committer timestamp is at or beyond 2106-02-07 UTC
(>= 2^32).
The truncated max then loses its dominance over c->date and the
child commit ends up with a generation that violates v2
monotonicity. The bad value gets written into the GDA2 chunk and
is caught later by `git commit-graph verify`.
Widen the accumulator to timestamp_t.
The narrowing was introduced in 6f6ecca307a7 (commit-graph:
combine generation computations, 2022-04-04), when the v1 and v2
generation computations were unified into a single helper.
The existing "single commit with generation data exceeding
UINT32_MAX" test in t5328 covers a root commit, which has no
parents whose generation could overflow the accumulator. Add a
test with a future-dated parent and a present-day child; without
this fix `git commit-graph verify` reports the descendant's
stored generation as below parent + 1.
Signed-off-by: Elijah Newren <newren@gmail.com>1 parent 600fe74 commit 9ee9954
2 files changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1669 | 1669 | | |
1670 | 1670 | | |
1671 | 1671 | | |
1672 | | - | |
| 1672 | + | |
1673 | 1673 | | |
1674 | 1674 | | |
1675 | 1675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
| |||
0 commit comments