Files
git/negotiator/noop.c
Derrick Stolee 22b2f3d2a3 negotiator: add have_sent() interface
In a future change, we will introduce a capability to choose specific commit
OIDs as 'have's in fetch negotiation, with the ability to have the
negotiator choose more 'have's to increase coverage beyond that required
core set. The negotiator works to avoid emitting 'have's that can reach each
other, but that logic is hidden beneath the negotiator's iterator function
pointer ('next'). We need a way to communicate to the negotiator that we
have picked a 'have' so it could incorporate that into its logic.

Add a have_sent() method to the fetch_negotiator interface. This is the
signal that allows the negotiator to track the commit as already shown and
can perform the proper bookkeeping to avoid emitting those objects or
anything they can reach.

For our non-trivial negotiators, it is sufficient to mark these commits as
common, so the implementation is quite simple. This logic will be exercised
in the next change.

Reviewed-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-05-20 11:33:24 +09:00

53 lines
1.1 KiB
C

#include "git-compat-util.h"
#include "noop.h"
#include "../fetch-negotiator.h"
static void known_common(struct fetch_negotiator *n UNUSED,
struct commit *c UNUSED)
{
/* do nothing */
}
static void add_tip(struct fetch_negotiator *n UNUSED,
struct commit *c UNUSED)
{
/* do nothing */
}
static const struct object_id *next(struct fetch_negotiator *n UNUSED)
{
return NULL;
}
static int ack(struct fetch_negotiator *n UNUSED, struct commit *c UNUSED)
{
/*
* This negotiator does not emit any commits, so there is no commit to
* be acknowledged. If there is any ack, there is a bug.
*/
BUG("ack with noop negotiator, which does not emit any commits");
return 0;
}
static void have_sent(struct fetch_negotiator *n UNUSED,
struct commit *c UNUSED)
{
/* nothing to do */
}
static void release(struct fetch_negotiator *n UNUSED)
{
/* nothing to release */
}
void noop_negotiator_init(struct fetch_negotiator *negotiator)
{
negotiator->known_common = known_common;
negotiator->add_tip = add_tip;
negotiator->next = next;
negotiator->ack = ack;
negotiator->have_sent = have_sent;
negotiator->release = release;
negotiator->data = NULL;
}