MCPcopy Create free account
hub / github.com/git/git / get_remote_heads

Function get_remote_heads

connect.c:340–392  ·  view source on GitHub ↗

* Read all the refs from the other end */

Source from the content-addressed store, hash-verified

338 * Read all the refs from the other end
339 */
340struct ref **get_remote_heads(struct packet_reader *reader,
341 struct ref **list, unsigned int flags,
342 struct oid_array *extra_have,
343 struct oid_array *shallow_points)
344{
345 struct ref **orig_list = list;
346 size_t len = 0;
347 enum get_remote_heads_state state = EXPECTING_FIRST_REF;
348
349 *list = NULL;
350
351 while (state != EXPECTING_DONE) {
352 switch (packet_reader_read(reader)) {
353 case PACKET_READ_EOF:
354 die_initial_contact(1);
355 case PACKET_READ_NORMAL:
356 len = reader->pktlen;
357 break;
358 case PACKET_READ_FLUSH:
359 state = EXPECTING_DONE;
360 break;
361 case PACKET_READ_DELIM:
362 case PACKET_READ_RESPONSE_END:
363 die(_("invalid packet"));
364 }
365
366 switch (state) {
367 case EXPECTING_FIRST_REF:
368 process_capabilities(reader, &len);
369 if (process_dummy_ref(reader)) {
370 state = EXPECTING_SHALLOW;
371 break;
372 }
373 state = EXPECTING_REF;
374 /* fallthrough */
375 case EXPECTING_REF:
376 if (process_ref(reader, len, &list, flags, extra_have))
377 break;
378 state = EXPECTING_SHALLOW;
379 /* fallthrough */
380 case EXPECTING_SHALLOW:
381 if (process_shallow(reader, len, shallow_points))
382 break;
383 die(_("protocol error: unexpected '%s'"), reader->line);
384 case EXPECTING_DONE:
385 break;
386 }
387 }
388
389 annotate_refs_with_symref_info(*orig_list);
390
391 return list;
392}
393
394/* Returns 1 when a valid ref has been added to `list`, 0 otherwise */
395static int process_ref_v2(struct packet_reader *reader, struct ref ***list,

Callers 4

handshakeFunction · 0.85
parse_git_refsFunction · 0.85
cmd_fetch_packFunction · 0.85
cmd_send_packFunction · 0.85

Calls 8

packet_reader_readFunction · 0.85
die_initial_contactFunction · 0.85
process_capabilitiesFunction · 0.85
process_dummy_refFunction · 0.85
process_refFunction · 0.85
dieFunction · 0.70
process_shallowFunction · 0.70

Tested by

no test coverage detected