| 2523 | } |
| 2524 | |
| 2525 | int http_fetch_ref(const char *base, struct ref *ref) |
| 2526 | { |
| 2527 | struct http_get_options options = {0}; |
| 2528 | char *url; |
| 2529 | struct strbuf buffer = STRBUF_INIT; |
| 2530 | int ret = -1; |
| 2531 | |
| 2532 | options.no_cache = 1; |
| 2533 | |
| 2534 | url = quote_ref_url(base, ref->name); |
| 2535 | if (http_get_strbuf(url, &buffer, &options) == HTTP_OK) { |
| 2536 | strbuf_rtrim(&buffer); |
| 2537 | if (buffer.len == the_hash_algo->hexsz) |
| 2538 | ret = get_oid_hex(buffer.buf, &ref->old_oid); |
| 2539 | else if (starts_with(buffer.buf, "ref: ")) { |
| 2540 | ref->symref = xstrdup(buffer.buf + 5); |
| 2541 | ret = 0; |
| 2542 | } |
| 2543 | } |
| 2544 | |
| 2545 | strbuf_release(&buffer); |
| 2546 | free(url); |
| 2547 | return ret; |
| 2548 | } |
| 2549 | |
| 2550 | /* Helpers for fetching packs */ |
| 2551 | static char *fetch_pack_index(unsigned char *hash, const char *base_url) |
no test coverage detected