Re: [PATCH 1/2] stash: record positional index in 'struct stash_info'

Junio C Hamano <[email protected]> Thu, 30 Jul 2026 06:22:51 -0700
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Ben Knoble <[email protected]> writes:

>> +    if (at) {
>> +        char *ep;
>> +        unsigned long u = strtoul(at + 2, &ep, 10);
>> +        if (ep > at + 2 && *ep == '}' && u < 100000000)
>> +            info->stash_idx = (int)u;
>

> What’s the purpose of the 1e8 constant/comparison? I see we
> truncate the unsigned long to an int, but even on 32-bit platforms
> 1e8 is a small portion of the integer range, right? So my read is
> that we are limiting the valid « n » in @{n}. I’m not totally
> sure why, though, or if that matches with the rest of the stash
> manipulation code.

This mirrors what approxidate does.  An integer that is too big is
taken as number-of-seconds-since-epoch.