| 1518 | } |
| 1519 | |
| 1520 | static int process_ack(struct fetch_negotiator *negotiator, |
| 1521 | struct packet_reader *reader, |
| 1522 | struct object_id *common_oid, |
| 1523 | int *received_ready) |
| 1524 | { |
| 1525 | while (packet_reader_read(reader) == PACKET_READ_NORMAL) { |
| 1526 | const char *arg; |
| 1527 | |
| 1528 | if (!strcmp(reader->line, "NAK")) |
| 1529 | continue; |
| 1530 | |
| 1531 | if (skip_prefix(reader->line, "ACK ", &arg)) { |
| 1532 | if (!get_oid_hex(arg, common_oid)) { |
| 1533 | struct commit *commit; |
| 1534 | commit = lookup_commit(the_repository, common_oid); |
| 1535 | if (negotiator) |
| 1536 | negotiator->ack(negotiator, commit); |
| 1537 | } |
| 1538 | return 1; |
| 1539 | } |
| 1540 | |
| 1541 | if (!strcmp(reader->line, "ready")) { |
| 1542 | *received_ready = 1; |
| 1543 | continue; |
| 1544 | } |
| 1545 | |
| 1546 | die(_("unexpected acknowledgment line: '%s'"), reader->line); |
| 1547 | } |
| 1548 | |
| 1549 | if (reader->status != PACKET_READ_FLUSH && |
| 1550 | reader->status != PACKET_READ_DELIM) |
| 1551 | die(_("error processing acks: %d"), reader->status); |
| 1552 | |
| 1553 | /* |
| 1554 | * If an "acknowledgments" section is sent, a packfile is sent if and |
| 1555 | * only if "ready" was sent in this section. The other sections |
| 1556 | * ("shallow-info" and "wanted-refs") are sent only if a packfile is |
| 1557 | * sent. Therefore, a DELIM is expected if "ready" is sent, and a FLUSH |
| 1558 | * otherwise. |
| 1559 | */ |
| 1560 | if (*received_ready && reader->status != PACKET_READ_DELIM) |
| 1561 | /* |
| 1562 | * TRANSLATORS: The parameter will be 'ready', a protocol |
| 1563 | * keyword. |
| 1564 | */ |
| 1565 | die(_("expected packfile to be sent after '%s'"), "ready"); |
| 1566 | if (!*received_ready && reader->status != PACKET_READ_FLUSH) |
| 1567 | /* |
| 1568 | * TRANSLATORS: The parameter will be 'ready', a protocol |
| 1569 | * keyword. |
| 1570 | */ |
| 1571 | die(_("expected no other sections to be sent after no '%s'"), "ready"); |
| 1572 | |
| 1573 | return 0; |
| 1574 | } |
| 1575 | |
| 1576 | static void receive_shallow_info(struct fetch_pack_args *args, |
| 1577 | struct packet_reader *reader, |
no test coverage detected