1 #ifndef FETCH_NEGOTIATOR
2 #define FETCH_NEGOTIATOR
7 * An object that supplies the information needed to negotiate the contents of
8 * the to-be-sent packfile during a fetch.
10 * To set up the negotiator, call fetch_negotiator_init(), then known_common()
11 * (0 or more times), then add_tip() (0 or more times).
13 * Then, when "have" lines are required, call next(). Call ack() to report what
14 * the server tells us.
16 * Once negotiation is done, call release(). The negotiator then cannot be used
17 * (unless reinitialized with fetch_negotiator_init()).
19 struct fetch_negotiator
{
21 * Before negotiation starts, indicate that the server is known to have
24 void (*known_common
)(struct fetch_negotiator
*, struct commit
*);
27 * Once this function is invoked, known_common() cannot be invoked any
30 * Indicate that this commit and all its ancestors are to be checked
31 * for commonality with the server.
33 void (*add_tip
)(struct fetch_negotiator
*, struct commit
*);
36 * Once this function is invoked, known_common() and add_tip() cannot
37 * be invoked any more.
39 * Return the next commit that the client should send as a "have" line.
41 const struct object_id
*(*next
)(struct fetch_negotiator
*);
44 * Inform the negotiator that the server has the given commit. This
45 * method must only be called on commits returned by next().
47 int (*ack
)(struct fetch_negotiator
*, struct commit
*);
49 void (*release
)(struct fetch_negotiator
*);
55 void fetch_negotiator_init(struct fetch_negotiator
*negotiator
,
56 const char *algorithm
);