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

Function reduce_heads

commit-reach.c:653–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653struct commit_list *reduce_heads(struct commit_list *heads)
654{
655 struct commit_list *p;
656 struct commit_list *result = NULL, **tail = &result;
657 struct commit **array;
658 size_t num_head, i;
659 int ret;
660
661 if (!heads)
662 return NULL;
663
664 /* Uniquify */
665 for (p = heads; p; p = p->next)
666 p->item->object.flags &= ~STALE;
667 for (p = heads, num_head = 0; p; p = p->next) {
668 if (p->item->object.flags & STALE)
669 continue;
670 p->item->object.flags |= STALE;
671 num_head++;
672 }
673 CALLOC_ARRAY(array, num_head);
674 for (p = heads, i = 0; p; p = p->next) {
675 if (p->item->object.flags & STALE) {
676 array[i++] = p->item;
677 p->item->object.flags &= ~STALE;
678 }
679 }
680
681 ret = remove_redundant(the_repository, array, num_head, &num_head);
682 if (ret < 0) {
683 free(array);
684 return NULL;
685 }
686
687 for (i = 0; i < num_head; i++)
688 tail = &commit_list_insert(array[i], tail)->next;
689 free(array);
690 return result;
691}
692
693void reduce_heads_replace(struct commit_list **heads)
694{

Callers 4

reduce_heads_replaceFunction · 0.85
mark_redundant_parentsFunction · 0.85
cmd__reachFunction · 0.85
reduce_parentsFunction · 0.85

Calls 2

remove_redundantFunction · 0.85
commit_list_insertFunction · 0.85

Tested by 1

cmd__reachFunction · 0.68