| 348 | } |
| 349 | |
| 350 | static int find_common(struct fetch_negotiator *negotiator, |
| 351 | struct fetch_pack_args *args, |
| 352 | int fd[2], struct object_id *result_oid, |
| 353 | struct ref *refs) |
| 354 | { |
| 355 | int fetching; |
| 356 | int count = 0, flushes = 0, flush_at = INITIAL_FLUSH, retval; |
| 357 | int negotiation_round = 0, haves = 0; |
| 358 | const struct object_id *oid; |
| 359 | unsigned in_vain = 0; |
| 360 | int got_continue = 0; |
| 361 | int got_ready = 0; |
| 362 | struct strbuf req_buf = STRBUF_INIT; |
| 363 | size_t state_len = 0; |
| 364 | struct packet_reader reader; |
| 365 | struct oidset negotiation_include_oids = OIDSET_INIT; |
| 366 | |
| 367 | if (args->stateless_rpc && multi_ack == 1) |
| 368 | die(_("the option '%s' requires '%s'"), "--stateless-rpc", "multi_ack_detailed"); |
| 369 | |
| 370 | packet_reader_init(&reader, fd[0], NULL, 0, |
| 371 | PACKET_READ_CHOMP_NEWLINE | |
| 372 | PACKET_READ_DIE_ON_ERR_PACKET); |
| 373 | |
| 374 | mark_tips(negotiator, args->negotiation_restrict_tips); |
| 375 | for_each_cached_alternate(negotiator, insert_one_alternate_object); |
| 376 | |
| 377 | fetching = 0; |
| 378 | for ( ; refs ; refs = refs->next) { |
| 379 | struct object_id *remote = &refs->old_oid; |
| 380 | const char *remote_hex; |
| 381 | struct object *o; |
| 382 | |
| 383 | if (!args->refetch) { |
| 384 | /* |
| 385 | * If that object is complete (i.e. it is an ancestor of a |
| 386 | * local ref), we tell them we have it but do not have to |
| 387 | * tell them about its ancestors, which they already know |
| 388 | * about. |
| 389 | * |
| 390 | * We use lookup_object here because we are only |
| 391 | * interested in the case we *know* the object is |
| 392 | * reachable and we have already scanned it. |
| 393 | */ |
| 394 | if (((o = lookup_object(the_repository, remote)) != NULL) && |
| 395 | (o->flags & COMPLETE)) { |
| 396 | continue; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | remote_hex = oid_to_hex(remote); |
| 401 | if (!fetching) { |
| 402 | struct strbuf c = STRBUF_INIT; |
| 403 | if (multi_ack == 2) strbuf_addstr(&c, " multi_ack_detailed"); |
| 404 | if (multi_ack == 1) strbuf_addstr(&c, " multi_ack"); |
| 405 | if (no_done) strbuf_addstr(&c, " no-done"); |
| 406 | if (use_sideband == 2) strbuf_addstr(&c, " side-band-64k"); |
| 407 | if (use_sideband == 1) strbuf_addstr(&c, " side-band"); |
no test coverage detected