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

Function fwrite_sha1_file

http.c:2789–2826  ·  view source on GitHub ↗

Helpers for fetching objects (loose) */

Source from the content-addressed store, hash-verified

2787
2788/* Helpers for fetching objects (loose) */
2789static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
2790 void *data)
2791{
2792 unsigned char expn[4096];
2793 size_t size = eltsize * nmemb;
2794 int posn = 0;
2795 struct http_object_request *freq = data;
2796 struct active_request_slot *slot = freq->slot;
2797
2798 if (slot) {
2799 CURLcode c = curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE,
2800 &slot->http_code);
2801 if (c != CURLE_OK)
2802 BUG("curl_easy_getinfo for HTTP code failed: %s",
2803 curl_easy_strerror(c));
2804 if (slot->http_code >= 300)
2805 return nmemb;
2806 }
2807
2808 do {
2809 ssize_t retval = xwrite(freq->localfile,
2810 (char *) ptr + posn, size - posn);
2811 if (retval < 0)
2812 return posn / eltsize;
2813 posn += retval;
2814 } while (posn < size);
2815
2816 freq->stream.avail_in = size;
2817 freq->stream.next_in = (void *)ptr;
2818 do {
2819 freq->stream.next_out = expn;
2820 freq->stream.avail_out = sizeof(expn);
2821 freq->zret = git_inflate(&freq->stream, Z_SYNC_FLUSH);
2822 git_hash_update(&freq->c, expn,
2823 sizeof(expn) - freq->stream.avail_out);
2824 } while (freq->stream.avail_in && freq->zret == Z_OK);
2825 return nmemb;
2826}
2827
2828struct http_object_request *new_http_object_request(const char *base_url,
2829 const struct object_id *oid)

Callers 1

new_http_object_requestFunction · 0.85

Calls 3

xwriteFunction · 0.85
git_inflateFunction · 0.85
git_hash_updateFunction · 0.85

Tested by

no test coverage detected