| 1505 | } |
| 1506 | |
| 1507 | static int parse_want_ref(struct packet_writer *writer, const char *line, |
| 1508 | struct strmap *wanted_refs, |
| 1509 | struct strvec *hidden_refs, |
| 1510 | struct object_array *want_obj) |
| 1511 | { |
| 1512 | const char *refname_nons; |
| 1513 | if (skip_prefix(line, "want-ref ", &refname_nons)) { |
| 1514 | struct object_id oid; |
| 1515 | struct object *o = NULL; |
| 1516 | struct strbuf refname = STRBUF_INIT; |
| 1517 | |
| 1518 | strbuf_addf(&refname, "%s%s", get_git_namespace(), refname_nons); |
| 1519 | if (ref_is_hidden(refname_nons, refname.buf, hidden_refs) || |
| 1520 | refs_read_ref(get_main_ref_store(the_repository), refname.buf, &oid)) { |
| 1521 | packet_writer_error(writer, "unknown ref %s", refname_nons); |
| 1522 | die("unknown ref %s", refname_nons); |
| 1523 | } |
| 1524 | strbuf_release(&refname); |
| 1525 | |
| 1526 | if (strmap_put(wanted_refs, refname_nons, oiddup(&oid))) { |
| 1527 | packet_writer_error(writer, "duplicate want-ref %s", |
| 1528 | refname_nons); |
| 1529 | die("duplicate want-ref %s", refname_nons); |
| 1530 | } |
| 1531 | |
| 1532 | if (!starts_with(refname_nons, "refs/tags/")) { |
| 1533 | struct commit *commit = lookup_commit_in_graph(the_repository, &oid); |
| 1534 | if (commit) |
| 1535 | o = &commit->object; |
| 1536 | } |
| 1537 | |
| 1538 | if (!o) |
| 1539 | o = parse_object_or_die(the_repository, &oid, refname_nons); |
| 1540 | |
| 1541 | if (!(o->flags & WANTED)) { |
| 1542 | o->flags |= WANTED; |
| 1543 | add_object_array(o, NULL, want_obj); |
| 1544 | } |
| 1545 | |
| 1546 | return 1; |
| 1547 | } |
| 1548 | |
| 1549 | return 0; |
| 1550 | } |
| 1551 | |
| 1552 | static int parse_have(const char *line, struct upload_pack_data *data) |
| 1553 | { |
no test coverage detected