Re: [PATCH v3 4/5] promisor-remote: prevent infinite recursion when lazy fetching
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 8, 2026, 18:12 UTC
- Message-ID
- <xmqqqzj3wr24.fsf@gitster.g>
- In-Reply-To
- <20260908164129.560396-5-christian.couder@gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 11 quoted lines
> It does not recurse forever in practice, but only because each level > adds one more variable to the environment of the child process, so > after a while `exec()` fails with: > > fatal: cannot exec 'git-upload-pack ...': Argument list too long > fatal: unable to fork > > To avoid this pathological case altogether, let's use a new > `GIT_INTERNAL_LAZY_FETCH_DEPTH` to count the recursion depth, and let's > check that it doesn't exceed a MAX_LAZY_FETCH_DEPTH limit (set to 5 for > now).
Good.
Does it have to be "unsigned long", though? Just like oid_nr, I'd prefer to see a number whose range or signedness does not matter in practice be typed as platform natural "int". Even though one could argue that "anything_nr cannot be negative so it must be unsigned", or "int might be too small for some platforms" or "int or ulong have different width on different platforms", or even "anything we count we should count in size_t", I do not think any of them is a good argument against it, especially when the value we start with is 5 ;-).