Subject: Re: [PATCH v2] commit-graph: fix writing generations with dates exceeding 34 bits

From: Junio C Hamano <[email-masked]>
Date: Tue, 24 Mar 2026 08:42:31 -0700

Patrick Steinhardt <[email-masked]> writes:

> Changes in v2:
>   - Account for platforms where `timestamp_t` has 32 bit precision. This
>     matches logic in `write_graph_chunk_data()`, where we also depend on
>     the size of the commit timestamps.

> +static timestamp_t compute_generation_offset(struct commit *c)
> +{
> +	timestamp_t masked_date;
> +
> +	if (sizeof(timestamp_t) > 4)
> +		masked_date = c->date & (((timestamp_t) 1 << 34) - 1);
> +	else
> +		masked_date = c->date;

It is a bit surprising that on a platform where timestamp_t is only
32-bit wide, a smart-enough compiler would not find (1<<34) as
suspicious.  IOW, I would have expected this to be done not with
runtime switch but with conditional compilation.