| 1574 | } |
| 1575 | |
| 1576 | static void receive_shallow_info(struct fetch_pack_args *args, |
| 1577 | struct packet_reader *reader, |
| 1578 | struct oid_array *shallows, |
| 1579 | struct shallow_info *si) |
| 1580 | { |
| 1581 | int unshallow_received = 0; |
| 1582 | |
| 1583 | process_section_header(reader, "shallow-info", 0); |
| 1584 | while (packet_reader_read(reader) == PACKET_READ_NORMAL) { |
| 1585 | const char *arg; |
| 1586 | struct object_id oid; |
| 1587 | |
| 1588 | if (skip_prefix(reader->line, "shallow ", &arg)) { |
| 1589 | if (get_oid_hex(arg, &oid)) |
| 1590 | die(_("invalid shallow line: %s"), reader->line); |
| 1591 | oid_array_append(shallows, &oid); |
| 1592 | continue; |
| 1593 | } |
| 1594 | if (skip_prefix(reader->line, "unshallow ", &arg)) { |
| 1595 | if (get_oid_hex(arg, &oid)) |
| 1596 | die(_("invalid unshallow line: %s"), reader->line); |
| 1597 | if (!lookup_object(the_repository, &oid)) |
| 1598 | die(_("object not found: %s"), reader->line); |
| 1599 | /* make sure that it is parsed as shallow */ |
| 1600 | if (!parse_object(the_repository, &oid)) |
| 1601 | die(_("error in object: %s"), reader->line); |
| 1602 | if (unregister_shallow(&oid)) |
| 1603 | die(_("no shallow found: %s"), reader->line); |
| 1604 | unshallow_received = 1; |
| 1605 | continue; |
| 1606 | } |
| 1607 | die(_("expected shallow/unshallow, got %s"), reader->line); |
| 1608 | } |
| 1609 | |
| 1610 | if (reader->status != PACKET_READ_FLUSH && |
| 1611 | reader->status != PACKET_READ_DELIM) |
| 1612 | die(_("error processing shallow info: %d"), reader->status); |
| 1613 | |
| 1614 | if (args->deepen || unshallow_received) { |
| 1615 | /* |
| 1616 | * Treat these as shallow lines caused by our depth settings. |
| 1617 | * In v0, these lines cannot cause refs to be rejected; do the |
| 1618 | * same. |
| 1619 | */ |
| 1620 | int i; |
| 1621 | |
| 1622 | for (i = 0; i < shallows->nr; i++) |
| 1623 | register_shallow(the_repository, &shallows->oid[i]); |
| 1624 | setup_alternate_shallow(&shallow_lock, &alternate_shallow_file, |
| 1625 | NULL); |
| 1626 | args->deepen = 1; |
| 1627 | } else if (shallows->nr) { |
| 1628 | /* |
| 1629 | * Treat these as shallow lines caused by the remote being |
| 1630 | * shallow. In v0, remote refs that reach these objects are |
| 1631 | * rejected (unless --update-shallow is set); do the same. |
| 1632 | */ |
| 1633 | prepare_shallow_info(si, shallows); |
no test coverage detected