Re: [PATCH v2 5/7] fetch: add --negotiation-require option for negotiation
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Apr 20, 2026, 11:41 UTC
- Message-ID
- <83b88782-96cd-443c-9a44-379a0e1b9275@gmail.com>
- In-Reply-To
- <aeXfwnHvfnujAiqF@pks.im>
On 4/20/2026 4:11 AM, Patrick Steinhardt wrote:
Show 14 quoted lines
> On Wed, Apr 15, 2026 at 03:14:24PM +0000, Derrick Stolee via GitGitGadget wrote: >> From: Derrick Stolee <stolee@gmail.com> >> >> Add a new --negotiation-require option to 'git fetch', which ensures >> that certain ref tips are always sent as 'have' lines during fetch >> negotiation, regardless of what the negotiation algorithm selects. > > When reading "--negotiation-require" my mind immediately shifts towards > a mode where we require the remote to have a specific reference, and if > not we'll abort. That's of course not what you're proposing here, but I > would think that I may not be the only person making that connection. > > Would an alternative like "--negotiation-include" or > "--negotiation-expand" be better?
"include" does sound good to me. I'm open to it. I'll let this idea stew and try prepping my local branch in this direction.
Show 21 quoted lines
>> + /* Send unconditional haves from --negotiation-require */
>> + resolve_negotiation_require(args->negotiation_require,
>> + &negotiation_require_oids);
>> + if (oidset_size(&negotiation_require_oids)) {
>> + struct oidset_iter iter;
>> + oidset_iter_init(&negotiation_require_oids, &iter);
>> +
>> + while ((oid = oidset_iter_next(&iter))) {
>> + packet_buf_write(&req_buf, "have %s\n",
>> + oid_to_hex(oid));
>> + print_verbose(args, "have %s", oid_to_hex(oid));
>> + }
>> + }
>
> Okay, so here we now unconditionally send our requested object IDs.
>
> One thing I was wondering is whether we need to flush eventually. It can
> happen that the user specifies millions of refs, either intentionally or
> by accident. But I guess the answer might be "no", as the intent of the
> feature is that we indeed want to send all of those to the remote side,
> and the remote is being asked to consider all of those OIDs.The idea is indeed to send all of the requested OIDs, but this does present an interesting behavior where the Git client can allow the user to misconfigure themselves to send larger-than-normal negotiation requests. Previously, the client would protect the negotiation with a maximum set of haves.
Is there any concern about this becoming a vector for increased load on servers?
Would it be good to have some kind of advice message when the config matches a set of haves that we think is too large? That would maybe be a way to help users get out of a self-made problem.
Thanks, -Stolee