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

Function prune_remote

builtin/remote.c:1625–1667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1623}
1624
1625static int prune_remote(const char *remote, int dry_run)
1626{
1627 int result = 0;
1628 struct ref_states states = REF_STATES_INIT;
1629 struct string_list refs_to_prune = STRING_LIST_INIT_NODUP;
1630 struct string_list_item *item;
1631
1632 get_remote_ref_states(remote, &states, GET_REF_STATES);
1633
1634 if (!states.stale.nr) {
1635 free_remote_ref_states(&states);
1636 return 0;
1637 }
1638
1639 printf_ln(_("Pruning %s"), remote);
1640 printf_ln(_("URL: %s"), states.remote->url.v[0]);
1641
1642 for_each_string_list_item(item, &states.stale)
1643 string_list_append(&refs_to_prune, item->util);
1644 string_list_sort(&refs_to_prune);
1645
1646 if (!dry_run)
1647 result |= refs_delete_refs(get_main_ref_store(the_repository),
1648 "remote: prune", &refs_to_prune, 0);
1649
1650 for_each_string_list_item(item, &states.stale) {
1651 const char *refname = item->util;
1652
1653 if (dry_run)
1654 printf_ln(_(" * [would prune] %s"),
1655 abbrev_ref(refname, "refs/remotes/"));
1656 else
1657 printf_ln(_(" * [pruned] %s"),
1658 abbrev_ref(refname, "refs/remotes/"));
1659 }
1660
1661 refs_warn_dangling_symrefs(get_main_ref_store(the_repository),
1662 stdout, " ", dry_run, &refs_to_prune);
1663
1664 string_list_clear(&refs_to_prune, 0);
1665 free_remote_ref_states(&states);
1666 return result;
1667}
1668
1669static int prune(int argc, const char **argv, const char *prefix,
1670 struct repository *repo UNUSED)

Callers 1

pruneFunction · 0.85

Calls 10

get_remote_ref_statesFunction · 0.85
free_remote_ref_statesFunction · 0.85
printf_lnFunction · 0.85
refs_delete_refsFunction · 0.85
get_main_ref_storeFunction · 0.85
abbrev_refFunction · 0.85
string_list_clearFunction · 0.85
string_list_appendFunction · 0.50
string_list_sortFunction · 0.50

Tested by

no test coverage detected