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

Function add_wants

fetch-pack.c:1303–1331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1301}
1302
1303static void add_wants(const struct ref *wants, struct strbuf *req_buf)
1304{
1305 int use_ref_in_want = server_supports_feature("fetch", "ref-in-want", 0);
1306
1307 for ( ; wants ; wants = wants->next) {
1308 const struct object_id *remote = &wants->old_oid;
1309 struct object *o;
1310
1311 /*
1312 * If that object is complete (i.e. it is an ancestor of a
1313 * local ref), we tell them we have it but do not have to
1314 * tell them about its ancestors, which they already know
1315 * about.
1316 *
1317 * We use lookup_object here because we are only
1318 * interested in the case we *know* the object is
1319 * reachable and we have already scanned it.
1320 */
1321 if (((o = lookup_object(the_repository, remote)) != NULL) &&
1322 (o->flags & COMPLETE)) {
1323 continue;
1324 }
1325
1326 if (!use_ref_in_want || wants->exact_oid)
1327 packet_buf_write(req_buf, "want %s\n", oid_to_hex(remote));
1328 else
1329 packet_buf_write(req_buf, "want-ref %s\n", wants->name);
1330 }
1331}
1332
1333static void add_common(struct strbuf *req_buf, struct oidset *common)
1334{

Callers 1

send_fetch_requestFunction · 0.85

Calls 4

server_supports_featureFunction · 0.85
lookup_objectFunction · 0.85
packet_buf_writeFunction · 0.85
oid_to_hexFunction · 0.85

Tested by

no test coverage detected