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

Function get_ref_map

builtin/fetch.c:485–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485static struct ref *get_ref_map(struct remote *remote,
486 const struct ref *remote_refs,
487 struct refspec *rs,
488 int tags, int *autotags)
489{
490 int i;
491 struct ref *rm;
492 struct ref *ref_map = NULL;
493 struct ref **tail = &ref_map;
494
495 /* opportunistically-updated references: */
496 struct ref *orefs = NULL, **oref_tail = &orefs;
497
498 struct hashmap existing_refs;
499 int existing_refs_populated = 0;
500
501 filter_prefetch_refspec(rs);
502 if (remote)
503 filter_prefetch_refspec(&remote->fetch);
504
505 if (rs->nr) {
506 struct refspec *fetch_refspec;
507
508 for (i = 0; i < rs->nr; i++) {
509 get_fetch_map(remote_refs, &rs->items[i], &tail, 0);
510 if (rs->items[i].dst && rs->items[i].dst[0])
511 *autotags = 1;
512 }
513 /* Merge everything on the command line (but not --tags) */
514 for (rm = ref_map; rm; rm = rm->next)
515 rm->fetch_head_status = FETCH_HEAD_MERGE;
516
517 /*
518 * For any refs that we happen to be fetching via
519 * command-line arguments, the destination ref might
520 * have been missing or have been different than the
521 * remote-tracking ref that would be derived from the
522 * configured refspec. In these cases, we want to
523 * take the opportunity to update their configured
524 * remote-tracking reference. However, we do not want
525 * to mention these entries in FETCH_HEAD at all, as
526 * they would simply be duplicates of existing
527 * entries, so we set them FETCH_HEAD_IGNORE below.
528 *
529 * We compute these entries now, based only on the
530 * refspecs specified on the command line. But we add
531 * them to the list following the refspecs resulting
532 * from the tags option so that one of the latter,
533 * which has FETCH_HEAD_NOT_FOR_MERGE, is not removed
534 * by ref_remove_duplicates() in favor of one of these
535 * opportunistic entries with FETCH_HEAD_IGNORE.
536 */
537 if (refmap.nr)
538 fetch_refspec = &refmap;
539 else
540 fetch_refspec = &remote->fetch;
541
542 for (i = 0; i < fetch_refspec->nr; i++)

Callers 1

do_fetchFunction · 0.85

Calls 15

filter_prefetch_refspecFunction · 0.85
get_fetch_mapFunction · 0.85
branch_getFunction · 0.85
branch_has_merge_configFunction · 0.85
add_merge_configFunction · 0.85
get_remote_refFunction · 0.85
refspec_item_init_pushFunction · 0.85
refspec_item_clearFunction · 0.85
find_non_local_tagsFunction · 0.85
apply_negative_refspecsFunction · 0.85
ref_remove_duplicatesFunction · 0.85
strhashFunction · 0.85

Tested by

no test coverage detected