| 617 | } |
| 618 | |
| 619 | static int oid_object_info_convert(struct repository *r, |
| 620 | const struct object_id *input_oid, |
| 621 | struct object_info *input_oi, unsigned flags) |
| 622 | { |
| 623 | const struct git_hash_algo *input_algo = &hash_algos[input_oid->algo]; |
| 624 | int do_die = flags & OBJECT_INFO_DIE_IF_CORRUPT; |
| 625 | enum object_type type; |
| 626 | struct object_id oid, delta_base_oid; |
| 627 | struct object_info new_oi, *oi; |
| 628 | size_t size; |
| 629 | void *content; |
| 630 | int ret; |
| 631 | |
| 632 | if (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) { |
| 633 | if (do_die) |
| 634 | die(_("missing mapping of %s to %s"), |
| 635 | oid_to_hex(input_oid), r->hash_algo->name); |
| 636 | return -1; |
| 637 | } |
| 638 | |
| 639 | /* Is new_oi needed? */ |
| 640 | oi = input_oi; |
| 641 | if (input_oi && (input_oi->delta_base_oid || input_oi->sizep || |
| 642 | input_oi->contentp)) { |
| 643 | new_oi = *input_oi; |
| 644 | /* Does delta_base_oid need to be converted? */ |
| 645 | if (input_oi->delta_base_oid) |
| 646 | new_oi.delta_base_oid = &delta_base_oid; |
| 647 | /* Will the attributes differ when converted? */ |
| 648 | if (input_oi->sizep || input_oi->contentp) { |
| 649 | new_oi.contentp = &content; |
| 650 | new_oi.sizep = &size; |
| 651 | new_oi.typep = &type; |
| 652 | } |
| 653 | oi = &new_oi; |
| 654 | } |
| 655 | |
| 656 | ret = odb_read_object_info_extended(r->objects, &oid, oi, flags); |
| 657 | if (ret) |
| 658 | return -1; |
| 659 | if (oi == input_oi) |
| 660 | return ret; |
| 661 | |
| 662 | if (new_oi.contentp) { |
| 663 | struct strbuf outbuf = STRBUF_INIT; |
| 664 | |
| 665 | if (type != OBJ_BLOB) { |
| 666 | ret = convert_object_file(r, &outbuf, |
| 667 | r->hash_algo, input_algo, |
| 668 | content, size, type, !do_die); |
| 669 | free(content); |
| 670 | if (ret == -1) |
| 671 | return -1; |
| 672 | size = outbuf.len; |
| 673 | content = strbuf_detach(&outbuf, NULL); |
| 674 | } |
| 675 | if (input_oi->sizep) |
| 676 | *input_oi->sizep = size; |
no test coverage detected