| 1623 | } |
| 1624 | |
| 1625 | static 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 | |
| 1669 | static int prune(int argc, const char **argv, const char *prefix, |
| 1670 | struct repository *repo UNUSED) |
no test coverage detected