Merge branch 'en/commit-graph-timestamp-fix' into jch

compute_reachable_generation_numbers() in commit-graph used a 32-bit
integer to accumulate parent generations, which is OK for generation
number v1 (topological levels), but with generation number v2
(adjusted committer timestamps), it truncated timestamps beyond
2106.  Fixed by widening the accumulator to timestamp_t.

* en/commit-graph-timestamp-fix:
  commit-graph: use timestamp_t for max parent generation accumulator
This commit is contained in:
Junio C Hamano
2026-06-17 05:40:01 -07:00
2 changed files with 10 additions and 1 deletions

View File

@@ -1669,7 +1669,7 @@ static void compute_reachable_generation_numbers(
struct commit *current = list->item;
struct commit_list *parent;
int all_parents_computed = 1;
uint32_t max_gen = 0;
timestamp_t max_gen = 0;
for (parent = current->parents; parent; parent = parent->next) {
repo_parse_commit(info->r, parent->item);

View File

@@ -74,6 +74,15 @@ test_expect_success 'single commit with generation data exceeding UINT32_MAX' '
git -C repo-uint32-max commit-graph verify
'
test_expect_success 'descendant of commit with date exceeding UINT32_MAX' '
git init repo-uint32-max-descendant &&
test_commit -C repo-uint32-max-descendant \
--date "@4294967300 +0000" future-parent &&
test_commit -C repo-uint32-max-descendant present-day-child &&
git -C repo-uint32-max-descendant commit-graph write --reachable &&
git -C repo-uint32-max-descendant commit-graph verify
'
test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds generation overflow' '
graph=.git/objects/info/commit-graph &&
test_when_finished "rm -rf $graph" &&