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

Function fetch_alternates

http-walker.c:344–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344static void fetch_alternates(struct walker *walker, const char *base)
345{
346 struct strbuf buffer = STRBUF_INIT;
347 struct strbuf url = STRBUF_INIT;
348 struct active_request_slot *slot;
349 struct alternates_request alt_req;
350 struct walker_data *cdata = walker->data;
351
352 /*
353 * If another request has already started fetching alternates,
354 * wait for them to arrive and return to processing this request's
355 * curl message
356 */
357 while (cdata->got_alternates == 0) {
358 step_active_slots();
359 }
360
361 /* Nothing to do if they've already been fetched */
362 if (cdata->got_alternates == 1)
363 return;
364
365 /* Start the fetch */
366 cdata->got_alternates = 0;
367
368 if (walker->get_verbosely)
369 fprintf(stderr, "Getting alternates list for %s\n", base);
370
371 strbuf_addf(&url, "%s/objects/info/http-alternates", base);
372
373 /*
374 * Use a callback to process the result, since another request
375 * may fail and need to have alternates loaded before continuing
376 */
377 slot = get_active_slot();
378 slot->callback_func = process_alternates_response;
379 alt_req.walker = walker;
380 slot->callback_data = &alt_req;
381
382 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buffer);
383 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
384 curl_easy_setopt(slot->curl, CURLOPT_URL, url.buf);
385
386 alt_req.base = base;
387 alt_req.url = &url;
388 alt_req.buffer = &buffer;
389 alt_req.http_specific = 1;
390 alt_req.slot = slot;
391
392 if (start_active_slot(slot))
393 run_active_slot(slot);
394 else
395 cdata->got_alternates = -1;
396
397 strbuf_release(&buffer);
398 strbuf_release(&url);
399}
400
401static int fetch_indices(struct walker *walker, struct alt_base *repo)

Callers 2

process_object_responseFunction · 0.85
fetchFunction · 0.85

Calls 6

step_active_slotsFunction · 0.85
strbuf_addfFunction · 0.85
get_active_slotFunction · 0.85
start_active_slotFunction · 0.85
run_active_slotFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected