| 2589 | } |
| 2590 | |
| 2591 | static int fetch_and_setup_pack_index(struct packfile_list *packs, |
| 2592 | unsigned char *sha1, |
| 2593 | const char *base_url) |
| 2594 | { |
| 2595 | struct packed_git *new_pack, *p; |
| 2596 | char *tmp_idx = NULL; |
| 2597 | int ret; |
| 2598 | |
| 2599 | /* |
| 2600 | * If we already have the pack locally, no need to fetch its index or |
| 2601 | * even add it to list; we already have all of its objects. |
| 2602 | */ |
| 2603 | repo_for_each_pack(the_repository, p) { |
| 2604 | if (hasheq(p->hash, sha1, the_repository->hash_algo)) |
| 2605 | return 0; |
| 2606 | } |
| 2607 | |
| 2608 | tmp_idx = fetch_pack_index(sha1, base_url); |
| 2609 | if (!tmp_idx) |
| 2610 | return -1; |
| 2611 | |
| 2612 | new_pack = parse_pack_index(the_repository, sha1, tmp_idx); |
| 2613 | if (!new_pack) { |
| 2614 | free(tmp_idx); |
| 2615 | return -1; /* parse_pack_index() already issued error message */ |
| 2616 | } |
| 2617 | |
| 2618 | ret = verify_pack_index(new_pack); |
| 2619 | |
| 2620 | close_pack_index(new_pack); |
| 2621 | free(tmp_idx); |
| 2622 | if (ret) { |
| 2623 | free(new_pack); |
| 2624 | return -1; |
| 2625 | } |
| 2626 | |
| 2627 | packfile_list_prepend(packs, new_pack); |
| 2628 | return 0; |
| 2629 | } |
| 2630 | |
| 2631 | int http_get_info_packs(const char *base_url, struct packfile_list *packs) |
| 2632 | { |
no test coverage detected