MCPcopy Index your code
hub / github.com/git/git / new_direct_http_pack_request

Function new_direct_http_pack_request

http.c:2738–2786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2736}
2737
2738struct http_pack_request *new_direct_http_pack_request(
2739 const unsigned char *packed_git_hash, char *url)
2740{
2741 off_t prev_posn = 0;
2742 struct http_pack_request *preq;
2743
2744 CALLOC_ARRAY(preq, 1);
2745 strbuf_init(&preq->tmpfile, 0);
2746
2747 preq->url = url;
2748
2749 odb_pack_name(the_repository, &preq->tmpfile, packed_git_hash, "pack");
2750 strbuf_addstr(&preq->tmpfile, ".temp");
2751 preq->packfile = fopen(preq->tmpfile.buf, "a");
2752 if (!preq->packfile) {
2753 error("Unable to open local file %s for pack",
2754 preq->tmpfile.buf);
2755 goto abort;
2756 }
2757
2758 preq->slot = get_active_slot();
2759 preq->headers = object_request_headers();
2760 curl_easy_setopt(preq->slot->curl, CURLOPT_WRITEDATA, preq->packfile);
2761 curl_easy_setopt(preq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
2762 curl_easy_setopt(preq->slot->curl, CURLOPT_URL, preq->url);
2763 curl_easy_setopt(preq->slot->curl, CURLOPT_HTTPHEADER, preq->headers);
2764
2765 /*
2766 * If there is data present from a previous transfer attempt,
2767 * resume where it left off
2768 */
2769 prev_posn = ftello(preq->packfile);
2770 if (prev_posn>0) {
2771 if (http_is_verbose)
2772 fprintf(stderr,
2773 "Resuming fetch of pack %s at byte %"PRIuMAX"\n",
2774 hash_to_hex(packed_git_hash),
2775 (uintmax_t)prev_posn);
2776 http_opt_request_remainder(preq->slot->curl, prev_posn);
2777 }
2778
2779 return preq;
2780
2781abort:
2782 strbuf_release(&preq->tmpfile);
2783 free(preq->url);
2784 free(preq);
2785 return NULL;
2786}
2787
2788/* Helpers for fetching objects (loose) */
2789static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,

Callers 2

new_http_pack_requestFunction · 0.85
fetch_single_packfileFunction · 0.85

Calls 9

strbuf_initFunction · 0.85
odb_pack_nameFunction · 0.85
strbuf_addstrFunction · 0.85
errorFunction · 0.85
get_active_slotFunction · 0.85
object_request_headersFunction · 0.85
hash_to_hexFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected