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

Function parse_info_refs

remote-curl.c:296–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296static struct ref *parse_info_refs(struct discovery *heads)
297{
298 char *data, *start, *mid;
299 char *ref_name;
300 int i = 0;
301
302 struct ref *refs = NULL;
303 struct ref *ref = NULL;
304 struct ref *last_ref = NULL;
305
306 options.hash_algo = detect_hash_algo(heads);
307 if (!options.hash_algo)
308 die("%sinfo/refs not valid: could not determine hash algorithm; "
309 "is this a git repository?",
310 transport_anonymize_url(url.buf));
311
312 /*
313 * Set the repository's hash algo to whatever we have just detected.
314 * This ensures that we can correctly parse the remote references.
315 */
316 repo_set_hash_algo(the_repository, hash_algo_by_ptr(options.hash_algo));
317
318 data = heads->buf;
319 start = NULL;
320 mid = data;
321 while (i < heads->len) {
322 if (!start) {
323 start = &data[i];
324 }
325 if (data[i] == '\t')
326 mid = &data[i];
327 if (data[i] == '\n') {
328 if (mid - start != options.hash_algo->hexsz)
329 die(_("%sinfo/refs not valid: is this a git repository?"),
330 transport_anonymize_url(url.buf));
331 data[i] = 0;
332 ref_name = mid + 1;
333 ref = alloc_ref(ref_name);
334 get_oid_hex_algop(start, &ref->old_oid, options.hash_algo);
335 if (!refs)
336 refs = ref;
337 if (last_ref)
338 last_ref->next = ref;
339 last_ref = ref;
340 start = NULL;
341 }
342 i++;
343 }
344
345 ref = alloc_ref("HEAD");
346 if (!http_fetch_ref(url.buf, ref) &&
347 !resolve_remote_symref(ref, refs)) {
348 ref->next = refs;
349 refs = ref;
350 } else {
351 free_one_ref(ref);
352 }
353

Callers 1

discover_refsFunction · 0.85

Calls 10

detect_hash_algoFunction · 0.85
transport_anonymize_urlFunction · 0.85
repo_set_hash_algoFunction · 0.85
hash_algo_by_ptrFunction · 0.85
alloc_refFunction · 0.85
get_oid_hex_algopFunction · 0.85
http_fetch_refFunction · 0.85
resolve_remote_symrefFunction · 0.85
free_one_refFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected