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

Function process_alternates_response

http-walker.c:203–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203static void process_alternates_response(void *callback_data)
204{
205 struct alternates_request *alt_req =
206 (struct alternates_request *)callback_data;
207 struct walker *walker = alt_req->walker;
208 struct walker_data *cdata = walker->data;
209 struct active_request_slot *slot = alt_req->slot;
210 struct alt_base *tail = cdata->alt;
211 const char *base = alt_req->base;
212 const char null_byte = '\0';
213 char *data;
214 int i = 0;
215
216 normalize_curl_result(&slot->curl_result, slot->http_code,
217 curl_errorstr, sizeof(curl_errorstr));
218
219 if (alt_req->http_specific) {
220 if (slot->curl_result != CURLE_OK ||
221 !alt_req->buffer->len) {
222
223 /* Try reusing the slot to get non-http alternates */
224 alt_req->http_specific = 0;
225 strbuf_reset(alt_req->url);
226 strbuf_addf(alt_req->url, "%s/objects/info/alternates",
227 base);
228 curl_easy_setopt(slot->curl, CURLOPT_URL,
229 alt_req->url->buf);
230 active_requests++;
231 slot->in_use = 1;
232 if (slot->finished)
233 (*slot->finished) = 0;
234 if (!start_active_slot(slot)) {
235 cdata->got_alternates = -1;
236 slot->in_use = 0;
237 if (slot->finished)
238 (*slot->finished) = 1;
239 }
240 return;
241 }
242 } else if (slot->curl_result != CURLE_OK) {
243 if (!missing_target(slot)) {
244 cdata->got_alternates = -1;
245 return;
246 }
247 }
248
249 fwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer);
250 alt_req->buffer->len--;
251 data = alt_req->buffer->buf;
252
253 while (i < alt_req->buffer->len) {
254 int posn = i;
255 while (posn < alt_req->buffer->len && data[posn] != '\n')
256 posn++;
257 if (data[posn] == '\n') {
258 int okay = 0;
259 int serverlen = 0;
260 struct alt_base *newalt;

Callers

nothing calls this directly

Calls 10

normalize_curl_resultFunction · 0.85
strbuf_addfFunction · 0.85
start_active_slotFunction · 0.85
fwrite_bufferFunction · 0.85
strbuf_addFunction · 0.85
strbuf_strip_suffixFunction · 0.85
warningFunction · 0.85
strbuf_releaseFunction · 0.85
is_alternate_allowedFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected