MCPcopy Create free account
hub / github.com/git/git / add_haves

Function add_haves

fetch-pack.c:1344–1377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1342}
1343
1344static int add_haves(struct fetch_negotiator *negotiator,
1345 struct strbuf *req_buf,
1346 int *haves_to_send,
1347 struct oidset *negotiation_include_oids)
1348{
1349 int haves_added = 0;
1350 const struct object_id *oid;
1351
1352 /* Send unconditional haves from --negotiation-include */
1353 if (negotiation_include_oids) {
1354 struct oidset_iter iter;
1355 oidset_iter_init(negotiation_include_oids, &iter);
1356
1357 while ((oid = oidset_iter_next(&iter))) {
1358 struct commit *commit = lookup_commit(the_repository, oid);
1359 if (commit) {
1360 packet_buf_write(req_buf, "have %s\n",
1361 oid_to_hex(oid));
1362 negotiator->have_sent(negotiator, commit);
1363 }
1364 }
1365 }
1366
1367 while ((oid = negotiator->next(negotiator))) {
1368 packet_buf_write(req_buf, "have %s\n", oid_to_hex(oid));
1369 if (++haves_added >= *haves_to_send)
1370 break;
1371 }
1372
1373 /* Increase haves to send on next round */
1374 *haves_to_send = next_flush(1, *haves_to_send);
1375
1376 return haves_added;
1377}
1378
1379static void write_fetch_command_and_capabilities(struct strbuf *req_buf,
1380 const struct string_list *server_options)

Callers 2

send_fetch_requestFunction · 0.85
negotiate_using_fetchFunction · 0.85

Calls 7

oidset_iter_initFunction · 0.85
oidset_iter_nextFunction · 0.85
lookup_commitFunction · 0.85
packet_buf_writeFunction · 0.85
oid_to_hexFunction · 0.85
next_flushFunction · 0.85
nextMethod · 0.80

Tested by

no test coverage detected