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

Function prune_ref

refs/files-backend.c:1320–1348  ·  view source on GitHub ↗

make sure nobody touched the ref, and unlink */

Source from the content-addressed store, hash-verified

1318
1319/* make sure nobody touched the ref, and unlink */
1320static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)
1321{
1322 struct ref_transaction *transaction;
1323 struct strbuf err = STRBUF_INIT;
1324 int ret = -1;
1325
1326 if (check_refname_format(r->name, 0))
1327 return;
1328
1329 transaction = ref_store_transaction_begin(&refs->base, 0, &err);
1330 if (!transaction)
1331 goto cleanup;
1332 ref_transaction_add_update(
1333 transaction, r->name,
1334 REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING,
1335 null_oid(the_hash_algo), &r->oid, NULL, NULL, NULL,
1336 NULL, NULL);
1337 if (ref_transaction_commit(transaction, &err))
1338 goto cleanup;
1339
1340 ret = 0;
1341
1342cleanup:
1343 if (ret)
1344 error("%s", err.buf);
1345 strbuf_release(&err);
1346 ref_transaction_free(transaction);
1347 return;
1348}
1349
1350/*
1351 * Prune the loose versions of the references in the linked list

Callers 1

prune_refsFunction · 0.85

Calls 8

check_refname_formatFunction · 0.85
null_oidFunction · 0.85
ref_transaction_commitFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
ref_transaction_freeFunction · 0.85

Tested by

no test coverage detected