Skip to content

Commit 8632b5c

Browse files
committed
Merge branch 'en/commit-graph-timestamp-fix'
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
2 parents 619931f + fbcc540 commit 8632b5c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ static void compute_reachable_generation_numbers(
16691669
struct commit *current = list->item;
16701670
struct commit_list *parent;
16711671
int all_parents_computed = 1;
1672-
uint32_t max_gen = 0;
1672+
timestamp_t max_gen = 0;
16731673

16741674
for (parent = current->parents; parent; parent = parent->next) {
16751675
repo_parse_commit(info->r, parent->item);

t/t5328-commit-graph-64bit-time.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ test_expect_success 'single commit with generation data exceeding UINT32_MAX' '
7474
git -C repo-uint32-max commit-graph verify
7575
'
7676

77+
test_expect_success 'descendant of commit with date exceeding UINT32_MAX' '
78+
git init repo-uint32-max-descendant &&
79+
test_commit -C repo-uint32-max-descendant \
80+
--date "@4294967300 +0000" future-parent &&
81+
test_commit -C repo-uint32-max-descendant present-day-child &&
82+
git -C repo-uint32-max-descendant commit-graph write --reachable &&
83+
git -C repo-uint32-max-descendant commit-graph verify
84+
'
85+
7786
test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds generation overflow' '
7887
graph=.git/objects/info/commit-graph &&
7988
test_when_finished "rm -rf $graph" &&

0 commit comments

Comments
 (0)