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

Function prune_refs

builtin/fetch.c:1446–1493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1444}
1445
1446static int prune_refs(struct display_state *display_state,
1447 struct refspec *rs,
1448 struct ref_transaction *transaction,
1449 struct ref *ref_map)
1450{
1451 int result = 0;
1452 struct ref *ref, *stale_refs = get_stale_heads(rs, ref_map);
1453 struct strbuf err = STRBUF_INIT;
1454 struct string_list refnames = STRING_LIST_INIT_NODUP;
1455
1456 for (ref = stale_refs; ref; ref = ref->next)
1457 string_list_append(&refnames, ref->name);
1458
1459 if (!dry_run) {
1460 if (transaction) {
1461 for (ref = stale_refs; ref; ref = ref->next) {
1462 result = ref_transaction_delete(transaction, ref->name, NULL,
1463 NULL, 0, "fetch: prune", &err);
1464 if (result)
1465 goto cleanup;
1466 }
1467 } else {
1468 result = refs_delete_refs(get_main_ref_store(the_repository),
1469 "fetch: prune", &refnames,
1470 0);
1471 }
1472 }
1473
1474 if (verbosity >= 0) {
1475 int summary_width = transport_summary_width(stale_refs);
1476
1477 for (ref = stale_refs; ref; ref = ref->next) {
1478 display_ref_update(display_state, '-', _("[deleted]"), NULL,
1479 _("(none)"), ref->name,
1480 &ref->new_oid, &ref->old_oid,
1481 summary_width);
1482 }
1483 string_list_sort(&refnames);
1484 refs_warn_dangling_symrefs(get_main_ref_store(the_repository),
1485 stderr, " ", dry_run, &refnames);
1486 }
1487
1488cleanup:
1489 string_list_clear(&refnames, 0);
1490 strbuf_release(&err);
1491 free_refs(stale_refs);
1492 return result;
1493}
1494
1495static void check_not_current_branch(struct ref *ref_map)
1496{

Callers 1

do_fetchFunction · 0.70

Calls 12

get_stale_headsFunction · 0.85
ref_transaction_deleteFunction · 0.85
refs_delete_refsFunction · 0.85
get_main_ref_storeFunction · 0.85
transport_summary_widthFunction · 0.85
display_ref_updateFunction · 0.85
string_list_clearFunction · 0.85
strbuf_releaseFunction · 0.85
free_refsFunction · 0.85
string_list_appendFunction · 0.50
string_list_sortFunction · 0.50

Tested by

no test coverage detected