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

Function start_put

http-push.c:360–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360static void start_put(struct transfer_request *request)
361{
362 char *hex = oid_to_hex(&request->obj->oid);
363 struct active_request_slot *slot;
364 struct strbuf buf = STRBUF_INIT;
365 enum object_type type;
366 char hdr[50];
367 void *unpacked;
368 size_t len;
369 int hdrlen;
370 ssize_t size;
371 git_zstream stream;
372 struct repo_config_values *cfg = repo_config_values(the_repository);
373
374 unpacked = odb_read_object(the_repository->objects, &request->obj->oid,
375 &type, &len);
376 hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
377
378 /* Set it up */
379 git_deflate_init(&stream, cfg->zlib_compression_level);
380 size = git_deflate_bound(&stream, len + hdrlen);
381 strbuf_grow(&request->buffer.buf, size);
382 request->buffer.posn = 0;
383
384 /* Compress it */
385 stream.next_out = (unsigned char *)request->buffer.buf.buf;
386 stream.avail_out = size;
387
388 /* First header.. */
389 stream.next_in = (void *)hdr;
390 stream.avail_in = hdrlen;
391 while (git_deflate(&stream, 0) == Z_OK)
392 ; /* nothing */
393
394 /* Then the data itself.. */
395 stream.next_in = unpacked;
396 stream.avail_in = len;
397 while (git_deflate(&stream, Z_FINISH) == Z_OK)
398 ; /* nothing */
399 git_deflate_end(&stream);
400 free(unpacked);
401
402 request->buffer.buf.len = stream.total_out;
403
404 strbuf_addstr(&buf, "Destination: ");
405 append_remote_object_url(&buf, repo->url, hex, 0);
406 request->dest = strbuf_detach(&buf, NULL);
407
408 append_remote_object_url(&buf, repo->url, hex, 0);
409 strbuf_add(&buf, request->lock->tmpfile_suffix, the_hash_algo->hexsz + 1);
410 request->url = strbuf_detach(&buf, NULL);
411
412 slot = get_active_slot();
413 slot->callback_func = process_response;
414 slot->callback_data = request;
415 curl_setup_http(slot->curl, request->url, DAV_PUT,
416 &request->buffer, fwrite_null);
417

Callers 2

finish_requestFunction · 0.85
fill_active_slotFunction · 0.85

Calls 15

oid_to_hexFunction · 0.85
odb_read_objectFunction · 0.85
format_object_headerFunction · 0.85
git_deflate_initFunction · 0.85
git_deflate_boundFunction · 0.85
strbuf_growFunction · 0.85
git_deflateFunction · 0.85
git_deflate_endFunction · 0.85
strbuf_addstrFunction · 0.85
append_remote_object_urlFunction · 0.85
strbuf_detachFunction · 0.85
strbuf_addFunction · 0.85

Tested by

no test coverage detected